mm/lruvec: trace LRU add drains
Subsystems (2)
PATCH v2 1/1 mm/lruvec: trace LRU add drains
LRU add batches can be drained before they reach capacity. This can be a source of LRU lock contention, but it is not currently possible to attribute these drains to callers with existing tracepoints.
Add mm_lru_add_drain to report the CPU and lru_add batch count when an lru_add batch is drained. This allows tracing to distinguish full drains from partial drains and attribute them to the calling stack.
Signed-off-by JP Kobryn <[email protected]>
---
v2:
- removed mm_lru_drain_all tracepoint
v1: https://lore.kernel.org/linux-mm/[email protected]/
include/trace/events/pagemap.h | 19 +++++++++++++++++++ mm/swap.c | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-)
include/trace/events/pagemap.h +19 -0
@@ -77,6 +77,25 @@ TRACE_EVENT(mm_lru_activate,TP_printk ("folio=%p pfn=0x%lx" , __entry->folio, __entry->pfn) ); +TRACE_EVENT (mm_lru_add_drain, + + TP_PROTO(int cpu, unsigned int nr), + +TP_ARGS (cpu, nr), + +TP_STRUCT__entry ( + __field(int, cpu ) + __field(unsigned int, nr ) + ), + +TP_fast_assign ( + __entry->cpu = cpu; + __entry->nr = nr; + ), + +TP_printk ("cpu=%d nr=%u" , __entry->cpu, __entry->nr) +); +#endif /* _TRACE_PAGEMAP_H */ /* This part must be outside protection */
mm/swap.c +4 -1
@@ -694,9 +694,12 @@ void lru_add_drain_cpu(int cpu) {struct cpu_fbatches *fbatches = &per_cpu (cpu_fbatches, cpu);struct folio_batch *fbatch = &fbatches->lru_add; +unsigned int nr_folios_add =folio_batch_count (fbatch); -if (folio_batch_count (fbatch)) +if (nr_folios_add) {folio_batch_move_lru (fbatch, lru_add); +trace_mm_lru_add_drain (cpu, nr_folios_add); + } fbatch = &fbatches->lru_move_tail;/* Disabling interrupts below acts as a compiler barrier. */
Signature · 1 line
2.54.0