Re: [PATCH cgroup/for-6.19 1/2] cgroup: Convert css_set_lock from spinlock_t to raw_spinlock_t

From: Sebastian Andrzej Siewior

Date: Wed Nov 05 2025 - 02:30:14 EST


On 2025-11-04 09:32:24 [-1000], Tejun Heo wrote:
> +++ b/kernel/cgroup/cgroup-internal.h
> @@ -208,9 +208,9 @@ static inline void put_css_set(struct cs
> if (refcount_dec_not_one(&cset->refcount))
> return;
>
> - spin_lock_irqsave(&css_set_lock, flags);
> + raw_spin_lock_irqsave(&css_set_lock, flags);
> put_css_set_locked(cset);

This one has a kfree(link) and kfree takes spinlock_t so not working.

> - spin_unlock_irqrestore(&css_set_lock, flags);
> + raw_spin_unlock_irqrestore(&css_set_lock, flags);
> }

> /*
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -1272,7 +1274,7 @@ static struct css_set *find_css_set(stru
> * find_existing_css_set() */
> memcpy(cset->subsys, template, sizeof(cset->subsys));
>
> - spin_lock_irq(&css_set_lock);
> + raw_spin_lock_irq(&css_set_lock);
> /* Add reference counts and links from the new css_set. */
> list_for_each_entry(link, &old_cset->cgrp_links, cgrp_link) {
> struct cgroup *c = link->cgrp;

I am also a bit worried about all these list iterations which happen
under the lock. There is no upper limit meaning the list can grow with
limits affecting the time the lock is held.

Sebastian