From: Kinsey Ho <kinseyho@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
David Rientjes <rientjes@google.com>,
willy@infradead.org, Vlastimil Babka <vbabka@suse.cz>,
David Hildenbrand <david@redhat.com>,
Kinsey Ho <kinseyho@google.com>,
Joel Granados <joel.granados@kernel.org>,
Kaiyang Zhao <kaiyang2@cs.cmu.edu>,
Sourav Panda <souravpanda@google.com>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH mm-unstable v1 2/2] mm, swap: add pages allocated for struct swap_cgroup to vmstat
Date: Thu, 31 Oct 2024 22:45:51 +0000 [thread overview]
Message-ID: <20241031224551.1736113-3-kinseyho@google.com> (raw)
In-Reply-To: <20241031224551.1736113-1-kinseyho@google.com>
Export the number of pages allocated for storing struct swap_cgroup in
vmstat using global system-wide counters.
Signed-off-by: Kinsey Ho <kinseyho@google.com>
---
include/linux/vmstat.h | 3 +++
mm/swap_cgroup.c | 3 +++
mm/vmstat.c | 3 +++
3 files changed, 9 insertions(+)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index ac4d42c4fabd..227e951d1219 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -41,6 +41,9 @@ enum vm_stat_item {
NR_DIRTY_BG_THRESHOLD,
NR_MEMMAP_PAGES, /* page metadata allocated through buddy allocator */
NR_MEMMAP_BOOT_PAGES, /* page metadata allocated through boot allocator */
+#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP)
+ NR_SWAP_CGROUP_PAGES, /* allocated to store struct swap_cgroup */
+#endif
NR_VM_STAT_ITEMS,
};
diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c
index da1278f0563b..82eda8a3efe1 100644
--- a/mm/swap_cgroup.c
+++ b/mm/swap_cgroup.c
@@ -53,6 +53,8 @@ static int swap_cgroup_prepare(int type)
if (!(idx % SWAP_CLUSTER_MAX))
cond_resched();
}
+ mod_global_page_state(NR_SWAP_CGROUP_PAGES, ctrl->length);
+
return 0;
not_enough_page:
max = idx;
@@ -228,6 +230,7 @@ void swap_cgroup_swapoff(int type)
if (!(i % SWAP_CLUSTER_MAX))
cond_resched();
}
+ mod_global_page_state(NR_SWAP_CGROUP_PAGES, -length);
vfree(map);
}
}
diff --git a/mm/vmstat.c b/mm/vmstat.c
index e5a6dd5106c2..259574261ec1 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1295,6 +1295,9 @@ const char * const vmstat_text[] = {
"nr_dirty_background_threshold",
"nr_memmap_pages",
"nr_memmap_boot_pages",
+#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP)
+ "nr_swap_cgroup_pages",
+#endif
#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
/* enum vm_event_item counters */
--
2.47.0.163.g1226f6d8fa-goog
next prev parent reply other threads:[~2024-10-31 22:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 22:45 [PATCH mm-unstable v1 0/2] Track pages allocated for struct Kinsey Ho
2024-10-31 22:45 ` [PATCH mm-unstable v1 1/2] mm: add generic system-wide page counters Kinsey Ho
2024-10-31 22:45 ` Kinsey Ho [this message]
2024-11-04 16:22 ` [PATCH mm-unstable v1 2/2] mm, swap: add pages allocated for struct swap_cgroup to vmstat Michal Koutný
2024-10-31 23:06 ` [PATCH mm-unstable v1 0/2] Track pages allocated for struct Andrew Morton
2024-11-01 15:54 ` Matthew Wilcox
2024-11-13 0:19 ` Kinsey Ho
2024-11-13 19:18 ` Roman Gushchin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241031224551.1736113-3-kinseyho@google.com \
--to=kinseyho@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=joel.granados@kernel.org \
--cc=kaiyang2@cs.cmu.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=pasha.tatashin@soleen.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=souravpanda@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox