mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 19:47:08 +02:00
mm: khugepaged: avoid pointless allocation for "struct mm_slot"
In __khugepaged_enter(), if "mm->flags" with MMF_VM_HUGEPAGE bit is set, the "mm_slot" will be released and return, so we can call mm_slot_alloc() after test_and_set_bit(). Link: https://lkml.kernel.org/r/20230531095817.11012-1-xhao@linux.alibaba.com Signed-off-by: Xin Hao <xhao@linux.alibaba.com> Reviewed-by: Andrew Morton <akpm@linux-foudation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
3b11edf1f2
commit
1661867027
|
|
@ -422,19 +422,17 @@ void __khugepaged_enter(struct mm_struct *mm)
|
||||||
struct mm_slot *slot;
|
struct mm_slot *slot;
|
||||||
int wakeup;
|
int wakeup;
|
||||||
|
|
||||||
|
/* __khugepaged_exit() must not run from under us */
|
||||||
|
VM_BUG_ON_MM(hpage_collapse_test_exit(mm), mm);
|
||||||
|
if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags)))
|
||||||
|
return;
|
||||||
|
|
||||||
mm_slot = mm_slot_alloc(mm_slot_cache);
|
mm_slot = mm_slot_alloc(mm_slot_cache);
|
||||||
if (!mm_slot)
|
if (!mm_slot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
slot = &mm_slot->slot;
|
slot = &mm_slot->slot;
|
||||||
|
|
||||||
/* __khugepaged_exit() must not run from under us */
|
|
||||||
VM_BUG_ON_MM(hpage_collapse_test_exit(mm), mm);
|
|
||||||
if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) {
|
|
||||||
mm_slot_free(mm_slot_cache, mm_slot);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock(&khugepaged_mm_lock);
|
spin_lock(&khugepaged_mm_lock);
|
||||||
mm_slot_insert(mm_slots_hash, mm, slot);
|
mm_slot_insert(mm_slots_hash, mm, slot);
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user