]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm/swap: Optimise lru_add_drain_cpu()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 15 Jun 2022 18:48:47 +0000 (14:48 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 17 Jun 2022 14:35:21 +0000 (10:35 -0400)
Do the per-cpu dereferencing of the fbatches once which saves 14 bytes
of text and several percpu relocations.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/swap.c

index 1bebd4bf19787328998268e81b08a6bf79be9972..d7faa9812b6915b94467cfabf782280db61a5ea6 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -620,7 +620,8 @@ static void lru_lazyfree_fn(struct lruvec *lruvec, struct folio *folio)
  */
 void lru_add_drain_cpu(int cpu)
 {
-       struct folio_batch *fbatch = &per_cpu(cpu_fbatches.lru_add, cpu);
+       struct cpu_fbatches *fbatches = &per_cpu(cpu_fbatches, cpu);
+       struct folio_batch *fbatch = &fbatches->lru_add;
 
        if (folio_batch_count(fbatch))
                folio_batch_move_lru(fbatch, lru_add_fn);
@@ -636,15 +637,15 @@ void lru_add_drain_cpu(int cpu)
                local_unlock_irqrestore(&lru_rotate.lock, flags);
        }
 
-       fbatch = &per_cpu(cpu_fbatches.lru_deactivate_file, cpu);
+       fbatch = &fbatches->lru_deactivate_file;
        if (folio_batch_count(fbatch))
                folio_batch_move_lru(fbatch, lru_deactivate_file_fn);
 
-       fbatch = &per_cpu(cpu_fbatches.lru_deactivate, cpu);
+       fbatch = &fbatches->lru_deactivate;
        if (folio_batch_count(fbatch))
                folio_batch_move_lru(fbatch, lru_deactivate_fn);
 
-       fbatch = &per_cpu(cpu_fbatches.lru_lazyfree, cpu);
+       fbatch = &fbatches->lru_lazyfree;
        if (folio_batch_count(fbatch))
                folio_batch_move_lru(fbatch, lru_lazyfree_fn);