From: Li Zefan <lizf@cn.fujitsu.com>
To: Paul Menage <menage@google.com>
Cc: Colin Cross <ccross@android.com>,
linux-kernel@vger.kernel.org,
containers@lists.linux-foundation.org
Subject: Re: [PATCH] cgroup: Convert synchronize_rcu to call_rcu in cgroup_attach_task
Date: Wed, 24 Nov 2010 10:06:33 +0800 [thread overview]
Message-ID: <4CEC7329.7070909@cn.fujitsu.com> (raw)
In-Reply-To: <AANLkTi=4-OgPUugnUBaqSU3oC=3wxTjAsOB_Ais3Or+i@mail.gmail.com>
Paul Menage wrote:
> On Sun, Nov 21, 2010 at 8:06 PM, Colin Cross <ccross@android.com> wrote:
>> The synchronize_rcu call in cgroup_attach_task can be very
>> expensive. All fastpath accesses to task->cgroups that expect
>> task->cgroups not to change already use task_lock() or
>> cgroup_lock() to protect against updates, and, in cgroup.c,
>> only the CGROUP_DEBUG files have RCU read-side critical
>> sections.
>
> I definitely agree with the goal of using lighter-weight
> synchronization than the current synchronize_rcu() call. However,
> there are definitely some subtleties to worry about in this code.
>
> One of the reasons originally for the current synchronization was to
> avoid the case of calling subsystem destroy() callbacks while there
> could still be threads with RCU references to the subsystem state. The
> fact that synchronize_rcu() was called within a cgroup_mutex critical
> section meant that an rmdir (or any other significant cgrooup
> management action) couldn't possibly start until any RCU read sections
> were done.
>
> I suspect that when we moved a lot of the cgroup teardown code from
> cgroup_rmdir() to cgroup_diput() (which also has a synchronize_rcu()
> call in it) this restriction could have been eased, but I think I left
> it as it was mostly out of paranoia that I was missing/forgetting some
> crucial reason for keeping it in place.
>
> I'd suggest trying the following approach, which I suspect is similar
> to what you were suggesting in your last email
>
> 1) make find_existing_css_set ignore css_set objects with a zero refcount
> 2) change __put_css_set to be simply
>
> if (atomic_dec_and_test(&cg->refcount)) {
> call_rcu(&cg->rcu_head, free_css_set_rcu);
> }
If we do this, it's not anymore safe to use get_css_set(), which just
increments the refcount without checking if it's zero.
>
> 3) move the rest of __put_css_set into a delayed work struct that's
> scheduled by free_css_set_rcu
>
> 4) Get rid of the taskexit parameter - I think we can do that via a
> simple flag that indicates whether any task has ever been moved into
> the cgroup.
>
> 5) Put extra checks in cgroup_rmdir() such that if it tries to remove
> a cgroup that has a non-zero refcount, it scans the cgroup's css_sets
> list - if it finds only zero-refcount entries, then wait (via
> synchronize_rcu() or some other appropriate means, maybe reusing the
> CGRP_WAIT_ON_RMDIR mechanism?) until the css_set objects have been
> fully cleaned up and the cgroup's refcounts have been released.
> Otherwise the operation of moving the last thread out of a cgroup and
> immediately deleting the cgroup would very likely fail with an EBUSY
>
next prev parent reply other threads:[~2010-11-24 2:04 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-21 2:00 [PATCH] cgroup: Remove RCU from task->cgroups Colin Cross
[not found] ` <1290304824-22722-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2010-11-21 23:02 ` Colin Cross
2010-11-21 23:02 ` Colin Cross
[not found] ` <AANLkTikx6d0_VFtZ4zWQucRCf=vFt7N2M6=0jpnKasEE-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-22 4:06 ` [PATCH] cgroup: Convert synchronize_rcu to call_rcu in cgroup_attach_task Colin Cross
2010-11-22 4:06 ` Colin Cross
2010-11-23 8:14 ` Li Zefan
[not found] ` <4CEB77E0.10202-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-11-23 8:58 ` Colin Cross
2010-11-23 8:58 ` Colin Cross
[not found] ` <AANLkTimjpW6NZ6fEiVi0VzjkpQGVob4=VHsohXUiDQkJ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-23 20:22 ` Colin Cross
2010-11-23 20:22 ` Colin Cross
2010-11-24 1:24 ` Paul Menage
[not found] ` <AANLkTi=4-OgPUugnUBaqSU3oC=3wxTjAsOB_Ais3Or+i-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-24 1:43 ` [PATCH] cgroup: Remove call to synchronize_rcu " Colin Cross
2010-11-24 1:43 ` Colin Cross
2010-11-24 2:29 ` Colin Cross
[not found] ` <1290563018-2804-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2010-11-24 2:29 ` Colin Cross
2011-01-22 1:17 ` Bryan Huntsman
2011-01-28 1:17 ` Bryan Huntsman
2011-01-22 1:17 ` Bryan Huntsman
2011-01-22 2:04 ` Colin Cross
[not found] ` <4D3A3024.9040402-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-01-22 2:04 ` Colin Cross
2011-01-28 1:17 ` Bryan Huntsman
2010-11-24 2:06 ` [PATCH] cgroup: Convert synchronize_rcu to call_rcu " Li Zefan
2010-11-24 2:06 ` Li Zefan [this message]
2010-11-24 2:10 ` Colin Cross
2010-11-24 5:37 ` [PATCH 1/2] cgroup: Set CGRP_RELEASABLE when adding to a cgroup Colin Cross
2010-11-24 23:54 ` Paul Menage
[not found] ` <AANLkTimFqJ+qPidS_81DKd7ExSxDG7GNi0gjcUEEq_7j-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-25 0:11 ` Colin Cross
2010-11-25 0:11 ` Colin Cross
2010-11-25 0:18 ` Colin Cross
2010-11-25 0:21 ` Paul Menage
[not found] ` <AANLkTimJA52-GTM=AzS+tkOugrsi6Keh0_j87vK1BkGv-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-03 3:07 ` Colin Cross
2010-12-03 3:07 ` Colin Cross
2010-12-17 0:54 ` Paul Menage
2010-12-17 1:12 ` Colin Cross
[not found] ` <AANLkTinZarXbEyb1xfJWjG4gN2qhTVTXTdso4Cym5M9T-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-17 1:12 ` Colin Cross
[not found] ` <AANLkTim67fLN+PYz-P0TM0QRmvQKP80tyXSNKNSZhFZ2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-17 0:54 ` Paul Menage
[not found] ` <AANLkTimwvP2Ey1gJ6AbbFNtDKjGZt4cwqL=08nGBa_PT-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-25 0:18 ` Colin Cross
2010-11-25 0:21 ` Paul Menage
[not found] ` <1290577024-12347-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2010-11-24 23:54 ` Paul Menage
2011-01-28 1:17 ` Bryan Huntsman
2011-01-28 1:17 ` Bryan Huntsman
[not found] ` <4D42192C.9000701-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-01-28 1:30 ` Paul Menage
2011-01-28 1:30 ` Paul Menage
[not found] ` <AANLkTin7B51maXHRH+FNmZ14bmWmEp9P2=2QTNqgq_Fi-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-28 1:48 ` Michael Bohan
2011-01-28 1:48 ` Michael Bohan
2010-11-24 5:37 ` [PATCH 2/2] cgroup: Remove call to synchronize_rcu in cgroup_attach_task Colin Cross
2011-01-28 1:17 ` Bryan Huntsman
[not found] ` <1290577024-12347-2-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2011-01-28 1:17 ` Bryan Huntsman
[not found] ` <AANLkTi=6nwDCdzDz7E2EaAw2pf3KUVjmKMRqGfz5zVhP-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-24 5:37 ` [PATCH 1/2] cgroup: Set CGRP_RELEASABLE when adding to a cgroup Colin Cross
2010-11-24 5:37 ` [PATCH 2/2] cgroup: Remove call to synchronize_rcu in cgroup_attach_task Colin Cross
[not found] ` <4CEC7329.7070909-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-11-24 2:10 ` [PATCH] cgroup: Convert synchronize_rcu to call_rcu " Colin Cross
2010-11-24 18:58 ` Paul Menage
2010-11-24 18:58 ` Paul Menage
[not found] ` <1290398767-15230-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2010-11-23 8:14 ` Li Zefan
2010-11-24 1:24 ` Paul Menage
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CEC7329.7070909@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=ccross@android.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.