Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mm-hotfixes-stable-2024-04-26-13-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull misc fixes from Andrew Morton:
"11 hotfixes. 8 are cc:stable and the remaining 3 (nice ratio!) address
post-6.8 issues or aren't considered suitable for backporting.

All except one of these are for MM. I see no particular theme - it's
singletons all over"

* tag 'mm-hotfixes-stable-2024-04-26-13-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when dissolve_free_hugetlb_folio()
selftests: mm: protection_keys: save/restore nr_hugepages value from launch script
stackdepot: respect __GFP_NOLOCKDEP allocation flag
hugetlb: check for anon_vma prior to folio allocation
mm: zswap: fix shrinker NULL crash with cgroup_disable=memory
mm: turn folio_test_hugetlb into a PageType
mm: support page_mapcount() on page_has_type() pages
mm: create FOLIO_FLAG_FALSE and FOLIO_TYPE_OPS macros
mm/hugetlb: fix missing hugetlb_lock for resv uncharge
selftests: mm: fix unused and uninitialized variable warning
selftests/harness: remove use of LINE_MAX

+138 -153
+2 -5
fs/proc/page.c
··· 67 67 */ 68 68 ppage = pfn_to_online_page(pfn); 69 69 70 - if (!ppage || PageSlab(ppage) || page_has_type(ppage)) 70 + if (!ppage) 71 71 pcount = 0; 72 72 else 73 73 pcount = page_mapcount(ppage); ··· 124 124 125 125 /* 126 126 * pseudo flags for the well known (anonymous) memory mapped pages 127 - * 128 - * Note that page->_mapcount is overloaded in SLAB, so the 129 - * simple test in page_mapped() is not enough. 130 127 */ 131 - if (!PageSlab(page) && page_mapped(page)) 128 + if (page_mapped(page)) 132 129 u |= 1 << KPF_MMAP; 133 130 if (PageAnon(page)) 134 131 u |= 1 << KPF_ANON;
+5 -3
include/linux/mm.h
··· 1223 1223 * a large folio, it includes the number of times this page is mapped 1224 1224 * as part of that folio. 1225 1225 * 1226 - * The result is undefined for pages which cannot be mapped into userspace. 1227 - * For example SLAB or special types of pages. See function page_has_type(). 1228 - * They use this field in struct page differently. 1226 + * Will report 0 for pages which cannot be mapped into userspace, eg 1227 + * slab, page tables and similar. 1229 1228 */ 1230 1229 static inline int page_mapcount(struct page *page) 1231 1230 { 1232 1231 int mapcount = atomic_read(&page->_mapcount) + 1; 1233 1232 1233 + /* Handle page_has_type() pages */ 1234 + if (mapcount < 0) 1235 + mapcount = 0; 1234 1236 if (unlikely(PageCompound(page))) 1235 1237 mapcount += folio_entire_mapcount(page_folio(page)); 1236 1238
+83 -63
include/linux/page-flags.h
··· 190 190 191 191 /* At least one page in this folio has the hwpoison flag set */ 192 192 PG_has_hwpoisoned = PG_error, 193 - PG_hugetlb = PG_active, 194 193 PG_large_rmappable = PG_workingset, /* anon or file-backed */ 195 194 }; 196 195 ··· 457 458 TESTSETFLAG(uname, lname, policy) \ 458 459 TESTCLEARFLAG(uname, lname, policy) 459 460 461 + #define FOLIO_TEST_FLAG_FALSE(name) \ 462 + static inline bool folio_test_##name(const struct folio *folio) \ 463 + { return false; } 464 + #define FOLIO_SET_FLAG_NOOP(name) \ 465 + static inline void folio_set_##name(struct folio *folio) { } 466 + #define FOLIO_CLEAR_FLAG_NOOP(name) \ 467 + static inline void folio_clear_##name(struct folio *folio) { } 468 + #define __FOLIO_SET_FLAG_NOOP(name) \ 469 + static inline void __folio_set_##name(struct folio *folio) { } 470 + #define __FOLIO_CLEAR_FLAG_NOOP(name) \ 471 + static inline void __folio_clear_##name(struct folio *folio) { } 472 + #define FOLIO_TEST_SET_FLAG_FALSE(name) \ 473 + static inline bool folio_test_set_##name(struct folio *folio) \ 474 + { return false; } 475 + #define FOLIO_TEST_CLEAR_FLAG_FALSE(name) \ 476 + static inline bool folio_test_clear_##name(struct folio *folio) \ 477 + { return false; } 478 + 479 + #define FOLIO_FLAG_FALSE(name) \ 480 + FOLIO_TEST_FLAG_FALSE(name) \ 481 + FOLIO_SET_FLAG_NOOP(name) \ 482 + FOLIO_CLEAR_FLAG_NOOP(name) 483 + 460 484 #define TESTPAGEFLAG_FALSE(uname, lname) \ 461 - static inline bool folio_test_##lname(const struct folio *folio) { return false; } \ 485 + FOLIO_TEST_FLAG_FALSE(lname) \ 462 486 static inline int Page##uname(const struct page *page) { return 0; } 463 487 464 488 #define SETPAGEFLAG_NOOP(uname, lname) \ 465 - static inline void folio_set_##lname(struct folio *folio) { } \ 489 + FOLIO_SET_FLAG_NOOP(lname) \ 466 490 static inline void SetPage##uname(struct page *page) { } 467 491 468 492 #define CLEARPAGEFLAG_NOOP(uname, lname) \ 469 - static inline void folio_clear_##lname(struct folio *folio) { } \ 493 + FOLIO_CLEAR_FLAG_NOOP(lname) \ 470 494 static inline void ClearPage##uname(struct page *page) { } 471 495 472 496 #define __CLEARPAGEFLAG_NOOP(uname, lname) \ 473 - static inline void __folio_clear_##lname(struct folio *folio) { } \ 497 + __FOLIO_CLEAR_FLAG_NOOP(lname) \ 474 498 static inline void __ClearPage##uname(struct page *page) { } 475 499 476 500 #define TESTSETFLAG_FALSE(uname, lname) \ 477 - static inline bool folio_test_set_##lname(struct folio *folio) \ 478 - { return 0; } \ 501 + FOLIO_TEST_SET_FLAG_FALSE(lname) \ 479 502 static inline int TestSetPage##uname(struct page *page) { return 0; } 480 503 481 504 #define TESTCLEARFLAG_FALSE(uname, lname) \ 482 - static inline bool folio_test_clear_##lname(struct folio *folio) \ 483 - { return 0; } \ 505 + FOLIO_TEST_CLEAR_FLAG_FALSE(lname) \ 484 506 static inline int TestClearPage##uname(struct page *page) { return 0; } 485 507 486 508 #define PAGEFLAG_FALSE(uname, lname) TESTPAGEFLAG_FALSE(uname, lname) \ ··· 875 855 876 856 #define PG_head_mask ((1UL << PG_head)) 877 857 878 - #ifdef CONFIG_HUGETLB_PAGE 879 - int PageHuge(const struct page *page); 880 - SETPAGEFLAG(HugeTLB, hugetlb, PF_SECOND) 881 - CLEARPAGEFLAG(HugeTLB, hugetlb, PF_SECOND) 882 - 883 - /** 884 - * folio_test_hugetlb - Determine if the folio belongs to hugetlbfs 885 - * @folio: The folio to test. 886 - * 887 - * Context: Any context. Caller should have a reference on the folio to 888 - * prevent it from being turned into a tail page. 889 - * Return: True for hugetlbfs folios, false for anon folios or folios 890 - * belonging to other filesystems. 891 - */ 892 - static inline bool folio_test_hugetlb(const struct folio *folio) 893 - { 894 - return folio_test_large(folio) && 895 - test_bit(PG_hugetlb, const_folio_flags(folio, 1)); 896 - } 897 - #else 898 - TESTPAGEFLAG_FALSE(Huge, hugetlb) 899 - #endif 900 - 901 858 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 902 859 /* 903 860 * PageHuge() only returns true for hugetlbfs pages, but not for ··· 931 934 #endif 932 935 933 936 /* 934 - * Check if a page is currently marked HWPoisoned. Note that this check is 935 - * best effort only and inherently racy: there is no way to synchronize with 936 - * failing hardware. 937 - */ 938 - static inline bool is_page_hwpoison(struct page *page) 939 - { 940 - if (PageHWPoison(page)) 941 - return true; 942 - return PageHuge(page) && PageHWPoison(compound_head(page)); 943 - } 944 - 945 - /* 946 937 * For pages that are never mapped to userspace (and aren't PageSlab), 947 938 * page_type may be used. Because it is initialised to -1, we invert the 948 939 * sense of the bit, so __SetPageFoo *clears* the bit used for PageFoo, and 949 940 * __ClearPageFoo *sets* the bit used for PageFoo. We reserve a few high and 950 - * low bits so that an underflow or overflow of page_mapcount() won't be 941 + * low bits so that an underflow or overflow of _mapcount won't be 951 942 * mistaken for a page type value. 952 943 */ 953 944 954 945 #define PAGE_TYPE_BASE 0xf0000000 955 - /* Reserve 0x0000007f to catch underflows of page_mapcount */ 946 + /* Reserve 0x0000007f to catch underflows of _mapcount */ 956 947 #define PAGE_MAPCOUNT_RESERVE -128 957 948 #define PG_buddy 0x00000080 958 949 #define PG_offline 0x00000100 959 950 #define PG_table 0x00000200 960 951 #define PG_guard 0x00000400 952 + #define PG_hugetlb 0x00000800 961 953 962 954 #define PageType(page, flag) \ 963 955 ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) ··· 963 977 return page_type_has_type(page->page_type); 964 978 } 965 979 966 - #define PAGE_TYPE_OPS(uname, lname, fname) \ 967 - static __always_inline int Page##uname(const struct page *page) \ 968 - { \ 969 - return PageType(page, PG_##lname); \ 970 - } \ 971 - static __always_inline int folio_test_##fname(const struct folio *folio)\ 980 + #define FOLIO_TYPE_OPS(lname, fname) \ 981 + static __always_inline bool folio_test_##fname(const struct folio *folio)\ 972 982 { \ 973 983 return folio_test_type(folio, PG_##lname); \ 974 - } \ 975 - static __always_inline void __SetPage##uname(struct page *page) \ 976 - { \ 977 - VM_BUG_ON_PAGE(!PageType(page, 0), page); \ 978 - page->page_type &= ~PG_##lname; \ 979 984 } \ 980 985 static __always_inline void __folio_set_##fname(struct folio *folio) \ 981 986 { \ 982 987 VM_BUG_ON_FOLIO(!folio_test_type(folio, 0), folio); \ 983 988 folio->page.page_type &= ~PG_##lname; \ 984 989 } \ 985 - static __always_inline void __ClearPage##uname(struct page *page) \ 986 - { \ 987 - VM_BUG_ON_PAGE(!Page##uname(page), page); \ 988 - page->page_type |= PG_##lname; \ 989 - } \ 990 990 static __always_inline void __folio_clear_##fname(struct folio *folio) \ 991 991 { \ 992 992 VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \ 993 993 folio->page.page_type |= PG_##lname; \ 994 + } 995 + 996 + #define PAGE_TYPE_OPS(uname, lname, fname) \ 997 + FOLIO_TYPE_OPS(lname, fname) \ 998 + static __always_inline int Page##uname(const struct page *page) \ 999 + { \ 1000 + return PageType(page, PG_##lname); \ 994 1001 } \ 1002 + static __always_inline void __SetPage##uname(struct page *page) \ 1003 + { \ 1004 + VM_BUG_ON_PAGE(!PageType(page, 0), page); \ 1005 + page->page_type &= ~PG_##lname; \ 1006 + } \ 1007 + static __always_inline void __ClearPage##uname(struct page *page) \ 1008 + { \ 1009 + VM_BUG_ON_PAGE(!Page##uname(page), page); \ 1010 + page->page_type |= PG_##lname; \ 1011 + } 995 1012 996 1013 /* 997 1014 * PageBuddy() indicates that the page is free and in the buddy system ··· 1040 1051 * Marks guardpages used with debug_pagealloc. 1041 1052 */ 1042 1053 PAGE_TYPE_OPS(Guard, guard, guard) 1054 + 1055 + #ifdef CONFIG_HUGETLB_PAGE 1056 + FOLIO_TYPE_OPS(hugetlb, hugetlb) 1057 + #else 1058 + FOLIO_TEST_FLAG_FALSE(hugetlb) 1059 + #endif 1060 + 1061 + /** 1062 + * PageHuge - Determine if the page belongs to hugetlbfs 1063 + * @page: The page to test. 1064 + * 1065 + * Context: Any context. 1066 + * Return: True for hugetlbfs pages, false for anon pages or pages 1067 + * belonging to other filesystems. 1068 + */ 1069 + static inline bool PageHuge(const struct page *page) 1070 + { 1071 + return folio_test_hugetlb(page_folio(page)); 1072 + } 1073 + 1074 + /* 1075 + * Check if a page is currently marked HWPoisoned. Note that this check is 1076 + * best effort only and inherently racy: there is no way to synchronize with 1077 + * failing hardware. 1078 + */ 1079 + static inline bool is_page_hwpoison(struct page *page) 1080 + { 1081 + if (PageHWPoison(page)) 1082 + return true; 1083 + return PageHuge(page) && PageHWPoison(compound_head(page)); 1084 + } 1043 1085 1044 1086 extern bool is_free_buddy_page(struct page *page); 1045 1087 ··· 1138 1118 */ 1139 1119 #define PAGE_FLAGS_SECOND \ 1140 1120 (0xffUL /* order */ | 1UL << PG_has_hwpoisoned | \ 1141 - 1UL << PG_hugetlb | 1UL << PG_large_rmappable) 1121 + 1UL << PG_large_rmappable) 1142 1122 1143 1123 #define PAGE_FLAGS_PRIVATE \ 1144 1124 (1UL << PG_private | 1UL << PG_private_2)
+1
include/trace/events/mmflags.h
··· 135 135 #define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) } 136 136 137 137 #define __def_pagetype_names \ 138 + DEF_PAGETYPE_NAME(hugetlb), \ 138 139 DEF_PAGETYPE_NAME(offline), \ 139 140 DEF_PAGETYPE_NAME(guard), \ 140 141 DEF_PAGETYPE_NAME(table), \
+2 -3
kernel/vmcore_info.c
··· 205 205 VMCOREINFO_NUMBER(PG_head_mask); 206 206 #define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) 207 207 VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); 208 - #ifdef CONFIG_HUGETLB_PAGE 209 - VMCOREINFO_NUMBER(PG_hugetlb); 208 + #define PAGE_HUGETLB_MAPCOUNT_VALUE (~PG_hugetlb) 209 + VMCOREINFO_NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE); 210 210 #define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) 211 211 VMCOREINFO_NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE); 212 - #endif 213 212 214 213 #ifdef CONFIG_KALLSYMS 215 214 VMCOREINFO_SYMBOL(kallsyms_names);
+2 -2
lib/stackdepot.c
··· 627 627 /* 628 628 * Zero out zone modifiers, as we don't have specific zone 629 629 * requirements. Keep the flags related to allocation in atomic 630 - * contexts and I/O. 630 + * contexts, I/O, nolockdep. 631 631 */ 632 632 alloc_flags &= ~GFP_ZONEMASK; 633 - alloc_flags &= (GFP_ATOMIC | GFP_KERNEL); 633 + alloc_flags &= (GFP_ATOMIC | GFP_KERNEL | __GFP_NOLOCKDEP); 634 634 alloc_flags |= __GFP_NOWARN; 635 635 page = alloc_pages(alloc_flags, DEPOT_POOL_ORDER); 636 636 if (page)
+15 -25
mm/hugetlb.c
··· 1624 1624 { 1625 1625 lockdep_assert_held(&hugetlb_lock); 1626 1626 1627 - folio_clear_hugetlb(folio); 1627 + __folio_clear_hugetlb(folio); 1628 1628 } 1629 1629 1630 1630 /* ··· 1711 1711 h->surplus_huge_pages_node[nid]++; 1712 1712 } 1713 1713 1714 - folio_set_hugetlb(folio); 1714 + __folio_set_hugetlb(folio); 1715 1715 folio_change_private(folio, NULL); 1716 1716 /* 1717 1717 * We have to set hugetlb_vmemmap_optimized again as above ··· 1781 1781 * If vmemmap pages were allocated above, then we need to clear the 1782 1782 * hugetlb destructor under the hugetlb lock. 1783 1783 */ 1784 - if (clear_dtor) { 1784 + if (folio_test_hugetlb(folio)) { 1785 1785 spin_lock_irq(&hugetlb_lock); 1786 1786 __clear_hugetlb_destructor(h, folio); 1787 1787 spin_unlock_irq(&hugetlb_lock); ··· 2049 2049 2050 2050 static void init_new_hugetlb_folio(struct hstate *h, struct folio *folio) 2051 2051 { 2052 - folio_set_hugetlb(folio); 2052 + __folio_set_hugetlb(folio); 2053 2053 INIT_LIST_HEAD(&folio->lru); 2054 2054 hugetlb_set_folio_subpool(folio, NULL); 2055 2055 set_hugetlb_cgroup(folio, NULL); ··· 2158 2158 { 2159 2159 return __prep_compound_gigantic_folio(folio, order, true); 2160 2160 } 2161 - 2162 - /* 2163 - * PageHuge() only returns true for hugetlbfs pages, but not for normal or 2164 - * transparent huge pages. See the PageTransHuge() documentation for more 2165 - * details. 2166 - */ 2167 - int PageHuge(const struct page *page) 2168 - { 2169 - const struct folio *folio; 2170 - 2171 - if (!PageCompound(page)) 2172 - return 0; 2173 - folio = page_folio(page); 2174 - return folio_test_hugetlb(folio); 2175 - } 2176 - EXPORT_SYMBOL_GPL(PageHuge); 2177 2161 2178 2162 /* 2179 2163 * Find and lock address space (mapping) in write mode. ··· 3252 3268 3253 3269 rsv_adjust = hugepage_subpool_put_pages(spool, 1); 3254 3270 hugetlb_acct_memory(h, -rsv_adjust); 3255 - if (deferred_reserve) 3271 + if (deferred_reserve) { 3272 + spin_lock_irq(&hugetlb_lock); 3256 3273 hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h), 3257 3274 pages_per_huge_page(h), folio); 3275 + spin_unlock_irq(&hugetlb_lock); 3276 + } 3258 3277 } 3259 3278 3260 3279 if (!memcg_charge_ret) ··· 6261 6274 VM_UFFD_MISSING); 6262 6275 } 6263 6276 6277 + if (!(vma->vm_flags & VM_MAYSHARE)) { 6278 + ret = vmf_anon_prepare(vmf); 6279 + if (unlikely(ret)) 6280 + goto out; 6281 + } 6282 + 6264 6283 folio = alloc_hugetlb_folio(vma, haddr, 0); 6265 6284 if (IS_ERR(folio)) { 6266 6285 /* ··· 6303 6310 */ 6304 6311 restore_reserve_on_error(h, vma, haddr, folio); 6305 6312 folio_put(folio); 6313 + ret = VM_FAULT_SIGBUS; 6306 6314 goto out; 6307 6315 } 6308 6316 new_pagecache_folio = true; 6309 6317 } else { 6310 6318 folio_lock(folio); 6311 - 6312 - ret = vmf_anon_prepare(vmf); 6313 - if (unlikely(ret)) 6314 - goto backout_unlocked; 6315 6319 anon_rmap = 1; 6316 6320 } 6317 6321 } else {
+16 -9
mm/zswap.c
··· 1331 1331 if (!gfp_has_io_fs(sc->gfp_mask)) 1332 1332 return 0; 1333 1333 1334 - #ifdef CONFIG_MEMCG_KMEM 1335 - mem_cgroup_flush_stats(memcg); 1336 - nr_backing = memcg_page_state(memcg, MEMCG_ZSWAP_B) >> PAGE_SHIFT; 1337 - nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED); 1338 - #else 1339 - /* use pool stats instead of memcg stats */ 1340 - nr_backing = zswap_pool_total_size >> PAGE_SHIFT; 1341 - nr_stored = atomic_read(&zswap_nr_stored); 1342 - #endif 1334 + /* 1335 + * For memcg, use the cgroup-wide ZSWAP stats since we don't 1336 + * have them per-node and thus per-lruvec. Careful if memcg is 1337 + * runtime-disabled: we can get sc->memcg == NULL, which is ok 1338 + * for the lruvec, but not for memcg_page_state(). 1339 + * 1340 + * Without memcg, use the zswap pool-wide metrics. 1341 + */ 1342 + if (!mem_cgroup_disabled()) { 1343 + mem_cgroup_flush_stats(memcg); 1344 + nr_backing = memcg_page_state(memcg, MEMCG_ZSWAP_B) >> PAGE_SHIFT; 1345 + nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED); 1346 + } else { 1347 + nr_backing = zswap_pool_total_size >> PAGE_SHIFT; 1348 + nr_stored = atomic_read(&zswap_nr_stored); 1349 + } 1343 1350 1344 1351 if (!nr_stored) 1345 1352 return 0;
+8 -4
tools/testing/selftests/kselftest_harness.h
··· 56 56 #include <asm/types.h> 57 57 #include <ctype.h> 58 58 #include <errno.h> 59 - #include <limits.h> 60 59 #include <stdbool.h> 61 60 #include <stdint.h> 62 61 #include <stdio.h> ··· 1158 1159 struct __test_metadata *t) 1159 1160 { 1160 1161 struct __test_xfail *xfail; 1161 - char test_name[LINE_MAX]; 1162 + char *test_name; 1162 1163 const char *diagnostic; 1163 1164 1164 1165 /* reset test struct */ ··· 1166 1167 t->trigger = 0; 1167 1168 memset(t->results->reason, 0, sizeof(t->results->reason)); 1168 1169 1169 - snprintf(test_name, sizeof(test_name), "%s%s%s.%s", 1170 - f->name, variant->name[0] ? "." : "", variant->name, t->name); 1170 + if (asprintf(&test_name, "%s%s%s.%s", f->name, 1171 + variant->name[0] ? "." : "", variant->name, t->name) == -1) { 1172 + ksft_print_msg("ERROR ALLOCATING MEMORY\n"); 1173 + t->exit_code = KSFT_FAIL; 1174 + _exit(t->exit_code); 1175 + } 1171 1176 1172 1177 ksft_print_msg(" RUN %s ...\n", test_name); 1173 1178 ··· 1209 1206 1210 1207 ksft_test_result_code(t->exit_code, test_name, 1211 1208 diagnostic ? "%s" : NULL, diagnostic); 1209 + free(test_name); 1212 1210 } 1213 1211 1214 1212 static int test_harness_run(int argc, char **argv)
+1
tools/testing/selftests/mm/mdwe_test.c
··· 7 7 #include <linux/mman.h> 8 8 #include <linux/prctl.h> 9 9 10 + #define _GNU_SOURCE 10 11 #include <stdio.h> 11 12 #include <stdlib.h> 12 13 #include <sys/auxv.h>
-38
tools/testing/selftests/mm/protection_keys.c
··· 54 54 u64 shadow_pkey_reg; 55 55 int dprint_in_signal; 56 56 char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; 57 - char buf[256]; 58 57 59 58 void cat_into_file(char *str, char *file) 60 59 { ··· 1744 1745 shadow_pkey_reg = __read_pkey_reg(); 1745 1746 } 1746 1747 1747 - pid_t parent_pid; 1748 - 1749 - void restore_settings_atexit(void) 1750 - { 1751 - if (parent_pid == getpid()) 1752 - cat_into_file(buf, "/proc/sys/vm/nr_hugepages"); 1753 - } 1754 - 1755 - void save_settings(void) 1756 - { 1757 - int fd; 1758 - int err; 1759 - 1760 - if (geteuid()) 1761 - return; 1762 - 1763 - fd = open("/proc/sys/vm/nr_hugepages", O_RDONLY); 1764 - if (fd < 0) { 1765 - fprintf(stderr, "error opening\n"); 1766 - perror("error: "); 1767 - exit(__LINE__); 1768 - } 1769 - 1770 - /* -1 to guarantee leaving the trailing \0 */ 1771 - err = read(fd, buf, sizeof(buf)-1); 1772 - if (err < 0) { 1773 - fprintf(stderr, "error reading\n"); 1774 - perror("error: "); 1775 - exit(__LINE__); 1776 - } 1777 - 1778 - parent_pid = getpid(); 1779 - atexit(restore_settings_atexit); 1780 - close(fd); 1781 - } 1782 - 1783 1748 int main(void) 1784 1749 { 1785 1750 int nr_iterations = 22; ··· 1751 1788 1752 1789 srand((unsigned int)time(NULL)); 1753 1790 1754 - save_settings(); 1755 1791 setup_handlers(); 1756 1792 1757 1793 printf("has pkeys: %d\n", pkeys_supported);
+2
tools/testing/selftests/mm/run_vmtests.sh
··· 385 385 CATEGORY="ksm" run_test ./ksm_functional_tests 386 386 387 387 # protection_keys tests 388 + nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages) 388 389 if [ -x ./protection_keys_32 ] 389 390 then 390 391 CATEGORY="pkey" run_test ./protection_keys_32 ··· 395 394 then 396 395 CATEGORY="pkey" run_test ./protection_keys_64 397 396 fi 397 + echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages 398 398 399 399 if [ -x ./soft-dirty ] 400 400 then
+1 -1
tools/testing/selftests/mm/split_huge_page_test.c
··· 300 300 char **addr) 301 301 { 302 302 size_t i; 303 - int dummy; 303 + int __attribute__((unused)) dummy = 0; 304 304 305 305 srand(time(NULL)); 306 306