Skip to content

Commit 15ff4d4

Browse files
linuszengakpm00
authored andcommitted
mm/memcontrol: add per-memcg pgpgin/pswpin counter
In proactive memory reclamation scenarios, it is necessary to estimate the pswpin and pswpout metrics of the cgroup to determine whether to continue reclaiming anonymous pages in the current batch. This patch will collect these metrics and expose them. [[email protected]: v2] Link: https://lkml.kernel.org/r/[email protected] Li nk: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jingxiang Zeng <[email protected]> Acked-by: Nhat Pham <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Shakeel Butt <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ba7196e commit 15ff4d4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mm/memcontrol.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ static const unsigned int memcg_vm_event_stat[] = {
418418
PGPGIN,
419419
PGPGOUT,
420420
#endif
421+
PSWPIN,
422+
PSWPOUT,
421423
PGSCAN_KSWAPD,
422424
PGSCAN_DIRECT,
423425
PGSCAN_KHUGEPAGED,

mm/page_io.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ static inline void count_swpout_vm_event(struct folio *folio)
290290
}
291291
count_mthp_stat(folio_order(folio), MTHP_STAT_SWPOUT);
292292
#endif
293+
count_memcg_folio_events(folio, PSWPOUT, folio_nr_pages(folio));
293294
count_vm_events(PSWPOUT, folio_nr_pages(folio));
294295
}
295296

@@ -485,6 +486,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
485486
for (p = 0; p < sio->pages; p++) {
486487
struct folio *folio = page_folio(sio->bvec[p].bv_page);
487488

489+
count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
488490
folio_mark_uptodate(folio);
489491
folio_unlock(folio);
490492
}
@@ -570,6 +572,7 @@ static void swap_read_folio_bdev_sync(struct folio *folio,
570572
* attempt to access it in the page fault retry time check.
571573
*/
572574
get_task_struct(current);
575+
count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
573576
count_vm_events(PSWPIN, folio_nr_pages(folio));
574577
submit_bio_wait(&bio);
575578
__end_swap_bio_read(&bio);
@@ -585,6 +588,7 @@ static void swap_read_folio_bdev_async(struct folio *folio,
585588
bio->bi_iter.bi_sector = swap_folio_sector(folio);
586589
bio->bi_end_io = end_swap_bio_read;
587590
bio_add_folio_nofail(bio, folio, folio_size(folio), 0);
591+
count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
588592
count_vm_events(PSWPIN, folio_nr_pages(folio));
589593
submit_bio(bio);
590594
}

0 commit comments

Comments
 (0)