summaryrefslogtreecommitdiffstats
path: root/mm/swap.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2022-06-17 18:50:09 +0100
committerakpm <akpm@linux-foundation.org>2022-07-03 18:08:46 -0700
commita2d33b5dd674c21e75ca47e3d791d070cba267dd (patch)
treefd6625c5b6a660c28577ef0528903410b6c8bfbb /mm/swap.c
parent4864545a4669781f75aa711ebf7b25e6f0f37d13 (diff)
downloadlinux-a2d33b5dd674c21e75ca47e3d791d070cba267dd.tar.gz
linux-a2d33b5dd674c21e75ca47e3d791d070cba267dd.tar.bz2
linux-a2d33b5dd674c21e75ca47e3d791d070cba267dd.zip
mm/swap: optimise lru_add_drain_cpu()
Do the per-cpu dereferencing of the fbatches once which saves 14 bytes of text and several percpu relocations. Link: https://lkml.kernel.org/r/20220617175020.717127-12-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/swap.c')
-rw-r--r--mm/swap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mm/swap.c b/mm/swap.c
index df78c4c4dbeb..84318692db6a 100644
--- 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);