[mm-unstable,2/4] mm: multi-gen LRU: cleanup lru_gen_soft_reclaim()

Message ID 20230522112058.2965866-2-talumbau@google.com
State New
Headers
Series [mm-unstable,1/4] mm: multi-gen LRU: use macro for bitmap |

Commit Message

T.J. Alumbaugh May 22, 2023, 11:20 a.m. UTC
  lru_gen_soft_reclaim() gets the lruvec from the memcg and node ID to keep a
cleaner interface on the caller side.

Signed-off-by: T.J. Alumbaugh <talumbau@google.com>
---
 include/linux/mmzone.h | 4 ++--
 mm/memcontrol.c        | 2 +-
 mm/vmscan.c            | 4 +++-
 3 files changed, 6 insertions(+), 4 deletions(-)
  

Comments

Yuanchu Xie June 1, 2023, 8:01 a.m. UTC | #1
Reviewed-by: Yuanchu Xie <yuanchu@google.com>

On Mon, May 22, 2023 at 7:21 PM T.J. Alumbaugh <talumbau@google.com> wrote:
>
> lru_gen_soft_reclaim() gets the lruvec from the memcg and node ID to keep a
> cleaner interface on the caller side.
>
> Signed-off-by: T.J. Alumbaugh <talumbau@google.com>
> ---
>  include/linux/mmzone.h | 4 ++--
>  mm/memcontrol.c        | 2 +-
>  mm/vmscan.c            | 4 +++-
>  3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 3a68326c9989..5a7ada0413da 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -534,7 +534,7 @@ void lru_gen_exit_memcg(struct mem_cgroup *memcg);
>  void lru_gen_online_memcg(struct mem_cgroup *memcg);
>  void lru_gen_offline_memcg(struct mem_cgroup *memcg);
>  void lru_gen_release_memcg(struct mem_cgroup *memcg);
> -void lru_gen_soft_reclaim(struct lruvec *lruvec);
> +void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid);
>
>  #else /* !CONFIG_MEMCG */
>
> @@ -585,7 +585,7 @@ static inline void lru_gen_release_memcg(struct mem_cgroup *memcg)
>  {
>  }
>
> -static inline void lru_gen_soft_reclaim(struct lruvec *lruvec)
> +static inline void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid)
>  {
>  }
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d31fb1e2cb33..738ba18f3a0c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -485,7 +485,7 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, int nid)
>
>         if (lru_gen_enabled()) {
>                 if (soft_limit_excess(memcg))
> -                       lru_gen_soft_reclaim(&memcg->nodeinfo[nid]->lruvec);
> +                       lru_gen_soft_reclaim(memcg, nid);
>                 return;
>         }
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index cf18873a36b9..e088db138f5f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4846,8 +4846,10 @@ void lru_gen_release_memcg(struct mem_cgroup *memcg)
>         }
>  }
>
> -void lru_gen_soft_reclaim(struct lruvec *lruvec)
> +void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid)
>  {
> +       struct lruvec *lruvec = get_lruvec(memcg, nid);
> +
>         /* see the comment on MEMCG_NR_GENS */
>         if (lru_gen_memcg_seg(lruvec) != MEMCG_LRU_HEAD)
>                 lru_gen_rotate_memcg(lruvec, MEMCG_LRU_HEAD);
> --
> 2.40.1.698.g37aff9b760-goog
>
  

Patch

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 3a68326c9989..5a7ada0413da 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -534,7 +534,7 @@  void lru_gen_exit_memcg(struct mem_cgroup *memcg);
 void lru_gen_online_memcg(struct mem_cgroup *memcg);
 void lru_gen_offline_memcg(struct mem_cgroup *memcg);
 void lru_gen_release_memcg(struct mem_cgroup *memcg);
-void lru_gen_soft_reclaim(struct lruvec *lruvec);
+void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid);
 
 #else /* !CONFIG_MEMCG */
 
@@ -585,7 +585,7 @@  static inline void lru_gen_release_memcg(struct mem_cgroup *memcg)
 {
 }
 
-static inline void lru_gen_soft_reclaim(struct lruvec *lruvec)
+static inline void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid)
 {
 }
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d31fb1e2cb33..738ba18f3a0c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -485,7 +485,7 @@  static void mem_cgroup_update_tree(struct mem_cgroup *memcg, int nid)
 
 	if (lru_gen_enabled()) {
 		if (soft_limit_excess(memcg))
-			lru_gen_soft_reclaim(&memcg->nodeinfo[nid]->lruvec);
+			lru_gen_soft_reclaim(memcg, nid);
 		return;
 	}
 
diff --git a/mm/vmscan.c b/mm/vmscan.c
index cf18873a36b9..e088db138f5f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4846,8 +4846,10 @@  void lru_gen_release_memcg(struct mem_cgroup *memcg)
 	}
 }
 
-void lru_gen_soft_reclaim(struct lruvec *lruvec)
+void lru_gen_soft_reclaim(struct mem_cgroup *memcg, int nid)
 {
+	struct lruvec *lruvec = get_lruvec(memcg, nid);
+
 	/* see the comment on MEMCG_NR_GENS */
 	if (lru_gen_memcg_seg(lruvec) != MEMCG_LRU_HEAD)
 		lru_gen_rotate_memcg(lruvec, MEMCG_LRU_HEAD);