linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again
@ 2025-01-24  4:38 Johannes Weiner
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johannes Weiner @ 2025-01-24  4:38 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Roman Gushchin, Shakeel Butt, Muchun Song, linux-mm,
	cgroups, linux-kernel

6b611388b626 ("memcg-v1: remove charge move code") removed the
remaining v1 callers.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol-v1.h | 15 ---------------
 mm/memcontrol.c    | 17 +++++++++++++----
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
index 144d71b65907..6dd7eaf96856 100644
--- a/mm/memcontrol-v1.h
+++ b/mm/memcontrol-v1.h
@@ -7,21 +7,6 @@
 
 /* Cgroup v1 and v2 common declarations */
 
-int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
-		     unsigned int nr_pages);
-
-static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
-			     unsigned int nr_pages)
-{
-	if (mem_cgroup_is_root(memcg))
-		return 0;
-
-	return try_charge_memcg(memcg, gfp_mask, nr_pages);
-}
-
-void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n);
-void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n);
-
 /*
  * Iteration constructs for visiting all cgroups (under a tree).  If
  * loops are exited prematurely (break), mem_cgroup_iter_break() must
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 46f8b372d212..818143b81760 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2198,8 +2198,8 @@ void mem_cgroup_handle_over_high(gfp_t gfp_mask)
 	css_put(&memcg->css);
 }
 
-int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
-		     unsigned int nr_pages)
+static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
+			    unsigned int nr_pages)
 {
 	unsigned int batch = max(MEMCG_CHARGE_BATCH, nr_pages);
 	int nr_retries = MAX_RECLAIM_RETRIES;
@@ -2388,6 +2388,15 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	return 0;
 }
 
+static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
+			     unsigned int nr_pages)
+{
+	if (mem_cgroup_is_root(memcg))
+		return 0;
+
+	return try_charge_memcg(memcg, gfp_mask, nr_pages);
+}
+
 static void commit_charge(struct folio *folio, struct mem_cgroup *memcg)
 {
 	VM_BUG_ON_FOLIO(folio_memcg_charged(folio), folio);
@@ -3368,13 +3377,13 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
 	}
 }
 
-void __maybe_unused mem_cgroup_id_get_many(struct mem_cgroup *memcg,
+static void __maybe_unused mem_cgroup_id_get_many(struct mem_cgroup *memcg,
 					   unsigned int n)
 {
 	refcount_add(n, &memcg->id.ref);
 }
 
-void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
+static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
 {
 	if (refcount_sub_and_test(n, &memcg->id.ref)) {
 		mem_cgroup_id_remove(memcg);
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1
  2025-01-24  4:38 [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Johannes Weiner
@ 2025-01-24  4:38 ` Johannes Weiner
  2025-01-25  1:26   ` Roman Gushchin
                     ` (2 more replies)
  2025-01-25  1:27 ` [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Roman Gushchin
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 8+ messages in thread
From: Johannes Weiner @ 2025-01-24  4:38 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Roman Gushchin, Shakeel Butt, Muchun Song, linux-mm,
	cgroups, linux-kernel

41213dd0f816 ("memcg: move mem_cgroup_event_ratelimit to v1 code")
left this one behind. There are no v2 references.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol-v1.c | 13 +++++++++++++
 mm/memcontrol-v1.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
index 2be6b9112808..6d184fae0ad1 100644
--- a/mm/memcontrol-v1.c
+++ b/mm/memcontrol-v1.c
@@ -490,6 +490,19 @@ static void mem_cgroup_threshold(struct mem_cgroup *memcg)
 }
 
 /* Cgroup1: threshold notifications & softlimit tree updates */
+
+/*
+ * Per memcg event counter is incremented at every pagein/pageout. With THP,
+ * it will be incremented by the number of pages. This counter is used
+ * to trigger some periodic events. This is straightforward and better
+ * than using jiffies etc. to handle periodic memcg event.
+ */
+enum mem_cgroup_events_target {
+	MEM_CGROUP_TARGET_THRESH,
+	MEM_CGROUP_TARGET_SOFTLIMIT,
+	MEM_CGROUP_NTARGETS,
+};
+
 struct memcg1_events_percpu {
 	unsigned long nr_page_events;
 	unsigned long targets[MEM_CGROUP_NTARGETS];
diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
index 6dd7eaf96856..4c8f36430fe9 100644
--- a/mm/memcontrol-v1.h
+++ b/mm/memcontrol-v1.h
@@ -28,18 +28,6 @@ static inline bool do_memsw_account(void)
 	return !cgroup_subsys_on_dfl(memory_cgrp_subsys);
 }
 
