mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 22:42:04 +00:00
mm/swap: take folio refcount after testing the LRU flag
Whoever passes a folio to __folio_batch_add_and_move() must hold a reference, otherwise something else would already be messed up. If the folio is referenced, it will not be freed elsewhere, so we can safely clear the folio's lru flag. As discussed with David in [1], we should take the reference after testing the LRU flag, not before. Link: https://lore.kernel.org/lkml/d41865b4-d6fa-49ba-890a-921eefad27dd@redhat.com/ [1] Link: https://lkml.kernel.org/r/1723542743-32179-1-git-send-email-yangge1116@126.com Signed-off-by: yangge <yangge1116@126.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Yu Zhao <yuzhao@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
b6273b55d8
commit
67b9a353e1
@ -226,12 +226,10 @@ static void __folio_batch_add_and_move(struct folio_batch __percpu *fbatch,
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
folio_get(folio);
|
||||
|
||||
if (on_lru && !folio_test_clear_lru(folio)) {
|
||||
folio_put(folio);
|
||||
if (on_lru && !folio_test_clear_lru(folio))
|
||||
return;
|
||||
}
|
||||
|
||||
folio_get(folio);
|
||||
|
||||
if (disable_irq)
|
||||
local_lock_irqsave(&cpu_fbatches.lock_irq, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user