public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* CONFIG_PRINTK_TIME woes
@ 2005-08-18 18:47 Luck, Tony
  2005-08-21  9:13 ` Andrew Morton
  0 siblings, 1 reply; 24+ messages in thread
From: Luck, Tony @ 2005-08-18 18:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason Uhlenkott

It has been pointed out to me that ia64 doesn't boot
with CONFIG_PRINTK_TIME=y.  The issue is the call to
sched_clock() ... which on ia64 accesses some per-cpu
data to adjust for possible variations in processor
speed between different cpus.  Since the per-cpu page
is not set up for the first few printk() calls, we die.

Is this an issue on any other architecture?  Most versions
of sched_clock() seem to just scale jiffies into nanoseconds,
so I guess they don't.  s390, sparc64, x86 and x86_64 all
have more sophisticated versions but they don't appear to me
to have limitations on how early they might be called.

Possible solutions:

1) Fix ia64 version of sched_clock() to check whether
the per-cpu page hase been initialized before using it.

I don't like this solution as it will make sched_clock()
slower for its primary uses in kernel/sched.c ... none of
which can be called before the per-cpu area is initialized.


2) Add some test to the printk() path along the lines of:

  t = (can_call_sched_clock) ? sched_clock() : 0;

This is somewhat ugly ... perhaps too unpleasant for words in
that can_call_sched_clock is a per-cpu concept!

3) Make the printk() code get the time in some other way.

Using sched_clock() here seems wrong.  The ia64 version
has a big fat comment about not comparing the results of
two calls from different cpus ... but since printk() calls
can come from any cpu ... it seems likely that a user who
turns on PRINTK_TIME might subtract timestamps from two
lines to see how long it was between the messages.  This
could have significant error on a system that has been up
for a long time.

But I don't have a better suggestion from existing code.  I
assume that sched_clock() was picked as it is both fast and
lockless.

-Tony


^ permalink raw reply	[flat|nested] 24+ messages in thread
* RE: CONFIG_PRINTK_TIME woes
@ 2005-08-23 14:07 Luck, Tony
  0 siblings, 0 replies; 24+ messages in thread
From: Luck, Tony @ 2005-08-23 14:07 UTC (permalink / raw)
  To: Tony Lindgren, Andrew Morton; +Cc: linux-kernel, jasonuhl

>I'd hate to have to test for something for CONFIG_PRINTK_TIME
>every time sched_clock() is being called.

Me too.

>The quick fix would seem to be to only allow CONFIG_PRINTK_TIME
>from kernel cmdline to make it happen a bit later. So basically
>make int printk_time = 0 until command line is evaluated.

Good thought, but this won't work for ia64 in the hot-plug cpu case.
There are a couple of printk() calls by new cpus as they boot before
they have set-up their per-cpu areas.  So there is no global state
that can be checked to decide whether it is safe for printk() to
call sched_clock().

-Tony

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2005-08-24  0:36 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18 18:47 CONFIG_PRINTK_TIME woes Luck, Tony
2005-08-21  9:13 ` Andrew Morton
2005-08-21  9:16   ` Andrew Morton
2005-08-21  9:27     ` Nick Piggin
2005-08-21  9:32       ` Andrew Morton
2005-08-21 11:25         ` Nick Piggin
2005-08-21 18:01           ` Andrew Morton
2005-08-24  0:04             ` Tim Bird
2005-08-22 17:42     ` tony.luck
2005-08-22 17:50       ` Andrew Morton
2005-08-22 20:52         ` tony.luck
2005-08-22 20:20       ` David S. Miller
2005-08-22 20:33         ` Jason Uhlenkott
2005-08-22 20:42           ` David S. Miller
2005-08-22 21:15             ` Andrew Morton
2005-08-22 22:33               ` tony.luck
2005-08-22 22:38                 ` Andrew Morton
2005-08-22 23:27                   ` tony.luck
2005-08-23  1:52                     ` Paul Mackerras
2005-08-23 15:01             ` Nick Piggin
2005-08-22 21:10           ` tony.luck
2005-08-24  0:36     ` Tim Bird
2005-08-23  7:18   ` Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2005-08-23 14:07 Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox