public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@fb.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: /proc/diskstats buglet
Date: Tue, 26 Aug 2014 08:55:49 -0600	[thread overview]
Message-ID: <53FC9FF5.7060106@fb.com> (raw)
In-Reply-To: <CACVxJT8LW4NOj7ksbcmfHig7MjJTK3AabZbnzWcNPNfznwPKrw@mail.gmail.com>

On 08/26/2014 08:47 AM, Alexey Dobriyan wrote:
> Found and reproduced some time ago, almost forgot about :-)
> 
> In part_round_stats_single(), ->stamp field is written but without
> locking SMP-wise.
> 
>     part->stamp = now;
> 
> So, if two processes read /proc/diskstats, it is possible for "now -
> part->stamp" value to become negative.
> 
> And indeed this can happen:
> 
> now 4294755500, ->stamp 4294755501
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 1950 at block/blk-core.c:1229
> part_round_stats_single+0xc0/0xd0()
>  ...
>  [<ffffffff811963f0>] part_round_stats_single+0xc0/0xd0
>  [<ffffffff81196447>] part_round_stats+0x47/0x70
>  [<ffffffff811a069d>] diskstats_show+0x8d/0x4b0
>  ...
> 
> Dunno how important used fields in /proc/diskstats but they can be
> clearly bogus.

Easiest fix is probably just to do the now - part->stamp math earlier,
and ignore <= 0 instead of just now == part->stamp. I think that should
be good enough for disk stats, and (most importantly), it would avoid
the warning.

Speaking of the warning, I don't see where that is. Where is it from?

-- 
Jens Axboe


  reply	other threads:[~2014-08-26 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26 14:47 /proc/diskstats buglet Alexey Dobriyan
2014-08-26 14:55 ` Jens Axboe [this message]
2014-08-26 15:00   ` Alexey Dobriyan
2014-08-26 15:01     ` Jens Axboe
2014-08-30 21:39       ` Alexey Dobriyan

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=53FC9FF5.7060106@fb.com \
    --to=axboe@fb.com \
    --cc=adobriyan@gmail.com \
    --cc=linux-kernel@vger.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