linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Tao Ma <tm@tao.ma>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH V2] block/throttle: Add IO throttled information in blkio.throttle.
Date: Tue, 4 Sep 2012 10:45:10 -0400	[thread overview]
Message-ID: <20120904144510.GA2603@redhat.com> (raw)
In-Reply-To: <50460C61.6050705@tao.ma>

On Tue, Sep 04, 2012 at 10:12:49PM +0800, Tao Ma wrote:
> On 09/04/2012 09:35 PM, Vivek Goyal wrote:
> > On Fri, Aug 31, 2012 at 01:15:09PM +0800, Tao Ma wrote:
> > 
> > [..]
> >> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> >> index 1588c2d..9317d71 100644
> >> --- a/block/blk-throttle.c
> >> +++ b/block/blk-throttle.c
> >> @@ -46,6 +46,8 @@ struct tg_stats_cpu {
> >>  	struct blkg_rwstat		service_bytes;
> >>  	/* total IOs serviced, post merge */
> >>  	struct blkg_rwstat		serviced;
> >> +	/* total IOs queued, not submitted to the underlying device. */
> >> +	struct blkg_rwstat		io_queued;
> >>  };
> > 
> > Couple of questions.
> > 
> > - blkg_rwstat is "unsigned" and io_queued can go negative too (Because
> >   throttled bio can very well be dispatched from other cpu from a worker
> >   thread). So is it a good idea to represent a negative number with 
> >   unsingned type?
> > 
> > - As this stat is per cpu, a reader might very well see negative (or a
> >   huge unsigned value) as number of io_queued. Not sure if that is acceptable.
> >   How would user space come to know whether it is a valid value or not. I
> >   thought per cpu stats are good for continuously increasing values but
> >   not necessarily for values which can increase as well as decrease.
> You are right. So I should just use throtl_grp->nr_queued to display the
> total numbers of ios being throttled and I guess a rcu_read_lock should
> be enough for me to access that data.

In last mail I missed the point that you are planning to read
tg->nr_queued directly.

thrtl_grp->nr_queued is protected by queue_lock. So to be preceise, you
will have to take queue lock in read path. Current design is that we
don't take queue lock while we are holding blkcg lock(to avoid deadlock).
So in read path, reading tg->nr_queued under queue_lock is not possible.

Reading a bit, nr_queued[] is of type "unsinged int". So update to it
are atomic both at 32bit and 64bit platforms. If that's the case, I 
think we should be able to just read tg->nr_queued only under blkcg->lock
(like rest of the stats). As we are holding blkcg->lock, none of the
tg/blkg can go away, so no rcu stuff should be required.

Thanks
Vivek

      parent reply	other threads:[~2012-09-04 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-31  5:15 [PATCH V2] block/throttle: Add IO throttled information in blkio.throttle Tao Ma
2012-09-01  1:05 ` Tejun Heo
2012-09-01 13:58   ` Tao Ma
2012-09-04 19:13     ` Tejun Heo
2012-09-04 13:35 ` Vivek Goyal
2012-09-04 14:12   ` Tao Ma
2012-09-04 14:23     ` Vivek Goyal
2012-09-04 14:45     ` Vivek Goyal [this message]

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=20120904144510.GA2603@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tm@tao.ma \
    /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 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).