[PATCH 01/25] mm/fbatch: remove !CONFIG_SMP special case of folio_activate()
Hugh Dickins <[email protected]>
| Newsgroups | org.kvack.linux-mm,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
3.0 commit eb709b0d062e ("mm: batch activate_page() to reduce lock
contention") brought in an ifdef CONFIG_SMP around activate batching:
https://lore.kernel.org/linux-mm/[email protected]/
shows a sensitivity to bloat that day, not any incompatibility with UP.
No other batching here has a UP alternative, and it's a bit confusing:
simplify mm/folio.c a little by removing it now.
Certainly we can reduce UP bloat (and/or 32-bit bloat) by, say, lowering
FOLIO_BATCH_SIZE from 31: traditionally 16, 14, 15, then raised to 31 by
6.9 commit 9cecde80aae0 ("mm: increase folio batch size"); or by giving
just the static per-cpu folio batches a type of their own with a smaller
array size on UP (1? or a little batching worthwhile even on UP?). But
not right now, it's orthogonal to this series.
And I suspect that the old ifdef led to lru_activate being placed last,
whereas it's usually the second most popular fbatch: move it there, to
match cpu_needs_drain() comment "Check these in order of likelihood that
they're not zero".
Signed-off-by: Hugh Dickins <[email protected]>
---
mm/folio.c | 40 ++++++----------------------------------
1 file changed, 6 insertions(+), 34 deletions(-)
diff --git a/mm/folio.c b/mm/folio.c
index d2937600cf72..62b96c9ce19e 100644
--- a/mm/folio.c
+++ b/mm/folio.c
@@ -47,12 +47,10 @@ struct cpu_fbatches {
*/
local_lock_t lock;
struct folio_batch lru_add;
+ struct folio_batch lru_activate;
struct folio_batch lru_deactivate_file;
struct folio_batch lru_deactivate;
struct folio_batch lru_lazyfree;
-#ifdef CONFIG_SMP
- struct folio_batch lru_activate;
-#endif
/* Protecting the following batches which require disabling interrupts */
local_lock_t lock_irq;
struct folio_batch lru_move_tail;
@@ -349,15 +347,6 @@ static void lru_activate(struct lruvec *lruvec, struct folio *folio)
count_memcg_events(lruvec_memcg(lruvec), PGACTIVATE, nr_pages);
}
-#ifdef CONFIG_SMP
-static void folio_activate_drain(int cpu)
-{
- struct folio_batch *fbatch = &per_cpu(cpu_fbatches.lru_activate, cpu);
-
- if (folio_batch_count(fbatch))
- folio_batch_move_lru(fbatch, lru_activate);
-}
-
void folio_activate(struct folio *folio)
{
if (folio_test_active(folio) || folio_test_unevictable(folio) ||
@@ -367,25 +356,6 @@ void folio_activate(struct folio *folio)
folio_batch_add_and_move(folio, lru_activate);
}
-#else
-static inline void folio_activate_drain(int cpu)
-{
-}
-
-void folio_activate(struct folio *folio)
-{
- struct lruvec *lruvec;
-
- if (!folio_test_clear_lru(folio))
- return;
-
- lruvec = folio_lruvec_lock_irq(folio);
- lru_activate(lruvec, folio);
- lruvec_unlock_irq(lruvec);
- folio_set_lru(folio);
-}
-#endif
-
static void __lru_cache_activate_folio(struct folio *folio)
{
struct folio_batch *fbatch;
@@ -694,6 +664,10 @@ void lru_add_drain_cpu(int cpu)
trace_mm_lru_add_drain_tp(cpu, nr_folios);
}
+ fbatch = &fbatches->lru_activate;
+ if (folio_batch_count(fbatch))
+ folio_batch_move_lru(fbatch, lru_activate);
+
fbatch = &fbatches->lru_move_tail;
/* Disabling interrupts below acts as a compiler barrier. */
if (data_race(folio_batch_count(fbatch))) {
@@ -716,8 +690,6 @@ void lru_add_drain_cpu(int cpu)
fbatch = &fbatches->lru_lazyfree;
if (folio_batch_count(fbatch))
folio_batch_move_lru(fbatch, lru_lazyfree);
-
- folio_activate_drain(cpu);
}
/**
@@ -825,11 +797,11 @@ static bool cpu_needs_drain(unsigned int cpu)
/* Check these in order of likelihood that they're not zero */
return data_race(folio_batch_count(&fbatches->lru_add) ||
+ folio_batch_count(&fbatches->lru_activate) ||
folio_batch_count(&fbatches->lru_move_tail) ||
folio_batch_count(&fbatches->lru_deactivate_file) ||
folio_batch_count(&fbatches->lru_deactivate) ||
folio_batch_count(&fbatches->lru_lazyfree) ||
- folio_batch_count(&fbatches->lru_activate) ||
need_mlock_drain(cpu)) ||
has_bh_in_lru(cpu, NULL);
}
--
2.51.0