[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fyu3eohrzarujgjwtpg6b2jultwntihm5kreoqx3b3gqlamum3@imbouehlyhle>
Date: Wed, 21 May 2025 16:50:50 -0700
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: JP Kobryn <inwardvessel@...il.com>
Cc: Klara Modin <klarasmodin@...il.com>, Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, Alexei Starovoitov <ast@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Michal Hocko <mhocko@...nel.org>,
Roman Gushchin <roman.gushchin@...ux.dev>, Muchun Song <muchun.song@...ux.dev>,
Yosry Ahmed <yosry.ahmed@...ux.dev>, Michal Koutný <mkoutny@...e.com>,
Vlastimil Babka <vbabka@...e.cz>, Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
bpf@...r.kernel.org, linux-mm@...ck.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org, Meta kernel team <kernel-team@...a.com>
Subject: Re: [OFFLIST PATCH 2/2] cgroup: use subsystem-specific rstat locks
to avoid contention
On Wed, May 21, 2025 at 04:47:01PM -0700, JP Kobryn wrote:
>
>
> On 5/21/25 4:33 PM, Shakeel Butt wrote:
> > On Wed, May 21, 2025 at 04:23:44PM -0700, Shakeel Butt wrote:
> > > On Thu, May 22, 2025 at 12:23:44AM +0200, Klara Modin wrote:
> > > > Hi,
> > > >
> > > > On 2025-04-28 23:15:58 -0700, Shakeel Butt wrote:
> > > > > Please ignore this patch as it was sent by mistake.
> > > >
> > > > This seems to have made it into next:
> > > >
> > > > 748922dcfabd ("cgroup: use subsystem-specific rstat locks to avoid contention")
> > > >
> > > > It causes a BUG and eventually a panic on my Raspberry Pi 1:
> > > >
> > > > WARNING: CPU: 0 PID: 0 at mm/percpu.c:1766 pcpu_alloc_noprof (mm/percpu.c:1766 (discriminator 2))
> > > > illegal size (0) or align (4) for percpu allocation
> > >
> > > Ok this config is without CONFIG_SMP and on such configs we have:
> > >
> > > typedef struct { } arch_spinlock_t;
> > >
> > > So, we are doing ss->rstat_ss_cpu_lock = alloc_percpu(0).
> > >
> > > Hmm, let me think more on how to fix this.
> > >
> >
> > I think following is the simplest fix:
> >
> > diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
> > index 7dd396ae3c68..aab09495192e 100644
> > --- a/kernel/cgroup/rstat.c
> > +++ b/kernel/cgroup/rstat.c
> > @@ -511,7 +511,10 @@ int __init ss_rstat_init(struct cgroup_subsys *ss)
> > int cpu;
> > if (ss) {
> > - ss->rstat_ss_cpu_lock = alloc_percpu(raw_spinlock_t);
> > + size_t size = sizeof(raw_spinlock_t) ?: 1;
> > +
> > + ss->rstat_ss_cpu_lock = __alloc_percpu(size,
> > + __alignof__(raw_spinlock_t));
>
> Thanks for narrowing this one down so fast. Would this approach be more
> straightforward?
>
> if (ss) {
> #ifdef CONFIG_SMP
> ss->rstat_ss_cpu_lock = alloc_percpu(raw_spinlock_t);
> #endif
>
> Since on non-smp the lock functions are no-ops, leaving the ss cpu lock
> can perhaps be left NULL. I could include a comment as well explaining
> why.
>
> > if (!ss->rstat_ss_cpu_lock)
> > return -ENOMEM;
Include this check and return -ENOMEM in the ifdef as well.
> > }
>
Powered by blists - more mailing lists