[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241206013512.2883617-4-chenridong@huaweicloud.com>
Date: Fri, 6 Dec 2024 01:35:10 +0000
From: Chen Ridong <chenridong@...weicloud.com>
To: akpm@...ux-foundation.org,
mhocko@...nel.org,
hannes@...xchg.org,
yosryahmed@...gle.com,
roman.gushchin@...ux.dev,
shakeel.butt@...ux.dev,
muchun.song@...ux.dev,
davidf@...eo.com,
vbabka@...e.cz
Cc: linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org,
chenridong@...wei.com,
wangweiyang2@...wei.com
Subject: [next -v1 3/5] memcg: simplify the mem_cgroup_update_lru_size function
From: Chen Ridong <chenridong@...wei.com>
In the `mem_cgroup_update_lru_size` function, the `lru_size` should be
updated by adding `nr_pages` regardless of whether `nr_pages` is greater
than 0 or less than 0. To simplify this function, add a check for
`nr_pages` == 0. When `nr_pages` is not equal to 0, perform the same
actions.
Signed-off-by: Chen Ridong <chenridong@...wei.com>
---
mm/memcontrol.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index da6e4e9bd0fa..f977e0be1c04 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1280,15 +1280,14 @@ void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
unsigned long *lru_size;
long size;
- if (mem_cgroup_disabled())
+ if (mem_cgroup_disabled() || !nr_pages)
return;
mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
lru_size = &mz->lru_zone_size[zid][lru];
- if (nr_pages < 0)
- *lru_size += nr_pages;
+ *lru_size += nr_pages;
size = *lru_size;
if (WARN_ONCE(size < 0,
"%s(%p, %d, %d): lru_size %ld\n",
@@ -1296,9 +1295,6 @@ void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
VM_BUG_ON(1);
*lru_size = 0;
}
-
- if (nr_pages > 0)
- *lru_size += nr_pages;
}
/**
--
2.34.1
Powered by blists - more mailing lists