All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bryan Huntsman <bryanh@codeaurora.org>
To: Colin Cross <ccross@android.com>
Cc: Paul Menage <menage@google.com>, Li Zefan <lizf@cn.fujitsu.com>,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, mbohan@codeaurora.org
Subject: Re: [PATCH 1/2] cgroup: Set CGRP_RELEASABLE when adding to a cgroup
Date: Thu, 27 Jan 2011 17:17:32 -0800	[thread overview]
Message-ID: <4D42192C.9000701@codeaurora.org> (raw)
In-Reply-To: <1290577024-12347-1-git-send-email-ccross@android.com>

On 11/23/2010 09:37 PM, Colin Cross wrote:
> Changes the meaning of CGRP_RELEASABLE to be set on any cgroup
> that has ever had a task or cgroup in it, or had css_get called
> on it.  The bit is set in cgroup_attach_task, cgroup_create,
> and __css_get.  It is not necessary to set the bit in
> cgroup_fork, as the task is either in the root cgroup, in
> which can never be released, or the task it was forked from
> already set the bit in croup_attach_task.
> 
> Signed-off-by: Colin Cross <ccross@android.com>
> ---
>  include/linux/cgroup.h |   12 +--------
>  kernel/cgroup.c        |   54 ++++++++++++++++++++---------------------------
>  2 files changed, 25 insertions(+), 41 deletions(-)
> 
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index ed4ba11..9e13078 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -84,12 +84,6 @@ enum {
>  	CSS_REMOVED, /* This CSS is dead */
>  };
>  
> -/* Caller must verify that the css is not for root cgroup */
> -static inline void __css_get(struct cgroup_subsys_state *css, int count)
> -{
> -	atomic_add(count, &css->refcnt);
> -}
> -
>  /*
>   * Call css_get() to hold a reference on the css; it can be used
>   * for a reference obtained via:
> @@ -97,6 +91,7 @@ static inline void __css_get(struct cgroup_subsys_state *css, int count)
>   * - task->cgroups for a locked task
>   */
>  
> +extern void __css_get(struct cgroup_subsys_state *css, int count);
>  static inline void css_get(struct cgroup_subsys_state *css)
>  {
>  	/* We don't need to reference count the root state */
> @@ -143,10 +138,7 @@ static inline void css_put(struct cgroup_subsys_state *css)
>  enum {
>  	/* Control Group is dead */
>  	CGRP_REMOVED,
> -	/*
> -	 * Control Group has previously had a child cgroup or a task,
> -	 * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set)
> -	 */
> +	/* Control Group has ever had a child cgroup or a task */
>  	CGRP_RELEASABLE,
>  	/* Control Group requires release notifications to userspace */
>  	CGRP_NOTIFY_ON_RELEASE,
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 66a416b..34e855e 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -338,7 +338,15 @@ static void free_css_set_rcu(struct rcu_head *obj)
>   * compiled into their kernel but not actually in use */
>  static int use_task_css_set_links __read_mostly;
>  
> -static void __put_css_set(struct css_set *cg, int taskexit)
> +/*
> + * refcounted get/put for css_set objects
> + */
> +static inline void get_css_set(struct css_set *cg)
> +{
> +	atomic_inc(&cg->refcount);
> +}
> +
> +static void put_css_set(struct css_set *cg)
>  {
>  	struct cg_cgroup_link *link;
>  	struct cg_cgroup_link *saved_link;
> @@ -364,12 +372,8 @@ static void __put_css_set(struct css_set *cg, int taskexit)
>  		struct cgroup *cgrp = link->cgrp;
>  		list_del(&link->cg_link_list);
>  		list_del(&link->cgrp_link_list);
> -		if (atomic_dec_and_test(&cgrp->count) &&
> -		    notify_on_release(cgrp)) {
> -			if (taskexit)
> -				set_bit(CGRP_RELEASABLE, &cgrp->flags);
> +		if (atomic_dec_and_test(&cgrp->count))
>  			check_for_release(cgrp);
> -		}
>  
>  		kfree(link);
>  	}
> @@ -379,24 +383,6 @@ static void __put_css_set(struct css_set *cg, int taskexit)
>  }
>  
>  /*
> - * refcounted get/put for css_set objects
> - */
> -static inline void get_css_set(struct css_set *cg)
> -{
> -	atomic_inc(&cg->refcount);
> -}
> -
> -static inline void put_css_set(struct css_set *cg)
> -{
> -	__put_css_set(cg, 0);
> -}
> -
> -static inline void put_css_set_taskexit(struct css_set *cg)
> -{
> -	__put_css_set(cg, 1);
> -}
> -
> -/*
>   * compare_css_sets - helper function for find_existing_css_set().
>   * @cg: candidate css_set being tested
>   * @old_cg: existing css_set for a task
> @@ -1801,7 +1787,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
>  		if (ss->attach)
>  			ss->attach(ss, cgrp, oldcgrp, tsk, false);
>  	}
> -	set_bit(CGRP_RELEASABLE, &oldcgrp->flags);
> +	set_bit(CGRP_RELEASABLE, &cgrp->flags);
>  	synchronize_rcu();
>  	put_css_set(cg);
>  
> @@ -3427,6 +3413,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
>  	if (err < 0)
>  		goto err_remove;
>  
> +	set_bit(CGRP_RELEASABLE, &parent->flags);
> +
>  	/* The cgroup directory was pre-locked for us */
>  	BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
>  
> @@ -3645,7 +3633,6 @@ again:
>  	cgroup_d_remove_dir(d);
>  	dput(d);
>  
> -	set_bit(CGRP_RELEASABLE, &parent->flags);
>  	check_for_release(parent);
>  
>  	/*
> @@ -4240,7 +4227,7 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks)
>  	tsk->cgroups = &init_css_set;
>  	task_unlock(tsk);
>  	if (cg)
> -		put_css_set_taskexit(cg);
> +		put_css_set(cg);
>  }
>  
>  /**
> @@ -4410,6 +4397,14 @@ static void check_for_release(struct cgroup *cgrp)
>  }
>  
>  /* Caller must verify that the css is not for root cgroup */
> +void __css_get(struct cgroup_subsys_state *css, int count)
> +{
> +	atomic_add(count, &css->refcnt);
> +	set_bit(CGRP_RELEASABLE, &css->cgroup->flags);
> +}
> +EXPORT_SYMBOL_GPL(__css_get);
> +
> +/* Caller must verify that the css is not for root cgroup */
>  void __css_put(struct cgroup_subsys_state *css, int count)
>  {
>  	struct cgroup *cgrp = css->cgroup;
> @@ -4417,10 +4412,7 @@ void __css_put(struct cgroup_subsys_state *css, int count)
>  	rcu_read_lock();
>  	val = atomic_sub_return(count, &css->refcnt);
>  	if (val == 1) {
> -		if (notify_on_release(cgrp)) {
> -			set_bit(CGRP_RELEASABLE, &cgrp->flags);
> -			check_for_release(cgrp);
> -		}
> +		check_for_release(cgrp);
>  		cgroup_wakeup_rmdir_waiter(cgrp);
>  	}
>  	rcu_read_unlock();

Tested-by: Mike Bohan <mbohan@codeaurora.org>

I'm responding on Mike's behalf and adding him to this thread.  This
patch improves launch time of a test app from ~700ms to ~250ms on MSM,
with much lower variance across tests.  We also see UI latency
improvements, but have not quantified the gains.

- Bryan

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  parent reply	other threads:[~2011-01-28  1:17 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-21  2:00 [PATCH] cgroup: Remove RCU from task->cgroups 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
2010-11-24  2:06       ` Li Zefan
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
     [not found]                         ` <AANLkTinZarXbEyb1xfJWjG4gN2qhTVTXTdso4Cym5M9T-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-17  1:12                           ` Colin Cross
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
2011-01-28  1:17             ` Bryan Huntsman [this message]
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
     [not found]               ` <4D42192C.9000701-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-01-28  1:30                 ` 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
2010-11-24  5:37           ` [PATCH 2/2] cgroup: Remove call to synchronize_rcu in cgroup_attach_task Colin Cross
     [not found]             ` <1290577024-12347-2-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2011-01-28  1:17               ` Bryan Huntsman
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]       ` <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
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
     [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-28  1:17           ` Bryan Huntsman
2010-11-24  2:06         ` [PATCH] cgroup: Convert synchronize_rcu to call_rcu " Li Zefan
     [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
     [not found] ` <1290304824-22722-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2010-11-21 23:02   ` [PATCH] cgroup: Remove RCU from task->cgroups Colin Cross
  -- strict thread matches above, loose matches on Subject: below --
2010-12-18 19:30 [PATCH 1/2] cgroup: Set CGRP_RELEASABLE when adding to a cgroup 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=4D42192C.9000701@codeaurora.org \
    --to=bryanh@codeaurora.org \
    --cc=ccross@android.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mbohan@codeaurora.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.