* [PATCH] mm, memcg: clean up reclaim iter array
@ 2019-10-01 2:42 Yafang Shao
2019-10-02 12:24 ` Michal Hocko
0 siblings, 1 reply; 2+ messages in thread
From: Yafang Shao @ 2019-10-01 2:42 UTC (permalink / raw)
To: akpm, mhocko, hannes, vdavydov.dev; +Cc: linux-mm, Yafang Shao
The mem_cgroup_reclaim_cookie is only used in memcg softlimit reclaim now,
and the priority of the reclaim is always 0. We don't need to define the
iter in struct mem_cgroup_per_node as an array any more. That could make
the code more clear and save some space.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/memcontrol.h | 3 +--
mm/memcontrol.c | 11 +++--------
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0c762e8..7d99a65 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -58,7 +58,6 @@ enum mem_cgroup_protection {
struct mem_cgroup_reclaim_cookie {
pg_data_t *pgdat;
- int priority;
unsigned int generation;
};
@@ -126,7 +125,7 @@ struct mem_cgroup_per_node {
unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
- struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1];
+ struct mem_cgroup_reclaim_iter iter;
struct memcg_shrinker_map __rcu *shrinker_map;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1c4c08b..5d9b00f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1052,7 +1052,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
struct mem_cgroup_per_node *mz;
mz = mem_cgroup_nodeinfo(root, reclaim->pgdat->node_id);
- iter = &mz->iter[reclaim->priority];
+ iter = &mz->iter;
if (prev && reclaim->generation != iter->generation)
goto out_unlock;
@@ -1152,15 +1152,11 @@ static void __invalidate_reclaim_iterators(struct mem_cgroup *from,
struct mem_cgroup_reclaim_iter *iter;
struct mem_cgroup_per_node *mz;
int nid;
- int i;
for_each_node(nid) {
mz = mem_cgroup_nodeinfo(from, nid);
- for (i = 0; i <= DEF_PRIORITY; i++) {
- iter = &mz->iter[i];
- cmpxchg(&iter->position,
- dead_memcg, NULL);
- }
+ iter = &mz->iter;
+ cmpxchg(&iter->position, dead_memcg, NULL);
}
}
@@ -1705,7 +1701,6 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,
unsigned long nr_scanned;
struct mem_cgroup_reclaim_cookie reclaim = {
.pgdat = pgdat,
- .priority = 0,
};
excess = soft_limit_excess(root_memcg);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm, memcg: clean up reclaim iter array
2019-10-01 2:42 [PATCH] mm, memcg: clean up reclaim iter array Yafang Shao
@ 2019-10-02 12:24 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2019-10-02 12:24 UTC (permalink / raw)
To: Yafang Shao; +Cc: akpm, hannes, vdavydov.dev, linux-mm
On Mon 30-09-19 22:42:08, Yafang Shao wrote:
> The mem_cgroup_reclaim_cookie is only used in memcg softlimit reclaim now,
> and the priority of the reclaim is always 0. We don't need to define the
> iter in struct mem_cgroup_per_node as an array any more. That could make
> the code more clear and save some space.
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Any changes to the soft limit reclaim are unlikely to happen so I tend
to agree that further simplification of the iterator is desirable.
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
> ---
> include/linux/memcontrol.h | 3 +--
> mm/memcontrol.c | 11 +++--------
> 2 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 0c762e8..7d99a65 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -58,7 +58,6 @@ enum mem_cgroup_protection {
>
> struct mem_cgroup_reclaim_cookie {
> pg_data_t *pgdat;
> - int priority;
> unsigned int generation;
> };
>
> @@ -126,7 +125,7 @@ struct mem_cgroup_per_node {
>
> unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
>
> - struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1];
> + struct mem_cgroup_reclaim_iter iter;
>
> struct memcg_shrinker_map __rcu *shrinker_map;
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 1c4c08b..5d9b00f 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1052,7 +1052,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
> struct mem_cgroup_per_node *mz;
>
> mz = mem_cgroup_nodeinfo(root, reclaim->pgdat->node_id);
> - iter = &mz->iter[reclaim->priority];
> + iter = &mz->iter;
>
> if (prev && reclaim->generation != iter->generation)
> goto out_unlock;
> @@ -1152,15 +1152,11 @@ static void __invalidate_reclaim_iterators(struct mem_cgroup *from,
> struct mem_cgroup_reclaim_iter *iter;
> struct mem_cgroup_per_node *mz;
> int nid;
> - int i;
>
> for_each_node(nid) {
> mz = mem_cgroup_nodeinfo(from, nid);
> - for (i = 0; i <= DEF_PRIORITY; i++) {
> - iter = &mz->iter[i];
> - cmpxchg(&iter->position,
> - dead_memcg, NULL);
> - }
> + iter = &mz->iter;
> + cmpxchg(&iter->position, dead_memcg, NULL);
> }
> }
>
> @@ -1705,7 +1701,6 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,
> unsigned long nr_scanned;
> struct mem_cgroup_reclaim_cookie reclaim = {
> .pgdat = pgdat,
> - .priority = 0,
> };
>
> excess = soft_limit_excess(root_memcg);
> --
> 1.8.3.1
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-02 12:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 2:42 [PATCH] mm, memcg: clean up reclaim iter array Yafang Shao
2019-10-02 12:24 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).