All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Peter Zijlstra <peterz@infradead.org>
Cc: piotr@hosowicz.com, linux-kernel@vger.kernel.org,
	Jens Axboe <jens.axboe@oracle.com>,
	Divyesh Shah <dpshah@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: BUG: using smp_processor_id() in preemptible [00000000] code: icedove-bin/5449
Date: Tue, 25 May 2010 11:43:47 +0200	[thread overview]
Message-ID: <20100525094347.GA7881@elte.hu> (raw)
In-Reply-To: <1274777422.5882.591.camel@twins>


* Peter Zijlstra <peterz@infradead.org> wrote:

> On Mon, 2010-05-24 at 05:03 +0200, Piotr Hosowicz wrote:
> > [  720.313607] BUG: using smp_processor_id() in preemptible [00000000] code: icedove-bin/5449
> > [  720.313612] caller is native_sched_clock+0x3c/0x68
> > [  720.313616] Pid: 5449, comm: icedove-bin Tainted: P            2.6.34-20100524-0407 #1
> > [  720.313618] Call Trace:
> > [  720.313624]  [<ffffffff811a533b>] debug_smp_processor_id+0xc7/0xe0
> > [  720.313629]  [<ffffffff81009b87>] native_sched_clock+0x3c/0x68
> > [  720.313634]  [<ffffffff81009a4d>] sched_clock+0x9/0xd
> > [  720.313637]  [<ffffffff811823ec>] blk_rq_init+0x92/0x9d
> > [  720.313641]  [<ffffffff81184227>] get_request+0x1bf/0x2c7
> > [  720.313646]  [<ffffffff8118435c>] get_request_wait+0x2d/0x19d 
> 
> This comes from wreckage in the blk tree..
> 
> ---
> commit 9195291e5f05e01d67f9a09c756b8aca8f009089
> Author: Divyesh Shah <dpshah@google.com>
> Date:   Thu Apr 1 15:01:41 2010 -0700
> 
>     blkio: Increment the blkio cgroup stats for real now
>     
>     We also add start_time_ns and io_start_time_ns fields to struct request
>     here to record the time when a request is created and when it is
>     dispatched to device. We use ns uints here as ms and jiffies are
>     not very useful for non-rotational media.
>     
>     Signed-off-by: Divyesh Shah<dpshah@google.com>
>     Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> ---
> 
> +#ifdef CONFIG_BLK_CGROUP
> +static inline void set_start_time_ns(struct request *req)
> +{
> +	req->start_time_ns = sched_clock();
> +}
> +
> +static inline void set_io_start_time_ns(struct request *req)
> +{
> +	req->io_start_time_ns = sched_clock();
> +}
> +#else
> +static inline void set_start_time_ns(struct request *req) {}
> +static inline void set_io_start_time_ns(struct request *req) {}
> +#endif
> 
> ---
> 
> Clearly nobody tested this, and its terribly broken to boot.
> 
> I guess they want something like:
> 
> ---
> Subject: sched_clock: Add local_clock()
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Date: Tue May 25 10:48:51 CEST 2010
> 
> For people who otherwise get to write: cpu_clock(smp_processor_id()),
> there is now: local_clock().

This doesnt fix the whole issue. cpu_clock() is local, while the measurements 
done in the blk code are global ...

While the warning is fixed this way, the far more serious issue is still 
there: time can go backwards if two points of time measurement are on 
different CPUs and can mess up the statistics with negative values, etc...

	Ingo

  parent reply	other threads:[~2010-05-25  9:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-24  3:03 BUG: using smp_processor_id() in preemptible [00000000] code: icedove-bin/5449 Piotr Hosowicz
2010-05-24 17:22 ` Piotr Hosowicz
2010-05-25  8:50 ` Peter Zijlstra
2010-05-25  9:42   ` Piotr Hosowicz
2010-05-25  9:45     ` Peter Zijlstra
2010-05-25  9:43   ` Ingo Molnar [this message]
2010-05-25  9:47     ` Peter Zijlstra
2010-05-25  9:51       ` Peter Zijlstra
2010-05-25  9:57     ` Piotr Hosowicz
2010-05-25 10:00       ` Peter Zijlstra
2010-05-25 10:05         ` Piotr Hosowicz
2010-05-25 10:29           ` Piotr Hosowicz
2010-05-25 14:13             ` Piotr Hosowicz
2010-05-25 14:34               ` Piotr Hosowicz
2010-05-25 14:36                 ` Peter Zijlstra
2010-05-25 14:48                   ` Piotr Hosowicz
2010-05-25 16:15                     ` Peter Zijlstra
2010-05-25 16:47                       ` Piotr Hosowicz
2010-05-26  2:06                         ` Piotr Hosowicz
2010-05-26  2:51                           ` Piotr Hosowicz
2010-05-25 18:07   ` Divyesh Shah
2010-05-25 18:15     ` Piotr Hosowicz
2010-05-25 21:35     ` Peter Zijlstra
2010-05-26 23:02   ` Andrew Morton
2010-05-27  6:46     ` Peter Zijlstra
2010-05-27  6:51       ` Andrew Morton
     [not found]         ` <1274945751.27810.3765.camel@twins>
     [not found]           ` <20100527113340.d4afb8fc.akpm@linux-foundation.org>
2010-05-28 13:13             ` [PATCH] sched_clock: Provide local_clock() and improve documentation Peter Zijlstra
2010-05-28 13:42               ` Johannes Stezenbach
2010-05-28 15:08                 ` Peter Zijlstra
2010-05-28 14:15               ` Piotr Hosowicz
2010-05-28 14:22                 ` Piotr Hosowicz
2010-05-28 18:11               ` Chad Talbott
2010-05-28 18:22                 ` Peter Zijlstra
2010-06-09 10:13               ` [tip:sched/core] sched_clock: Add local_clock() API " tip-bot for Peter Zijlstra
2010-06-01  6:41   ` BUG: using smp_processor_id() in preemptible [00000000] code: icedove-bin/5449 Ingo Molnar
2010-06-01  6:47     ` Jens Axboe
2010-06-01  6:55       ` Ingo Molnar
2010-06-01  7:53         ` Jens Axboe
2010-06-12  1:54           ` Divyesh Shah
2010-06-12  9:42             ` Peter Zijlstra
2010-06-02 11:16         ` blkiocg_update_io_add_stats(): INFO: trying to register non-static key Ingo Molnar
2010-06-02 13:04           ` Jens Axboe
2010-06-11  1:33             ` Divyesh Shah
2010-06-11  7:15             ` Peter Zijlstra
2010-06-11  8:34               ` 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=20100525094347.GA7881@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=dpshah@google.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=piotr@hosowicz.com \
    /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.