From: Yang Shi <yang.shi(a)linux.alibaba.com>
commit 668e4147d8850df32ca41e28f52c146025ca45c6 uptream
Account the number of demoted pages.
Add pgdemote_kswapd and pgdemote_direct VM counters showed in
/proc/vmstat.
[ daveh:
- __count_vm_events() a bit, and made them look at the THP
size directly rather than getting data from migrate_pages()
]
Link:
https://lkml.kernel.org/r/20210721063926.3024591-5-ying.huang@intel.com
Link:
https://lkml.kernel.org/r/20210715055145.195411-6-ying.huang@intel.com
Signed-off-by: Yang Shi <yang.shi(a)linux.alibaba.com>
Signed-off-by: Dave Hansen <dave.hansen(a)linux.intel.com>
Signed-off-by: "Huang, Ying" <ying.huang(a)intel.com>
Reviewed-by: Yang Shi <shy828301(a)gmail.com>
Reviewed-by: Wei Xu <weixugc(a)google.com>
Reviewed-by: Zi Yan <ziy(a)nvidia.com>
Cc: Michal Hocko <mhocko(a)suse.com>
Cc: David Rientjes <rientjes(a)google.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: David Hildenbrand <david(a)redhat.com>
Cc: Oscar Salvador <osalvador(a)suse.de>
Cc: Greg Thelen <gthelen(a)google.com>
Cc: Keith Busch <kbusch(a)kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
---
include/linux/vm_event_item.h | 2 ++
mm/vmscan.c | 5 +++++
mm/vmstat.c | 2 ++
3 files changed, 9 insertions(+)
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 6143858..8984994 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -32,6 +32,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
PGREFILL,
PGSTEAL_KSWAPD,
PGSTEAL_DIRECT,
+ PGDEMOTE_KSWAPD,
+ PGDEMOTE_DIRECT,
PGSCAN_KSWAPD,
PGSCAN_DIRECT,
PGSCAN_DIRECT_THROTTLE,
diff --git a/mm/vmscan.c b/mm/vmscan.c
index d63504e..7dad7fb 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1115,6 +1115,11 @@ static unsigned int demote_page_list(struct list_head
*demote_pages,
target_nid, MIGRATE_ASYNC, MR_DEMOTION,
&nr_succeeded);
+ if (current_is_kswapd())
+ __count_vm_events(PGDEMOTE_KSWAPD, nr_succeeded);
+ else
+ __count_vm_events(PGDEMOTE_DIRECT, nr_succeeded);
+
return nr_succeeded;
}
diff --git a/mm/vmstat.c b/mm/vmstat.c
index c9421b1..c457bcc 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1214,6 +1214,8 @@ int fragmentation_index(struct zone *zone, unsigned int order)
"pgrefill",
"pgsteal_kswapd",
"pgsteal_direct",
+ "pgdemote_kswapd",
+ "pgdemote_direct",
"pgscan_kswapd",
"pgscan_direct",
"pgscan_direct_throttle",
--
1.8.3.1