mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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>
This commit is contained in:
committed by
Andrew Morton
parent
bf263bcaf6
commit
5a62019807
@@ -2828,6 +2828,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
|
||||
unsigned long hstart, hend, addr;
|
||||
enum scan_result last_fail = SCAN_FAIL;
|
||||
int thps = 0;
|
||||
bool mmap_unlocked = false;
|
||||
|
||||
BUG_ON(vma->vm_start > start);
|
||||
BUG_ON(vma->vm_end < end);
|
||||
@@ -2850,10 +2851,11 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
|
||||
for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) {
|
||||
enum scan_result result = SCAN_FAIL;
|
||||
|
||||
if (*lock_dropped) {
|
||||
if (mmap_unlocked) {
|
||||
cond_resched();
|
||||
mmap_read_lock(mm);
|
||||
*lock_dropped = false;
|
||||
mmap_unlocked = false;
|
||||
*lock_dropped = true;
|
||||
result = hugepage_vma_revalidate(mm, addr, false, &vma,
|
||||
cc);
|
||||
if (result != SCAN_SUCCEED) {
|
||||
@@ -2864,7 +2866,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
|
||||
hend = min(hend, vma->vm_end & HPAGE_PMD_MASK);
|
||||
}
|
||||
|
||||
result = collapse_single_pmd(addr, vma, lock_dropped, cc);
|
||||
result = collapse_single_pmd(addr, vma, &mmap_unlocked, cc);
|
||||
|
||||
switch (result) {
|
||||
case SCAN_SUCCEED:
|
||||
@@ -2893,8 +2895,10 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
|
||||
|
||||
out_maybelock:
|
||||
/* Caller expects us to hold mmap_lock on return */
|
||||
if (*lock_dropped)
|
||||
if (mmap_unlocked) {
|
||||
*lock_dropped = true;
|
||||
mmap_read_lock(mm);
|
||||
}
|
||||
out_nolock:
|
||||
mmap_assert_locked(mm);
|
||||
mmdrop(mm);
|
||||
|
||||
Reference in New Issue
Block a user