All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	ctalbott-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 11/11] blkcg: implement per-blkg request allocation
Date: Fri, 27 Apr 2012 13:15:16 -0700	[thread overview]
Message-ID: <20120427201516.GJ26595@google.com> (raw)
In-Reply-To: <20120427194654.GN10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Hello, Vivek.

On Fri, Apr 27, 2012 at 03:46:54PM -0400, Vivek Goyal wrote:
> On Thu, Apr 26, 2012 at 02:59:21PM -0700, Tejun Heo wrote:
> 
> [..]
> > @@ -926,6 +936,7 @@ static struct request *__get_request(struct request_list *rl, int rw_flags,
> >  		goto fail_alloc;
> >  
> >  	blk_rq_init(q, rq);
> > +	blk_rq_set_rl(rq, rl);
> 
> Given the fact that we have established the rq and blkg releation at
> the time of allocation, should we modify CFQ to just use that relation
> instread of trying to lookup group again based on bio.

Maybe, given the lookup cache it shouldn't really matter tho.

> We avoid one lookup also we avoid duplicate creation of blkg in following
> corner case of bio==NULL
> 
> 	- blkg_get_rl()
> 	- request allocation fails. sleep, drop queue lock
> 	- process is moved to a different cgroup. origincal cgroup is
> 	  deleted. pre_destroy will cleanup all blkg on blkcg.
> 	- process wakes up, request allocated, set_request sets up new blkg
>  	  based on new cgroup. Now a request is queued in one blkg/cgroup and
>  	  it has come out of the quota of other blkg/cgroup.

I don't think it really matters as long as the request gets freed to
the right queue on completion.

> Well, I have a question. Ideally nobody should be linking any more blkg
> to a blkcg once blkg_pre_destroy() has been called? But can it happen
> that bio_associate_current() takes are reference to blkcg and bio is
> throttled. cgroup associated with bio is deleted resulting in
> pre_destroy(). Now bio is submitted to CFQ and it will try to create
> a new blkg for blkcg-queue pair and once IO is complete, bio will drop
> blkcg reference, which in turn will free up blkcg and associated blkg
> is still around and will not be cleaned up.
> 
> IOW, looks like we need a mechanism to mark a blkcg dead (set in
> pre_destroy() call) and any submissions to blkcg after that should result
> in bio being divered to root group?

Don't we already have that with css_tryget()?

Thanks.

-- 
tejun

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: axboe@kernel.dk, ctalbott@google.com, rni@google.com,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	containers@lists.linux-foundation.org, fengguang.wu@intel.com,
	hughd@google.com, akpm@linux-foundation.org
Subject: Re: [PATCH 11/11] blkcg: implement per-blkg request allocation
Date: Fri, 27 Apr 2012 13:15:16 -0700	[thread overview]
Message-ID: <20120427201516.GJ26595@google.com> (raw)
In-Reply-To: <20120427194654.GN10579@redhat.com>

Hello, Vivek.

On Fri, Apr 27, 2012 at 03:46:54PM -0400, Vivek Goyal wrote:
> On Thu, Apr 26, 2012 at 02:59:21PM -0700, Tejun Heo wrote:
> 
> [..]
> > @@ -926,6 +936,7 @@ static struct request *__get_request(struct request_list *rl, int rw_flags,
> >  		goto fail_alloc;
> >  
> >  	blk_rq_init(q, rq);
> > +	blk_rq_set_rl(rq, rl);
> 
> Given the fact that we have established the rq and blkg releation at
> the time of allocation, should we modify CFQ to just use that relation
> instread of trying to lookup group again based on bio.

Maybe, given the lookup cache it shouldn't really matter tho.

> We avoid one lookup also we avoid duplicate creation of blkg in following
> corner case of bio==NULL
> 
> 	- blkg_get_rl()
> 	- request allocation fails. sleep, drop queue lock
> 	- process is moved to a different cgroup. origincal cgroup is
> 	  deleted. pre_destroy will cleanup all blkg on blkcg.
> 	- process wakes up, request allocated, set_request sets up new blkg
>  	  based on new cgroup. Now a request is queued in one blkg/cgroup and
>  	  it has come out of the quota of other blkg/cgroup.

I don't think it really matters as long as the request gets freed to
the right queue on completion.

> Well, I have a question. Ideally nobody should be linking any more blkg
> to a blkcg once blkg_pre_destroy() has been called? But can it happen
> that bio_associate_current() takes are reference to blkcg and bio is
> throttled. cgroup associated with bio is deleted resulting in
> pre_destroy(). Now bio is submitted to CFQ and it will try to create
> a new blkg for blkcg-queue pair and once IO is complete, bio will drop
> blkcg reference, which in turn will free up blkcg and associated blkg
> is still around and will not be cleaned up.
> 
> IOW, looks like we need a mechanism to mark a blkcg dead (set in
> pre_destroy() call) and any submissions to blkcg after that should result
> in bio being divered to root group?

Don't we already have that with css_tryget()?

Thanks.

-- 
tejun

  parent reply	other threads:[~2012-04-27 20:15 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 21:59 [PATCHSET] block: implement per-blkg request allocation Tejun Heo
2012-04-26 21:59 ` Tejun Heo
     [not found] ` <1335477561-11131-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-04-26 21:59   ` [PATCH 01/11] blkcg: fix blkg_alloc() failure path Tejun Heo
2012-04-26 21:59     ` Tejun Heo
     [not found]     ` <1335477561-11131-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-04-27 14:26       ` Vivek Goyal
2012-04-27 14:26       ` Vivek Goyal
2012-04-27 14:26         ` Vivek Goyal
     [not found]         ` <20120427142652.GH10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 14:27           ` Tejun Heo
2012-04-27 14:27           ` Tejun Heo
2012-04-27 14:27             ` Tejun Heo
2012-04-26 21:59   ` [PATCH 02/11] blkcg: __blkg_lookup_create() doesn't have to fail on radix tree preload failure Tejun Heo
2012-04-26 21:59     ` Tejun Heo
     [not found]     ` <1335477561-11131-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-04-27 14:42       ` Vivek Goyal
2012-04-27 14:42         ` Vivek Goyal
     [not found]         ` <20120427144258.GI10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 14:47           ` Tejun Heo
2012-04-27 14:47           ` Tejun Heo
2012-04-27 14:47             ` Tejun Heo
2012-04-27 21:18       ` [PATCH UPDATED 02/11] blkcg: __blkg_lookup_create() doesn't need radix preload Tejun Heo
2012-04-27 21:18       ` Tejun Heo
2012-04-27 21:18         ` Tejun Heo
2012-04-26 21:59   ` [PATCH 03/11] blkcg: make root blkcg allocation use %GFP_KERNEL Tejun Heo
2012-04-26 21:59     ` Tejun Heo
     [not found]     ` <1335477561-11131-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-04-27 21:19       ` [PATCH UPDATED " Tejun Heo
2012-04-27 21:19         ` Tejun Heo
2012-04-26 21:59   ` [PATCH 04/11] mempool: add @gfp_mask to mempool_create_node() Tejun Heo
2012-04-26 21:59     ` Tejun Heo
2012-04-26 21:59   ` [PATCH 05/11] block: drop custom queue draining used by scsi_transport_{iscsi|fc} Tejun Heo
2012-04-26 21:59     ` Tejun Heo
     [not found]     ` <1335477561-11131-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-05-02  4:55       ` Mike Christie
2012-05-02  4:55         ` Mike Christie
2012-05-02  4:55       ` Mike Christie
2012-04-26 21:59   ` [PATCH 06/11] block: refactor get_request[_wait]() Tejun Heo
2012-04-26 21:59     ` Tejun Heo
2012-04-26 21:59   ` [PATCH 07/11] block: allocate io_context upfront Tejun Heo
2012-04-26 21:59     ` Tejun Heo
2012-04-26 21:59   ` [PATCH 08/11] blkcg: inline bio_blkcg() and friends Tejun Heo
2012-04-26 21:59     ` Tejun Heo
2012-04-26 21:59   ` [PATCH 09/11] block: add q->nr_rqs[] and move q->rq.elvpriv to q->nr_rqs_elvpriv Tejun Heo
2012-04-26 21:59   ` [PATCH 10/11] block: prepare for multiple request_lists Tejun Heo
2012-04-26 21:59     ` Tejun Heo
2012-04-26 21:59   ` [PATCH 11/11] blkcg: implement per-blkg request allocation Tejun Heo
2012-04-26 21:59     ` Tejun Heo
     [not found]     ` <1335477561-11131-12-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-04-27 14:54       ` Jeff Moyer
2012-04-27 14:54         ` Jeff Moyer
     [not found]         ` <x49wr51usxi.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2012-04-27 15:02           ` Tejun Heo
2012-04-27 15:02             ` Tejun Heo
     [not found]             ` <20120427150217.GK27486-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-04-27 15:40               ` Vivek Goyal
2012-04-27 15:40                 ` Vivek Goyal
     [not found]                 ` <20120427154033.GJ10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 15:45                   ` Tejun Heo
2012-04-27 15:45                     ` Tejun Heo
     [not found]                     ` <20120427154502.GM27486-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-04-27 15:48                       ` Vivek Goyal
2012-04-27 15:48                         ` Vivek Goyal
     [not found]                         ` <20120427154841.GA16237-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 15:51                           ` Tejun Heo
2012-04-27 15:51                             ` Tejun Heo
     [not found]                             ` <20120427155140.GN27486-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-04-27 15:56                               ` Vivek Goyal
2012-04-27 15:56                                 ` Vivek Goyal
     [not found]                                 ` <20120427155612.GK10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 16:19                                   ` Vivek Goyal
2012-04-27 16:19                                     ` Vivek Goyal
2012-04-27 16:20                                   ` Tejun Heo
2012-04-27 16:20                                     ` Tejun Heo
     [not found]                                     ` <20120427162012.GP27486-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-04-27 17:21                                       ` Vivek Goyal
2012-04-27 17:21                                       ` Vivek Goyal
2012-04-27 17:21                                         ` Vivek Goyal
     [not found]                                         ` <20120427172110.GM10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 17:25                                           ` Tejun Heo
2012-04-27 17:25                                           ` Tejun Heo
2012-04-27 17:25                                             ` Tejun Heo
2012-04-27 15:48                       ` Vivek Goyal
2012-04-27 15:45                   ` Tejun Heo
2012-04-27 15:02           ` Tejun Heo
2012-04-27 19:46       ` Vivek Goyal
2012-04-27 19:46         ` Vivek Goyal
     [not found]         ` <20120427194654.GN10579-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-27 20:15           ` Tejun Heo [this message]
2012-04-27 20:15             ` Tejun Heo
     [not found]             ` <20120427201516.GJ26595-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-04-27 20:21               ` Vivek Goyal
2012-04-27 20:21               ` Vivek Goyal
2012-04-27 20:21                 ` Vivek Goyal
2012-04-26 21:59 ` [PATCH 09/11] block: add q->nr_rqs[] and move q->rq.elvpriv to q->nr_rqs_elvpriv Tejun Heo

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=20120427201516.GJ26595@google.com \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=ctalbott-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /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.