Subject: linux-next: manual merge of the cgroup tree with the mm-stable, mm-unstable trees

From: Stephen Rothwell <[email-masked]>
Date: Thu, 22 May 2025 17:35:18 +1000

Hi all,

Today's linux-next merge of the cgroup tree got a conflict in:

  mm/memcontrol.c

between commits:

  60cada258dfe ("memcg: optimize memcg_rstat_updated")
  ff9798e05d33 ("memcg: memcg_rstat_updated re-entrant safe against irqs")

from the mm-stable tree,

  dc1bc55490f4 ("memcg: make memcg_rstat_updated nmi safe")

from the mm-unstable tree and commit:

  a97915559f5c ("cgroup: change rstat function signatures from cgroup-based to css-based")

from the cgroup tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/memcontrol.c
index 4e9771e6e340,fde0934e2837..000000000000
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@@ -573,22 -582,11 +573,22 @@@ static inline void memcg_rstat_updated(
  	if (!val)
  		return;
  
 -	css_rstat_updated(&memcg->css, cpu);
 -	statc = this_cpu_ptr(memcg->vmstats_percpu);
 -	for (; statc; statc = statc->parent) {
 -		stats_updates = READ_ONCE(statc->stats_updates) + abs(val);
 -		WRITE_ONCE(statc->stats_updates, stats_updates);
 +	/* TODO: add to cgroup update tree once it is nmi-safe. */
 +	if (!in_nmi())
- 		cgroup_rstat_updated(memcg->css.cgroup, cpu);
++		css_rstat_updated(&memcg->css, cpu);
 +	statc_pcpu = memcg->vmstats_percpu;
 +	for (; statc_pcpu; statc_pcpu = statc->parent_pcpu) {
 +		statc = this_cpu_ptr(statc_pcpu);
 +		/*
 +		 * If @memcg is already flushable then all its ancestors are
 +		 * flushable as well and also there is no need to increase
 +		 * stats_updates.
 +		 */
 +		if (memcg_vmstats_needs_flush(statc->vmstats))
 +			break;
 +
 +		stats_updates = this_cpu_add_return(statc_pcpu->stats_updates,
 +						    abs(val));
  		if (stats_updates < MEMCG_CHARGE_BATCH)
  			continue;