The first patch expose swapcache stat for memcg v1, the second patch
remote unused do_memsw_account() in memcg1_stat_format().
v1->v2: Cover MEMCG_SWAP with CONFIG_SWAP and delete unused code suggested
by Michal.
Liu Shixin (2):
memcg: expose swapcache stat for memcg v1
memcg: remove unused do_memsw_account in memcg1_stat_format
Documentation/admin-guide/cgroup-v1/memory.rst | 1 +
mm/memcontrol.c | 15 ++++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
--
2.25.1
Since commit b25806dcd3d5("mm: memcontrol: deprecate swapaccounting=0 mode")
do_memsw_account() is synonymous with !cgroup_subsys_on_dfl(memory_cgrp_subsys),
It always equals true in memcg1_stat_format(). Remove the unused code.
Suggested-by: Michal Koutný <[email protected]>
Signed-off-by: Liu Shixin <[email protected]>
---
mm/memcontrol.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 78ea10c5a636..bb9a617be046 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4112,8 +4112,6 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
unsigned long nr;
- if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
- continue;
nr = memcg_page_state_local(memcg, memcg1_stats[i]);
seq_buf_printf(s, "%s %lu\n", memcg1_stat_names[i],
nr * memcg_page_state_unit(memcg1_stats[i]));
@@ -4136,15 +4134,12 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
}
seq_buf_printf(s, "hierarchical_memory_limit %llu\n",
(u64)memory * PAGE_SIZE);
- if (do_memsw_account())
- seq_buf_printf(s, "hierarchical_memsw_limit %llu\n",
- (u64)memsw * PAGE_SIZE);
+ seq_buf_printf(s, "hierarchical_memsw_limit %llu\n",
+ (u64)memsw * PAGE_SIZE);
for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
unsigned long nr;
- if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
- continue;
nr = memcg_page_state(memcg, memcg1_stats[i]);
seq_buf_printf(s, "total_%s %llu\n", memcg1_stat_names[i],
(u64)nr * memcg_page_state_unit(memcg1_stats[i]));
--
2.25.1
On Fri, Sep 15, 2023 at 06:58:43PM +0800, Liu Shixin wrote:
> The first patch expose swapcache stat for memcg v1, the second patch
> remote unused do_memsw_account() in memcg1_stat_format().
>
> v1->v2: Cover MEMCG_SWAP with CONFIG_SWAP and delete unused code suggested
> by Michal.
>
> Liu Shixin (2):
> memcg: expose swapcache stat for memcg v1
> memcg: remove unused do_memsw_account in memcg1_stat_format
Acked-by: Tejun heo <[email protected]>
Thanks.
--
tejun
On Fri, Sep 15, 2023 at 3:05 AM Liu Shixin <[email protected]> wrote:
>
> Since commit b25806dcd3d5("mm: memcontrol: deprecate swapaccounting=0 mode")
> do_memsw_account() is synonymous with !cgroup_subsys_on_dfl(memory_cgrp_subsys),
> It always equals true in memcg1_stat_format(). Remove the unused code.
>
> Suggested-by: Michal Koutný <[email protected]>
> Signed-off-by: Liu Shixin <[email protected]>
Reviewed-by: Yosry Ahmed <[email protected]>
> ---
> mm/memcontrol.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 78ea10c5a636..bb9a617be046 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4112,8 +4112,6 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
> for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
> unsigned long nr;
>
> - if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
> - continue;
> nr = memcg_page_state_local(memcg, memcg1_stats[i]);
> seq_buf_printf(s, "%s %lu\n", memcg1_stat_names[i],
> nr * memcg_page_state_unit(memcg1_stats[i]));
> @@ -4136,15 +4134,12 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
> }
> seq_buf_printf(s, "hierarchical_memory_limit %llu\n",
> (u64)memory * PAGE_SIZE);
> - if (do_memsw_account())
> - seq_buf_printf(s, "hierarchical_memsw_limit %llu\n",
> - (u64)memsw * PAGE_SIZE);
> + seq_buf_printf(s, "hierarchical_memsw_limit %llu\n",
> + (u64)memsw * PAGE_SIZE);
>
> for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
> unsigned long nr;
>
> - if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
> - continue;
> nr = memcg_page_state(memcg, memcg1_stats[i]);
> seq_buf_printf(s, "total_%s %llu\n", memcg1_stat_names[i],
> (u64)nr * memcg_page_state_unit(memcg1_stats[i]));
> --
> 2.25.1
>