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 branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
"18 patches.

Subsystems affected by this patch series: mm (hugetlb, compaction,
vmalloc, shmem, memblock, pagecache, kasan, and hugetlb), mailmap,
gcov, ubsan, and MAINTAINERS"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
MAINTAINERS/.mailmap: use my @kernel.org address
mm: hugetlb: fix missing put_page in gather_surplus_pages()
ubsan: implement __ubsan_handle_alignment_assumption
kasan: make addr_has_metadata() return true for valid addresses
kasan: add explicit preconditions to kasan_report()
mm/filemap: add missing mem_cgroup_uncharge() to __add_to_page_cache_locked()
mailmap: add entries for Manivannan Sadhasivam
mailmap: fix name/email for Viresh Kumar
memblock: do not start bottom-up allocations with kernel_end
mm: thp: fix MADV_REMOVE deadlock on shmem THP
init/gcov: allow CONFIG_CONSTRUCTORS on UML to fix module gcov
mm/vmalloc: separate put pages and flush VM flags
mm, compaction: move high_pfn to the for loop scope
mm: migrate: do not migrate HugeTLB page whose refcount is one
mm: hugetlb: remove VM_BUG_ON_PAGE from page_huge_active
mm: hugetlb: fix a race between isolating and freeing page
mm: hugetlb: fix a race between freeing and dissolving the page
mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page

