[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aYQuj6Ot-JS4tXvY@hyeyoo>
Date: Thu, 5 Feb 2026 14:45:51 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Dev Jain <dev.jain@....com>
Cc: Shakeel Butt <shakeel.butt@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>, Michal Hocko <mhocko@...nel.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Muchun Song <muchun.song@...ux.dev>, Qi Zheng <qi.zheng@...ux.dev>,
Vlastimil Babka <vbabka@...e.cz>, linux-mm@...ck.org,
cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
Meta kernel team <kernel-team@...a.com>
Subject: Re: [PATCH 1/4] memcg: use mod_node_page_state to update stats
On Thu, Feb 05, 2026 at 10:50:06AM +0530, Dev Jain wrote:
>
> On 05/02/26 2:08 am, Shakeel Butt wrote:
> > On Mon, Feb 02, 2026 at 02:23:54PM +0530, Dev Jain wrote:
> >> On 02/02/26 10:24 am, Shakeel Butt wrote:
> >>>>>> Hello Shakeel,
> >>>>>>
> >>>>>> We are seeing a regression in micromm/munmap benchmark with this patch, on arm64 -
> >>>>>> the benchmark mmmaps a lot of memory, memsets it, and measures the time taken
> >>>>>> to munmap. Please see below if my understanding of this patch is correct.
> >>>>>>
> >>>>> Thanks for the report. Are you seeing regression in just the benchmark
> >>>>> or some real workload as well? Also how much regression are you seeing?
> >>>>> I have a kernel rebot regression report [1] for this patch as well which
> >>>>> says 2.6% regression and thus it was on the back-burner for now. I will
> >>>>> take look at this again soon.
> >>>>>
> >>>> The munmap regression is ~24%. Haven't observed a regression in any other
> >>>> benchmark yet.
> >>> Please share the code/benchmark which shows such regression, also if you can
> >>> share the perf profile, that would be awesome.
> >> https://gitlab.arm.com/tooling/fastpath/-/blob/main/containers/microbench/micromm.c
> >> You can run this with
> >> ./micromm 0 munmap 10
> >>
> >> Don't have a perf profile, I measured the time taken by above command, with and
> >> without the patch.
> >>
> > Hi Dev, can you please try the following patch?
> >
> >
> > From 40155feca7e7bc846800ab8449735bdb03164d6d Mon Sep 17 00:00:00 2001
> > From: Shakeel Butt <shakeel.butt@...ux.dev>
> > Date: Wed, 4 Feb 2026 08:46:08 -0800
> > Subject: [PATCH] vmstat: use preempt disable instead of try_cmpxchg
> >
> > Signed-off-by: Shakeel Butt <shakeel.butt@...ux.dev>
> > ---
[...snip...]
>
> Thanks for looking into this.
>
> But this doesn't solve it :( preempt_disable() contains a compiler barrier,
> probably that's why.
I think the reason why it doesn't solve the regression is because of how
arm64 implements this_cpu_add_8() and this_cpu_try_cmpxchg_8().
On arm64, IIUC both this_cpu_try_cmpxchg_8() and this_cpu_add_8() are
implemented using LL/SC instructions or LSE atomics (if supported).
See:
- this_cpu_add_8()
-> __percpu_add_case_64
(which is generated from PERCPU_OP)
- this_cpu_try_cmpxchg_8()
-> __cpu_fallback_try_cmpxchg(..., this_cpu_cmpxchg_8)
-> this_cpu_cmpxchg_8()
-> cmpxchg_relaxed()
-> raw_cmpxchg_relaxed()
-> arch_cmpxchg_relaxed()
-> __cmpxchg_wrapper()
-> __cmpxchg_case_64()
-> __lse_ll_sc_body(_cmpxchg_case_64, ...)
> Also can you confirm whether my analysis of the regression was correct?
> Because if it was, then this diff looks wrong - AFAIU preempt_disable()
> won't stop an irq handler from interrupting the execution, so this
> will introduce a bug for code paths running in irq context.
I was worried about the correctness too, but this_cpu_add() is safe
against IRQs and so the stat will be _eventually_ consistent?
Ofc it's so confusing! Maybe I'm the one confused.
--
Cheers,
Harry / Hyeonggon
Powered by blists - more mailing lists