Re: [PATCH 19/26] cgroups: Convert cgroups release_list_lock to raw_spinlock

From: John Kacur
Date: Mon Jan 11 2010 - 17:11:30 EST



----- "Paul Menage" <menage@xxxxxxxxxx> wrote:

> Does this patch take the lock out of the scope of lockdep? Or is
> raw_spinlock still high-level enough to support lockdep?

lockdep should work as before - in fact everything should work as before.
This is pretty much a no-op until preempt-rt changes are pushed upstream.
>
> Paul
>
> On Mon, Jan 11, 2010 at 1:26 PM, John Kacur <jkacur@xxxxxxxxxx>
> wrote:
> > Convert locks which cannot sleep in preempt-rt to raw_spinlocks
> >
> > See also 58814bae5de64d5291b813ea0a52192e4fa714ad
> >
> > Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
> > ---
> > Âkernel/cgroup.c | Â 18 +++++++++---------
> > Â1 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> > index 0249f4b..32a80b2 100644
> > --- a/kernel/cgroup.c
> > +++ b/kernel/cgroup.c
> > @@ -204,7 +204,7 @@ list_for_each_entry(_root, &roots, root_list)
> > Â/* the list of cgroups eligible for automatic release. Protected
> by
> > Â* release_list_lock */
> > Âstatic LIST_HEAD(release_list);
> > -static DEFINE_SPINLOCK(release_list_lock);
> > +static DEFINE_RAW_SPINLOCK(release_list_lock);
> > Âstatic void cgroup_release_agent(struct work_struct *work);
> > Âstatic DECLARE_WORK(release_agent_work, cgroup_release_agent);
> > Âstatic void check_for_release(struct cgroup *cgrp);
> > @@ -3151,11 +3151,11 @@ again:
> > Â Â Â Âfinish_wait(&cgroup_rmdir_waitq, &wait);
> > Â Â Â Âclear_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
> >
> > - Â Â Â spin_lock(&release_list_lock);
> > + Â Â Â raw_spin_lock(&release_list_lock);
> > Â Â Â Âset_bit(CGRP_REMOVED, &cgrp->flags);
> > Â Â Â Âif (!list_empty(&cgrp->release_list))
> > Â Â Â Â Â Â Â Âlist_del(&cgrp->release_list);
> > - Â Â Â spin_unlock(&release_list_lock);
> > + Â Â Â raw_spin_unlock(&release_list_lock);
> >
> > Â Â Â Âcgroup_lock_hierarchy(cgrp->root);
> > Â Â Â Â/* delete this cgroup from parent->children */
> > @@ -3691,13 +3691,13 @@ static void check_for_release(struct cgroup
> *cgrp)
> > Â Â Â Â Â Â Â Â * already queued for a userspace notification,
> queue
> > Â Â Â Â Â Â Â Â * it now */
> > Â Â Â Â Â Â Â Âint need_schedule_work = 0;
> > - Â Â Â Â Â Â Â spin_lock(&release_list_lock);
> > + Â Â Â Â Â Â Â raw_spin_lock(&release_list_lock);
> > Â Â Â Â Â Â Â Âif (!cgroup_is_removed(cgrp) &&
> > Â Â Â Â Â Â Â Â Â Âlist_empty(&cgrp->release_list)) {
> > Â Â Â Â Â Â Â Â Â Â Â Âlist_add(&cgrp->release_list,
> &release_list);
> > Â Â Â Â Â Â Â Â Â Â Â Âneed_schedule_work = 1;
> > Â Â Â Â Â Â Â Â}
> > - Â Â Â Â Â Â Â spin_unlock(&release_list_lock);
> > + Â Â Â Â Â Â Â raw_spin_unlock(&release_list_lock);
> > Â Â Â Â Â Â Â Âif (need_schedule_work)
> > Â Â Â Â Â Â Â Â Â Â Â Âschedule_work(&release_agent_work);
> > Â Â Â Â}
> > @@ -3747,7 +3747,7 @@ static void cgroup_release_agent(struct
> work_struct *work)
> > Â{
> > Â Â Â ÂBUG_ON(work != &release_agent_work);
> > Â Â Â Âmutex_lock(&cgroup_mutex);
> > - Â Â Â spin_lock(&release_list_lock);
> > + Â Â Â raw_spin_lock(&release_list_lock);
> > Â Â Â Âwhile (!list_empty(&release_list)) {
> > Â Â Â Â Â Â Â Âchar *argv[3], *envp[3];
> > Â Â Â Â Â Â Â Âint i;
> > @@ -3756,7 +3756,7 @@ static void cgroup_release_agent(struct
> work_struct *work)
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct cgroup,
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Ârelease_list);
> > Â Â Â Â Â Â Â Âlist_del_init(&cgrp->release_list);
> > - Â Â Â Â Â Â Â spin_unlock(&release_list_lock);
> > + Â Â Â Â Â Â Â raw_spin_unlock(&release_list_lock);
> > Â Â Â Â Â Â Â Âpathbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> > Â Â Â Â Â Â Â Âif (!pathbuf)
> > Â Â Â Â Â Â Â Â Â Â Â Âgoto continue_free;
> > @@ -3786,9 +3786,9 @@ static void cgroup_release_agent(struct
> work_struct *work)
> > Âcontinue_free:
> > Â Â Â Â Â Â Â Âkfree(pathbuf);
> > Â Â Â Â Â Â Â Âkfree(agentbuf);
> > - Â Â Â Â Â Â Â spin_lock(&release_list_lock);
> > + Â Â Â Â Â Â Â raw_spin_lock(&release_list_lock);
> > Â Â Â Â}
> > - Â Â Â spin_unlock(&release_list_lock);
> > + Â Â Â raw_spin_unlock(&release_list_lock);
> > Â Â Â Âmutex_unlock(&cgroup_mutex);
> > Â}
> >
> > --
> > 1.6.5.2
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in
> > the body of a message to majordomo@xxxxxxxxxxxxxxx
> > More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at Âhttp://www.tux.org/lkml/
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/