-/*
- * Per memcg event counter is incremented at every pagein/pageout. With THP,
- * it will be incremented by the number of pages. This counter is used
- * to trigger some periodic events. This is straightforward and better
- * than using jiffies etc. to handle periodic memcg event.
- */
-enum mem_cgroup_events_target {
-	MEM_CGROUP_TARGET_THRESH,
-	MEM_CGROUP_TARGET_SOFTLIMIT,
-	MEM_CGROUP_NTARGETS,
-};
-
 unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
 
 void drain_all_stock(struct mem_cgroup *root_memcg);
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
@ 2025-01-25  1:26   ` Roman Gushchin
  2025-01-25 20:12   ` Shakeel Butt
  2025-01-27 12:51   ` Michal Hocko
  2 siblings, 0 replies; 8+ messages in thread
From: Roman Gushchin @ 2025-01-25  1:26 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Michal Hocko, Shakeel Butt, Muchun Song, linux-mm,
	cgroups, linux-kernel

On Thu, Jan 23, 2025 at 11:38:59PM -0500, Johannes Weiner wrote:
> 41213dd0f816 ("memcg: move mem_cgroup_event_ratelimit to v1 code")
> left this one behind. There are no v2 references.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Roman Gushchin <roman.gushchin@linux.dev>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again
  2025-01-24  4:38 [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Johannes Weiner
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
@ 2025-01-25  1:27 ` Roman Gushchin
  2025-01-25 20:11 ` Shakeel Butt
  2025-01-27 12:50 ` Michal Hocko
  3 siblings, 0 replies; 8+ messages in thread
From: Roman Gushchin @ 2025-01-25  1:27 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Michal Hocko, Shakeel Butt, Muchun Song, linux-mm,
	cgroups, linux-kernel

On Thu, Jan 23, 2025 at 11:38:58PM -0500, Johannes Weiner wrote:
> 6b611388b626 ("memcg-v1: remove charge move code") removed the
> remaining v1 callers.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Roman Gushchin <roman.gushchin@linux.dev>