+153 -77
+5
.mailmap
··· 199 199 Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org> 200 200 Lukasz Luba <lukasz.luba@arm.com> <l.luba@partner.samsung.com> 201 201 Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com> 202 + Manivannan Sadhasivam <mani@kernel.org> <manivannanece23@gmail.com> 203 + Manivannan Sadhasivam <mani@kernel.org> <manivannan.sadhasivam@linaro.org> 202 204 Marcin Nowakowski <marcin.nowakowski@mips.com> <marcin.nowakowski@imgtec.com> 203 205 Marc Zyngier <maz@kernel.org> <marc.zyngier@arm.com> 204 206 Mark Brown <broonie@sirena.org.uk> ··· 246 244 Morten Welinder <welinder@darter.rentec.com> 247 245 Morten Welinder <welinder@troll.com> 248 246 Mythri P K <mythripk@ti.com> 247 + Nathan Chancellor <nathan@kernel.org> <natechancellor@gmail.com> 249 248 Nguyen Anh Quynh <aquynh@gmail.com> 250 249 Nicolas Ferre <nicolas.ferre@microchip.com> <nicolas.ferre@atmel.com> 251 250 Nicolas Pitre <nico@fluxnic.net> <nicolas.pitre@linaro.org> ··· 337 334 Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com> 338 335 Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com> 339 336 Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com> 337 + Viresh Kumar <viresh.kumar@linaro.org> <viresh.kumar@linaro.org> 338 + Viresh Kumar <viresh.kumar@linaro.org> <viresh.kumar@linaro.com> 340 339 Vivien Didelot <vivien.didelot@gmail.com> <vivien.didelot@savoirfairelinux.com> 341 340 Vlad Dogaru <ddvlad@gmail.com> <vlad.dogaru@intel.com> 342 341 Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
+1 -1
MAINTAINERS
··· 4304 4304 F: .clang-format 4305 4305 4306 4306 CLANG/LLVM BUILD SUPPORT 4307 - M: Nathan Chancellor <natechancellor@gmail.com> 4307 + M: Nathan Chancellor <nathan@kernel.org> 4308 4308 M: Nick Desaulniers <ndesaulniers@google.com> 4309 4309 L: clang-built-linux@googlegroups.com 4310 4310 S: Supported
+2 -1
fs/hugetlbfs/inode.c
··· 735 735 736 736 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 737 737 738 + set_page_huge_active(page); 738 739 /* 739 740 * unlock_page because locked by add_to_page_cache() 740 - * page_put due to reference from alloc_huge_page() 741 + * put_page() due to reference from alloc_huge_page() 741 742 */ 742 743 unlock_page(page); 743 744 put_page(page);
+2
include/linux/hugetlb.h
··· 770 770 } 771 771 #endif 772 772 773 + void set_page_huge_active(struct page *page); 774 + 773 775 #else /* CONFIG_HUGETLB_PAGE */ 774 776 struct hstate {}; 775 777
+7
include/linux/kasan.h
··· 333 333 return (void *)arch_kasan_reset_tag(addr); 334 334 } 335 335 336 + /** 337 + * kasan_report - print a report about a bad memory access detected by KASAN 338 + * @addr: address of the bad access 339 + * @size: size of the bad access 340 + * @is_write: whether the bad access is a write or a read 341 + * @ip: instruction pointer for the accessibility check or the bad access itself 342 + */ 336 343 bool kasan_report(unsigned long addr, size_t size, 337 344 bool is_write, unsigned long ip); 338 345
+2 -7
include/linux/vmalloc.h
··· 24 24 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */ 25 25 #define VM_NO_GUARD 0x00000040 /* don't add guard page */ 26 26 #define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */ 27 - #define VM_MAP_PUT_PAGES 0x00000100 /* put pages and free array in vfree */ 27 + #define VM_FLUSH_RESET_PERMS 0x00000100 /* reset direct map and flush TLB on unmap, can't be freed in atomic context */ 28 + #define VM_MAP_PUT_PAGES 0x00000200 /* put pages and free array in vfree */ 28 29 29 30 /* 30 31 * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC. ··· 37 36 * Otherwise, VM_KASAN is set for kasan_module_alloc() allocations and used to 38 37 * determine which allocations need the module shadow freed. 39 38 */ 40 - 41 - /* 42 - * Memory with VM_FLUSH_RESET_PERMS cannot be freed in an interrupt or with 43 - * vfree_atomic(). 44 - */ 45 - #define VM_FLUSH_RESET_PERMS 0x00000100 /* Reset direct map and flush TLB on unmap */ 46 39 47 40 /* bits [20..32] reserved for arch specific ioremap internals */ 48 41
-1
init/Kconfig
··· 76 76 77 77 config CONSTRUCTORS 78 78 bool 79 - depends on !UML 80 79 81 80 config IRQ_WORK 82 81 bool
+7 -1
init/main.c
··· 1066 1066 /* Call all constructor functions linked into the kernel. */ 1067 1067 static void __init do_ctors(void) 1068 1068 { 1069 - #ifdef CONFIG_CONSTRUCTORS 1069 + /* 1070 + * For UML, the constructors have already been called by the 1071 + * normal setup code as it's just a normal ELF binary, so we 1072 + * cannot do it again - but we do need CONFIG_CONSTRUCTORS 1073 + * even on UML for modules. 1074 + */ 1075 + #if defined(CONFIG_CONSTRUCTORS) && !defined(CONFIG_UML) 1070 1076 ctor_fn_t *fn = (ctor_fn_t *) __ctors_start; 1071 1077 1072 1078 for (; fn < (ctor_fn_t *) __ctors_end; fn++)
+1 -1
kernel/gcov/Kconfig
··· 4 4 config GCOV_KERNEL 5 5 bool "Enable gcov-based kernel profiling" 6 6 depends on DEBUG_FS 7 - select CONSTRUCTORS if !UML 7 + select CONSTRUCTORS 8 8 default n 9 9 help 10 10 This option enables gcov-based code profiling (e.g. for code coverage
+31
lib/ubsan.c
··· 427 427 ubsan_epilogue(); 428 428 } 429 429 EXPORT_SYMBOL(__ubsan_handle_load_invalid_value); 430 + 431 + void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr, 432 + unsigned long align, 433 + unsigned long offset); 434 + void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr, 435 + unsigned long align, 436 + unsigned long offset) 437 + { 438 + struct alignment_assumption_data *data = _data; 439 + unsigned long real_ptr; 440 + 441 + if (suppress_report(&data->location)) 442 + return; 443 + 444 + ubsan_prologue(&data->location, "alignment-assumption"); 445 + 446 + if (offset) 447 + pr_err("assumption of %lu byte alignment (with offset of %lu byte) for pointer of type %s failed", 448 + align, offset, data->type->type_name); 449 + else 450 + pr_err("assumption of %lu byte alignment for pointer of type %s failed", 451 + align, data->type->type_name); 452 + 453 + real_ptr = ptr - offset; 454 + pr_err("%saddress is %lu aligned, misalignment offset is %lu bytes", 455 + offset ? "offset " : "", BIT(real_ptr ? __ffs(real_ptr) : 0), 456 + real_ptr & (align - 1)); 457 + 458 + ubsan_epilogue(); 459 + } 460 + EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
+6
lib/ubsan.h
··· 78 78 struct type_descriptor *type; 79 79 }; 80 80 81 + struct alignment_assumption_data { 82 + struct source_location location; 83 + struct source_location assumption_location; 84 + struct type_descriptor *type; 85 + }; 86 + 81 87 #if defined(CONFIG_ARCH_SUPPORTS_INT128) 82 88 typedef __int128 s_max; 83 89 typedef unsigned __int128 u_max;
+2 -1
mm/compaction.c
··· 1342 1342 { 1343 1343 unsigned int limit = min(1U, freelist_scan_limit(cc) >> 1); 1344 1344 unsigned int nr_scanned = 0; 1345 - unsigned long low_pfn, min_pfn, high_pfn = 0, highest = 0; 1345 + unsigned long low_pfn, min_pfn, highest = 0; 1346 1346 unsigned long nr_isolated = 0; 1347 1347 unsigned long distance; 1348 1348 struct page *page = NULL; ··· 1387 1387 struct page *freepage; 1388 1388 unsigned long flags; 1389 1389 unsigned int order_scanned = 0; 1390 + unsigned long high_pfn = 0; 1390 1391 1391 1392 if (!area->nr_free) 1392 1393 continue;
+4
mm/filemap.c
··· 835 835 XA_STATE(xas, &mapping->i_pages, offset); 836 836 int huge = PageHuge(page); 837 837 int error; 838 + bool charged = false; 838 839 839 840 VM_BUG_ON_PAGE(!PageLocked(page), page); 840 841 VM_BUG_ON_PAGE(PageSwapBacked(page), page); ··· 849 848 error = mem_cgroup_charge(page, current->mm, gfp); 850 849 if (error) 851 850 goto error; 851 + charged = true; 852 852 } 853 853 854 854 gfp &= GFP_RECLAIM_MASK; ··· 898 896 899 897 if (xas_error(&xas)) { 900 898 error = xas_error(&xas); 899 + if (charged) 900 + mem_cgroup_uncharge(page); 901 901 goto error; 902 902 } 903 903
+23 -14
mm/huge_memory.c
··· 2202 2202 { 2203 2203 spinlock_t *ptl; 2204 2204 struct mmu_notifier_range range; 2205 - bool was_locked = false; 2205 + bool do_unlock_page = false; 2206 2206 pmd_t _pmd; 2207 2207 2208 2208 mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm, ··· 2218 2218 VM_BUG_ON(freeze && !page); 2219 2219 if (page) { 2220 2220 VM_WARN_ON_ONCE(!PageLocked(page)); 2221 - was_locked = true; 2222 2221 if (page != pmd_page(*pmd)) 2223 2222 goto out; 2224 2223 } ··· 2226 2227 if (pmd_trans_huge(*pmd)) { 2227 2228 if (!page) { 2228 2229 page = pmd_page(*pmd); 2229 - if (unlikely(!trylock_page(page))) { 2230 - get_page(page); 2231 - _pmd = *pmd; 2232 - spin_unlock(ptl); 2233 - lock_page(page); 2234 - spin_lock(ptl); 2235 - if (unlikely(!pmd_same(*pmd, _pmd))) { 2236 - unlock_page(page); 2230 + /* 2231 + * An anonymous page must be locked, to ensure that a 2232 + * concurrent reuse_swap_page() sees stable mapcount; 2233 + * but reuse_swap_page() is not used on shmem or file, 2234 + * and page lock must not be taken when zap_pmd_range() 2235 + * calls __split_huge_pmd() while i_mmap_lock is held. 2236 + */ 2237 + if (PageAnon(page)) { 2238 + if (unlikely(!trylock_page(page))) { 2239 + get_page(page); 2240 + _pmd = *pmd; 2241 + spin_unlock(ptl); 2242 + lock_page(page); 2243 + spin_lock(ptl); 2244 + if (unlikely(!pmd_same(*pmd, _pmd))) { 2245 + unlock_page(page); 2246 + put_page(page); 2247 + page = NULL; 2248 + goto repeat; 2249 + } 2237 2250 put_page(page); 2238 - page = NULL; 2239 - goto repeat; 2240 2251 } 2241 - put_page(page); 2252 + do_unlock_page = true; 2242 2253 } 2243 2254 } 2244 2255 if (PageMlocked(page)) ··· 2258 2249 __split_huge_pmd_locked(vma, pmd, range.start, freeze); 2259 2250 out: 2260 2251 spin_unlock(ptl); 2261 - if (!was_locked && page) 2252 + if (do_unlock_page) 2262 2253 unlock_page(page); 2263 2254 /* 2264 2255 * No need to double call mmu_notifier->invalidate_range() callback.
+47 -6
mm/hugetlb.c
··· 79 79 static int num_fault_mutexes; 80 80 struct mutex *hugetlb_fault_mutex_table ____cacheline_aligned_in_smp; 81 81 82 + static inline bool PageHugeFreed(struct page *head) 83 + { 84 + return page_private(head + 4) == -1UL; 85 + } 86 + 87 + static inline void SetPageHugeFreed(struct page *head) 88 + { 89 + set_page_private(head + 4, -1UL); 90 + } 91 + 92 + static inline void ClearPageHugeFreed(struct page *head) 93 + { 94 + set_page_private(head + 4, 0); 95 + } 96 + 82 97 /* Forward declaration */ 83 98 static int hugetlb_acct_memory(struct hstate *h, long delta); 84 99 ··· 1043 1028 list_move(&page->lru, &h->hugepage_freelists[nid]); 1044 1029 h->free_huge_pages++; 1045 1030 h->free_huge_pages_node[nid]++; 1031 + SetPageHugeFreed(page); 1046 1032 } 1047 1033 1048 1034 static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) ··· 1060 1044 1061 1045 list_move(&page->lru, &h->hugepage_activelist); 1062 1046 set_page_refcounted(page); 1047 + ClearPageHugeFreed(page); 1063 1048 h->free_huge_pages--; 1064 1049 h->free_huge_pages_node[nid]--; 1065 1050 return page; ··· 1361 1344 */ 1362 1345 bool page_huge_active(struct page *page) 1363 1346 { 1364 - VM_BUG_ON_PAGE(!PageHuge(page), page); 1365 - return PageHead(page) && PagePrivate(&page[1]); 1347 + return PageHeadHuge(page) && PagePrivate(&page[1]); 1366 1348 } 1367 1349 1368 1350 /* never called for tail page */ 1369 - static void set_page_huge_active(struct page *page) 1351 + void set_page_huge_active(struct page *page) 1370 1352 { 1371 1353 VM_BUG_ON_PAGE(!PageHeadHuge(page), page); 1372 1354 SetPagePrivate(&page[1]); ··· 1521 1505 spin_lock(&hugetlb_lock); 1522 1506 h->nr_huge_pages++; 1523 1507 h->nr_huge_pages_node[nid]++; 1508 + ClearPageHugeFreed(page); 1524 1509 spin_unlock(&hugetlb_lock); 1525 1510 } 1526 1511 ··· 1772 1755 { 1773 1756 int rc = -EBUSY; 1774 1757 1758 + retry: 1775 1759 /* Not to disrupt normal path by vainly holding hugetlb_lock */ 1776 1760 if (!PageHuge(page)) 1777 1761 return 0; ··· 1789 1771 int nid = page_to_nid(head); 1790 1772 if (h->free_huge_pages - h->resv_huge_pages == 0) 1791 1773 goto out; 1774 + 1775 + /* 1776 + * We should make sure that the page is already on the free list 1777 + * when it is dissolved. 1778 + */ 1779 + if (unlikely(!PageHugeFreed(head))) { 1780 + spin_unlock(&hugetlb_lock); 1781 + cond_resched(); 1782 + 1783 + /* 1784 + * Theoretically, we should return -EBUSY when we 1785 + * encounter this race. In fact, we have a chance 1786 + * to successfully dissolve the page if we do a 1787 + * retry. Because the race window is quite small. 1788 + * If we seize this opportunity, it is an optimization 1789 + * for increasing the success rate of dissolving page. 1790 + */ 1791 + goto retry; 1792 + } 1793 + 1792 1794 /* 1793 1795 * Move PageHWPoison flag from head page to the raw error page, 1794 1796 * which makes any subpages rather than the error page reusable. ··· 2047 2009 2048 2010 /* Free the needed pages to the hugetlb pool */ 2049 2011 list_for_each_entry_safe(page, tmp, &surplus_list, lru) { 2012 + int zeroed; 2013 + 2050 2014 if ((--needed) < 0) 2051 2015 break; 2052 2016 /* 2053 2017 * This page is now managed by the hugetlb allocator and has 2054 2018 * no users -- drop the buddy allocator's reference. 2055 2019 */ 2056 - VM_BUG_ON_PAGE(!put_page_testzero(page), page); 2020 + zeroed = put_page_testzero(page); 2021 + VM_BUG_ON_PAGE(!zeroed, page); 2057 2022 enqueue_huge_page(h, page); 2058 2023 } 2059 2024 free: ··· 5596 5555 { 5597 5556 bool ret = true; 5598 5557 5599 - VM_BUG_ON_PAGE(!PageHead(page), page); 5600 5558 spin_lock(&hugetlb_lock); 5601 - if (!page_huge_active(page) || !get_page_unless_zero(page)) { 5559 + if (!PageHeadHuge(page) || !page_huge_active(page) || 5560 + !get_page_unless_zero(page)) { 5602 5561 ret = false; 5603 5562 goto unlock; 5604 5563 }
+1 -1
mm/kasan/kasan.h
··· 209 209 210 210 static inline bool addr_has_metadata(const void *addr) 211 211 { 212 - return true; 212 + return (is_vmalloc_addr(addr) || virt_addr_valid(addr)); 213 213 } 214 214 215 215 #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
+6 -43
mm/memblock.c
··· 275 275 * 276 276 * Find @size free area aligned to @align in the specified range and node. 277 277 * 278 - * When allocation direction is bottom-up, the @start should be greater 279 - * than the end of the kernel image. Otherwise, it will be trimmed. The 280 - * reason is that we want the bottom-up allocation just near the kernel 281 - * image so it is highly likely that the allocated memory and the kernel 282 - * will reside in the same node. 283 - * 284 - * If bottom-up allocation failed, will try to allocate memory top-down. 285 - * 286 278 * Return: 287 279 * Found address on success, 0 on failure. 288 280 */ ··· 283 291 phys_addr_t end, int nid, 284 292 enum memblock_flags flags) 285 293 { 286 - phys_addr_t kernel_end, ret; 287 - 288 294 /* pump up @end */ 289 295 if (end == MEMBLOCK_ALLOC_ACCESSIBLE || 290 296 end == MEMBLOCK_ALLOC_KASAN) ··· 291 301 /* avoid allocating the first page */ 292 302 start = max_t(phys_addr_t, start, PAGE_SIZE); 293 303 end = max(start, end); 294 - kernel_end = __pa_symbol(_end); 295 304 296 - /* 297 - * try bottom-up allocation only when bottom-up mode 298 - * is set and @end is above the kernel image. 299 - */ 300 - if (memblock_bottom_up() && end > kernel_end) { 301 - phys_addr_t bottom_up_start; 302 - 303 - /* make sure we will allocate above the kernel */ 304 - bottom_up_start = max(start, kernel_end); 305 - 306 - /* ok, try bottom-up allocation first */ 307 - ret = __memblock_find_range_bottom_up(bottom_up_start, end, 308 - size, align, nid, flags); 309 - if (ret) 310 - return ret; 311 - 312 - /* 313 - * we always limit bottom-up allocation above the kernel, 314 - * but top-down allocation doesn't have the limit, so 315 - * retrying top-down allocation may succeed when bottom-up 316 - * allocation failed. 317 - * 318 - * bottom-up allocation is expected to be fail very rarely, 319 - * so we use WARN_ONCE() here to see the stack trace if 320 - * fail happens. 321 - */ 322 - WARN_ONCE(IS_ENABLED(CONFIG_MEMORY_HOTREMOVE), 323 - "memblock: bottom-up allocation failed, memory hotremove may be affected\n"); 324 - } 325 - 326 - return __memblock_find_range_top_down(start, end, size, align, nid, 327 - flags); 305 + if (memblock_bottom_up()) 306 + return __memblock_find_range_bottom_up(start, end, size, align, 307 + nid, flags); 308 + else 309 + return __memblock_find_range_top_down(start, end, size, align, 310 + nid, flags); 328 311 } 329 312 330 313 /**
+6
mm/migrate.c
··· 1280 1280 return -ENOSYS; 1281 1281 } 1282 1282 1283 + if (page_count(hpage) == 1) { 1284 + /* page was freed from under us. So we are done. */ 1285 + putback_active_hugepage(hpage); 1286 + return MIGRATEPAGE_SUCCESS; 1287 + } 1288 + 1283 1289 new_hpage = get_new_page(hpage, private); 1284 1290 if (!new_hpage) 1285 1291 return -ENOMEM;