linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Nikanth Karthikesan <knikanth@suse.de>
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 09:35:57 +0200	[thread overview]
Message-ID: <20090416073557.GU5178@kernel.dk> (raw)
In-Reply-To: <200904161254.41433.knikanth@suse.de>

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? 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.

-- 
Jens Axboe


  reply	other threads:[~2009-04-16  7:36 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 [this message]
2009-04-16  9:15   ` Nikanth Karthikesan
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=20090416073557.GU5178@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=knikanth@suse.de \
    --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).