Thanks


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again
  2025-01-24  4:38 [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Johannes Weiner
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
  2025-01-25  1:27 ` [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Roman Gushchin
@ 2025-01-25 20:11 ` Shakeel Butt
  2025-01-27 12:50 ` Michal Hocko
  3 siblings, 0 replies; 8+ messages in thread
From: Shakeel Butt @ 2025-01-25 20:11 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Michal Hocko, Roman Gushchin, Muchun Song,
	linux-mm, cgroups, linux-kernel

On Thu, Jan 23, 2025 at 11:38:58PM -0500, Johannes Weiner wrote:
> 6b611388b626 ("memcg-v1: remove charge move code") removed the
> remaining v1 callers.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
  2025-01-25  1:26   ` Roman Gushchin
@ 2025-01-25 20:12   ` Shakeel Butt
  2025-01-27 12:51   ` Michal Hocko
  2 siblings, 0 replies; 8+ messages in thread
From: Shakeel Butt @ 2025-01-25 20:12 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Michal Hocko, Roman Gushchin, Muchun Song,
	linux-mm, cgroups, linux-kernel

On Thu, Jan 23, 2025 at 11:38:59PM -0500, Johannes Weiner wrote:
> 41213dd0f816 ("memcg: move mem_cgroup_event_ratelimit to v1 code")
> left this one behind. There are no v2 references.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again
  2025-01-24  4:38 [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Johannes Weiner
                   ` (2 preceding siblings ...)
  2025-01-25 20:11 ` Shakeel Butt
@ 2025-01-27 12:50 ` Michal Hocko
  3 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2025-01-27 12:50 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Roman Gushchin, Shakeel Butt, Muchun Song,
	linux-mm, cgroups, linux-kernel

On Thu 23-01-25 23:38:58, Johannes Weiner wrote:
> 6b611388b626 ("memcg-v1: remove charge move code") removed the
> remaining v1 callers.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  mm/memcontrol-v1.h | 15 ---------------
>  mm/memcontrol.c    | 17 +++++++++++++----
>  2 files changed, 13 insertions(+), 19 deletions(-)
> 
> diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
> index 144d71b65907..6dd7eaf96856 100644
> --- a/mm/memcontrol-v1.h
> +++ b/mm/memcontrol-v1.h
> @@ -7,21 +7,6 @@
>  
>  /* Cgroup v1 and v2 common declarations */
>  
> -int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
> -		     unsigned int nr_pages);
> -
> -static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
> -			     unsigned int nr_pages)
> -{
> -	if (mem_cgroup_is_root(memcg))
> -		return 0;
> -
> -	return try_charge_memcg(memcg, gfp_mask, nr_pages);
> -}
> -
> -void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n);
> -void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n);
> -
>  /*
>   * Iteration constructs for visiting all cgroups (under a tree).  If
>   * loops are exited prematurely (break), mem_cgroup_iter_break() must
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 46f8b372d212..818143b81760 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2198,8 +2198,8 @@ void mem_cgroup_handle_over_high(gfp_t gfp_mask)
>  	css_put(&memcg->css);
>  }
>  
> -int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
> -		     unsigned int nr_pages)
> +static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
> +			    unsigned int nr_pages)
>  {
>  	unsigned int batch = max(MEMCG_CHARGE_BATCH, nr_pages);
>  	int nr_retries = MAX_RECLAIM_RETRIES;
> @@ -2388,6 +2388,15 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
>  	return 0;
>  }
>  
> +static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
> +			     unsigned int nr_pages)
> +{
> +	if (mem_cgroup_is_root(memcg))
> +		return 0;
> +
> +	return try_charge_memcg(memcg, gfp_mask, nr_pages);
> +}
> +
>  static void commit_charge(struct folio *folio, struct mem_cgroup *memcg)
>  {
>  	VM_BUG_ON_FOLIO(folio_memcg_charged(folio), folio);
> @@ -3368,13 +3377,13 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
>  	}
>  }
>  
> -void __maybe_unused mem_cgroup_id_get_many(struct mem_cgroup *memcg,
> +static void __maybe_unused mem_cgroup_id_get_many(struct mem_cgroup *memcg,
>  					   unsigned int n)
>  {
>  	refcount_add(n, &memcg->id.ref);
>  }
>  
> -void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
> +static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
>  {
>  	if (refcount_sub_and_test(n, &memcg->id.ref)) {
>  		mem_cgroup_id_remove(memcg);
> -- 
> 2.48.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1
  2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
  2025-01-25  1:26   ` Roman Gushchin
  2025-01-25 20:12   ` Shakeel Butt
@ 2025-01-27 12:51   ` Michal Hocko
  2 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2025-01-27 12:51 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Roman Gushchin, Shakeel Butt, Muchun Song,
	linux-mm, cgroups, linux-kernel

On Thu 23-01-25 23:38:59, Johannes Weiner wrote:
> 41213dd0f816 ("memcg: move mem_cgroup_event_ratelimit to v1 code")
> left this one behind. There are no v2 references.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  mm/memcontrol-v1.c | 13 +++++++++++++
>  mm/memcontrol-v1.h | 12 ------------
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
> index 2be6b9112808..6d184fae0ad1 100644
> --- a/mm/memcontrol-v1.c
> +++ b/mm/memcontrol-v1.c
> @@ -490,6 +490,19 @@ static void mem_cgroup_threshold(struct mem_cgroup *memcg)
>  }
>  
>  /* Cgroup1: threshold notifications & softlimit tree updates */
> +
> +/*
> + * Per memcg event counter is incremented at every pagein/pageout. With THP,
> + * it will be incremented by the number of pages. This counter is used
> + * to trigger some periodic events. This is straightforward and better
> + * than using jiffies etc. to handle periodic memcg event.
> + */
> +enum mem_cgroup_events_target {
> +	MEM_CGROUP_TARGET_THRESH,
> +	MEM_CGROUP_TARGET_SOFTLIMIT,
> +	MEM_CGROUP_NTARGETS,
> +};
> +
>  struct memcg1_events_percpu {
>  	unsigned long nr_page_events;
>  	unsigned long targets[MEM_CGROUP_NTARGETS];
> diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
> index 6dd7eaf96856..4c8f36430fe9 100644
> --- a/mm/memcontrol-v1.h
> +++ b/mm/memcontrol-v1.h
> @@ -28,18 +28,6 @@ static inline bool do_memsw_account(void)
>  	return !cgroup_subsys_on_dfl(memory_cgrp_subsys);
>  }
>  
> -/*
> - * Per memcg event counter is incremented at every pagein/pageout. With THP,
> - * it will be incremented by the number of pages. This counter is used
> - * to trigger some periodic events. This is straightforward and better
> - * than using jiffies etc. to handle periodic memcg event.
> - */
> -enum mem_cgroup_events_target {
> -	MEM_CGROUP_TARGET_THRESH,
> -	MEM_CGROUP_TARGET_SOFTLIMIT,
> -	MEM_CGROUP_NTARGETS,
> -};
> -
>  unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
>  
>  void drain_all_stock(struct mem_cgroup *root_memcg);
> -- 
> 2.48.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-01-27 12:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24  4:38 [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Johannes Weiner
2025-01-24  4:38 ` [PATCH 2/2] mm: memcontrol: move stray ratelimit bits to v1 Johannes Weiner
2025-01-25  1:26   ` Roman Gushchin
2025-01-25 20:12   ` Shakeel Butt
2025-01-27 12:51   ` Michal Hocko
2025-01-25  1:27 ` [PATCH 1/2] mm: memcontrol: unshare v2-only charge API bits again Roman Gushchin
2025-01-25 20:11 ` Shakeel Butt
2025-01-27 12:50 ` 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).