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.

mm/khugepaged: fix issue with tracking lock

We are incorrectly treating lock_dropped to track both whether the lock is
currently held and whether or not the lock was ever dropped.

Update this change to account for this.

Link: https://lkml.kernel.org/r/7760c811-e100-4d40-9217-0813c28314be@lucifer.local
Fixes: 330f3758a3bc ("mm/khugepaged: unify khugepaged and madv_collapse with collapse_single_pmd()")
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Nico Pache <npache@redhat.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Rafael Aquini <raquini@redhat.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shivank Garg <shivankg@amd.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Takashi Iwai (SUSE) <tiwai@suse.de>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yang Shi <yang@os.amperecomputing.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
5a620198 bf263bca

+8 -4
+8 -4
mm/khugepaged.c
··· 2828 2828 unsigned long hstart, hend, addr; 2829 2829 enum scan_result last_fail = SCAN_FAIL; 2830 2830 int thps = 0; 2831 + bool mmap_unlocked = false; 2831 2832 2832 2833 BUG_ON(vma->vm_start > start); 2833 2834 BUG_ON(vma->vm_end < end); ··· 2851 2850 for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) { 2852 2851 enum scan_result result = SCAN_FAIL; 2853 2852 2854 - if (*lock_dropped) { 2853 + if (mmap_unlocked) { 2855 2854 cond_resched(); 2856 2855 mmap_read_lock(mm); 2857 - *lock_dropped = false; 2856 + mmap_unlocked = false; 2857 + *lock_dropped = true; 2858 2858 result = hugepage_vma_revalidate(mm, addr, false, &vma, 2859 2859 cc); 2860 2860 if (result != SCAN_SUCCEED) { ··· 2866 2864 hend = min(hend, vma->vm_end & HPAGE_PMD_MASK); 2867 2865 } 2868 2866 2869 - result = collapse_single_pmd(addr, vma, lock_dropped, cc); 2867 + result = collapse_single_pmd(addr, vma, &mmap_unlocked, cc); 2870 2868 2871 2869 switch (result) { 2872 2870 case SCAN_SUCCEED: ··· 2895 2893 2896 2894 out_maybelock: 2897 2895 /* Caller expects us to hold mmap_lock on return */ 2898 - if (*lock_dropped) 2896 + if (mmap_unlocked) { 2897 + *lock_dropped = true; 2899 2898 mmap_read_lock(mm); 2899 + } 2900 2900 out_nolock: 2901 2901 mmap_assert_locked(mm); 2902 2902 mmdrop(mm);