cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* synchronize_rcu in cgroup_attach_task and cgroup_attach_proc
@ 2013-01-11 23:48 Colin Cross
       [not found] ` <CAMbhsRQo3mjSMWTtUzqaHbeZqVYafzUjoweWa9Oz3QNRM46PVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Cross @ 2013-01-11 23:48 UTC (permalink / raw)
  To: Tejun Heo, Li Zefan; +Cc: cgroups-u79uwXL29TY76Z2rM5mHXA

Quick background:  Android uses cgroups heavily to manage thread
priorities, putting threads in a background group with reduced
cpu.shares when they are not visible to the user, and in a foreground
group when they are.  Some RPCs from foreground threads to background
threads will temporarily move the background thread into the
foreground group for the duration of the RPC.  This results in many
calls to cgroup_attach_task.

The call to synchronize_rcu() in cgroup_attach_task and
cgroup_attach_proc can take up to 100ms, and averages 50ms on Nexus 10
(ARM Exynos5250 SoC) when the cpus are all idle, and similar times
have been measured on multiple other ARM SMP SoCs.

I worked with Paul around v3.0 to try to remove the synchronize_rcu
calls (see https://android.googlesource.com/kernel/common/+/befae2f2c9137d6af5c8b38670f00441019032bb),
but nobody seemed to have a clear understanding of the full extent of
what the synchronize_rcu was protecting.  Since then the relevant
code, especially cgroup_rmdir, has been heavily rewritten, so
hopefully someone understands it better now.

The only rcu-protected variable updated in cgroup_attach_task is
tsk->cgroups.  Freeing the old tsk->cgroups is already rcu-protected
by kfree_rcu in __put_css_set.  The only thing that happens before
cgroup_attach_task returns out to userspace is threadgroup_unlock and
cgroup_unlock.  Is anything relying on cgroup_mutex to be held for an
RCU grace period?  If not, it seems like the synchronize_rcu isn't
protecting anything and is just wasting time.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: synchronize_rcu in cgroup_attach_task and cgroup_attach_proc
       [not found] ` <CAMbhsRQo3mjSMWTtUzqaHbeZqVYafzUjoweWa9Oz3QNRM46PVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-01-14  4:07   ` Li Zefan
  0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2013-01-14  4:07 UTC (permalink / raw)
  To: Colin Cross; +Cc: Tejun Heo, cgroups-u79uwXL29TY76Z2rM5mHXA

On 2013/1/12 7:48, Colin Cross wrote:
> Quick background:  Android uses cgroups heavily to manage thread
> priorities, putting threads in a background group with reduced
> cpu.shares when they are not visible to the user, and in a foreground
> group when they are.  Some RPCs from foreground threads to background
> threads will temporarily move the background thread into the
> foreground group for the duration of the RPC.  This results in many
> calls to cgroup_attach_task.
> 
> The call to synchronize_rcu() in cgroup_attach_task and
> cgroup_attach_proc can take up to 100ms, and averages 50ms on Nexus 10
> (ARM Exynos5250 SoC) when the cpus are all idle, and similar times
> have been measured on multiple other ARM SMP SoCs.
> 
> I worked with Paul around v3.0 to try to remove the synchronize_rcu
> calls (see https://android.googlesource.com/kernel/common/+/befae2f2c9137d6af5c8b38670f00441019032bb),
> but nobody seemed to have a clear understanding of the full extent of
> what the synchronize_rcu was protecting.  Since then the relevant
> code, especially cgroup_rmdir, has been heavily rewritten, so
> hopefully someone understands it better now.
> 
> The only rcu-protected variable updated in cgroup_attach_task is
> tsk->cgroups.  Freeing the old tsk->cgroups is already rcu-protected
> by kfree_rcu in __put_css_set.  The only thing that happens before
> cgroup_attach_task returns out to userspace is threadgroup_unlock and
> cgroup_unlock.  Is anything relying on cgroup_mutex to be held for an
> RCU grace period?  If not, it seems like the synchronize_rcu isn't
> protecting anything and is just wasting time.
> 

Let's remove these two synchronize_rcu()s without hesitation. If some
subtleties are broken, we'll fix them, and thus make the code saner.

Patch will be sent out soon.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-14  4:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 23:48 synchronize_rcu in cgroup_attach_task and cgroup_attach_proc Colin Cross
     [not found] ` <CAMbhsRQo3mjSMWTtUzqaHbeZqVYafzUjoweWa9Oz3QNRM46PVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-14  4:07   ` Li Zefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).