[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <77zncuxd472mhhbsbj3orcwsj7pl65s4h6uy5x6fioy55cvlsd@zmvpkrh2wfry>
Date: Wed, 21 May 2025 16:47:33 -0700
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: Klara Modin <klarasmodin@...il.com>
Cc: 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>, JP Kobryn <inwardvessel@...il.com>, 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:33:35PM -0700, 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));
> if (!ss->rstat_ss_cpu_lock)
> return -ENOMEM;
> }
JP suggested to avoid the allocation altogether on such configs. So,
something like the following.
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 7dd396ae3c68..d0c88903d033 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -510,7 +510,7 @@ int __init ss_rstat_init(struct cgroup_subsys *ss)
{
int cpu;
- if (ss) {
+ if (ss && sizeof(raw_spinlock_t)) {
ss->rstat_ss_cpu_lock = alloc_percpu(raw_spinlock_t);
if (!ss->rstat_ss_cpu_lock)
return -ENOMEM;
Tejun which one do you prefer?
Powered by blists - more mailing lists