From: Nikanth Karthikesan <knikanth@suse.de>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] [RFC] make hd_struct->in_flight atomic to avoid diskstat corruption
Date: Thu, 16 Apr 2009 14:45:03 +0530 [thread overview]
Message-ID: <200904161445.03955.knikanth@suse.de> (raw)
In-Reply-To: <20090416073557.GU5178@kernel.dk>
On Thursday 16 April 2009 13:05:57 Jens Axboe wrote:
> On Thu, Apr 16 2009, Nikanth Karthikesan wrote:
> > The disk statistics exported to userspace through proc and sysfs are
> > not protected by locks to avoid performance overhead. Since most of
> > the statistics are maintained in the per_cpu struct disk_stats, the
> > chances of them getting corrupted is negligible. But the in_flight
> > counter, that records the no of requests currently in progress is not
> > per-cpu. This increases the chance of it getting corrupted. And
> > corruption of this value would result in visibly distorted statistics
> > such as negative in_flight. This can be avoided by making this field
> > atomic.
>
> Hmm. Did you observe this behaviour?
Sorry, not on current kernels. But on a very old 2.6.5 kernel.
Reading Documentation/iostats.txt and the changelog of commit
e71bf0d0ee89e51b92776391c5634938236977d5 made me assume that this could be a
problem even today.
> A quick glance at the code reveals
> that the callers of part_inc_in_flight() and part_dec_in_flight() in the
> block layer are always done under the queue lock. Ditto
> part_round_stats(), which calls part_round_stats_single() and also needs
> protection for in_flight.
>
> That basically just leaves the code reading this out and reporting, and
> driver calls to part_round_stats(). I'd suggest looking there instead,
> we're not going to make ->in_flight an atomic just because of some
> silliness there that could be fixed.
Isn't this also true for the stats protected by the part_stat_lock()? Only
places where we are only reading seems to be called without the queue lock.
Thanks
Nikanth
next prev parent reply other threads:[~2009-04-16 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-16 7:24 [PATCH] [RFC] make hd_struct->in_flight atomic to avoid diskstat corruption Nikanth Karthikesan
2009-04-16 7:35 ` Jens Axboe
2009-04-16 9:15 ` Nikanth Karthikesan [this message]
2009-04-16 14:40 ` Tejun Heo
2009-04-16 16:32 ` Jens Axboe
2009-04-19 8:51 ` Tejun Heo
2009-04-21 7:31 ` Jens Axboe
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=200904161445.03955.knikanth@suse.de \
--to=knikanth@suse.de \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.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 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).