mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Andi Kleen <ak@suse.de>
Cc: lkml <linux-kernel@vger.kernel.org>,
	tim@physik3.uni-rostock.de, george anzinger <george@mvista.com>,
	albert@users.sourceforge.net, Ulrich.Windl@rz.uni-regensburg.de,
	clameter@sgi.com, Len Brown <len.brown@intel.com>,
	linux@dominikbrodowski.de, David Mosberger <davidm@hpl.hp.com>,
	paulus@samba.org, schwidefsky@de.ibm.com, jimix@us.ibm.com,
	keith maanthey <kmannth@us.ibm.com>, greg kh <greg@kroah.com>,
	Patricia Gaughen <gone@us.ibm.com>,
	Chris McDermott <lcm@us.ibm.com>
Subject: Re: [RFC] New Time of day proposal (updated 9/2/04)
Date: Wed, 08 Sep 2004 11:25:57 -0700	[thread overview]
Message-ID: <1094667956.29408.86.camel@cog.beaverton.ibm.com> (raw)
In-Reply-To: <20040904130022.GB21912@wotan.suse.de>

On Sat, 2004-09-04 at 06:00, Andi Kleen wrote:
> On Fri, Sep 03, 2004 at 01:11:58PM -0700, john stultz wrote:
> > The timeofday_hook (should be timeofday_interrupt_hook, my bad) is
> > called by the semi-periodic-irregular-interval(also known as "timer")
> > interrupt. Its what does the housekeeping for all the timeofday code so
> > we don't run into a counter overflow. 
> > 
> > monotonic_clock() is an accessor that returns the amount of time that
> > has been accumulated since boot in nanoseconds. 
> 
> Ok, but you need different low level drivers for those.  The TSC is not
> stable enough as a long term time source, but it is best&fastest for
> the offset calculation between timer interrupts.
> 
> Or you would need to make the single driver handle both TSC
> and HPET/PIT, which would probably defeat the extensibility of
> the new architecture. Even in that case you would need different
> read() calls.

Well, actually with this design the TSC, when used, would be the long
term timesource. Interpolating between two timesources (timer ticks and
TSC) is what causes a great deal of the time trouble on i386. You get
into the issue of: "which one do you trust?" (some laptops change freq
w/o notification, while other desktops have buggy interval timers) which
takes us then into the problems lost-tick detection brought up. 

Instead, I'm suggesting we make our best guess, and then select a
timesource to trust. Make it trivial for folks to work around bad
selections (say a buggy HPET shows up, have the user echo "acpi-pm" >
/sysfs/something/timesource, or use the "clock=" boot option), and make
it easy to add blacklist/sanity checking code to the timesource init
functions (so it does the right thing automatically in the next
release). 

So basically, rather then confuse the core code, my plan is to leave it
up to the timesource code to ensure they provide good time. 


> > > Hmm, I am missing something here, but how do you handle
> > > the case where the timer interrupt uses HPET, but the offset
> > > from last timer interrupt is determined using TSC.  But
> > > some machines don't have a reliable TSC, so it may need
> > > to use a different "offset" source.
> > > 
> > > I guess you would need two different drivers here? 
> > 
> > Not really, this is very doable. Time of day is now completely isolated
> > from the timer interrupt code, so it doesn't care who calls the
> > timeofday_interrupt_hook (HPET's interrupt or the i8253's interrupt
> > could do it). Also it doesn't have to be regular or exact, just frequent
> > enough that the timesource doesn't overflow.
> 
> I am not talking about the interrupt source here, just from which
> time source xtime is refreshed.

Well, at the end of the day, the hope is xtime is removed completely and
replaced w/ get_lowres_timestamp()/get_lowres_timeofday().  However,
right now instead of making a patch with thousands of single line
replacements, I'm just updating xtime in timer_interrupt_hook().

I'm not sure if that answers your question, so let me know if I need to
clarify myself further. 

> > > > o vsyscalls/userspace gettimeofday()
> > > > 	- Mark functions and data w/  __vsyscall attribute
> > > > 	- Use linker to put all __vsyscall data in the same set of pages
> > > 
> > > That won't work because the kernel needs to write to 
> > > these variables (e.g. to update the wall time from the interrupt
> > > handler). So in general you need two different mappings, one
> > > read only for user space and another writable one for the kernel.
> > 
> > Well, I was thinking about this and I don't see why the kernel and
> > userspace can't share the same data and functions for read only access?
> 
> For reading only kernel & user could probably share, although
> you may run into some interesting problems on architecturs
> that use truly different "segments" for user and kernel space
> (like sparc64 or m68k or possibly s390) 
> 
> > Why exactly does it need to be mapped twice? We only write to the data
> > from kernel mode using different functions, so the same symbols should
> > be usable. 
> 
> The kernel needs to write too. And at least on x86 there
> is no way to make a page read only for user space and writable
> for kernel space on the same mapping.

Ah! You're right. I was confusing page permission semantics w/ file
permissions (ie: permissions don't affect kernel mode, just user mode). 

That does throw a wrench in the simplicity of my design. I *really*
would like to avoid the extended linker trickery that x86-64 has, but it
may be necessary in the end.

> > the simplest way to use ANY time source, no matter how strange.
> > cycle_t's are basically magic cookies given by the timesource that can
> > be manipulated generically and converted into nanoseconds. It is likely
> > an over-virtualization, but I'd prefer to keep things general and
> > flexible until more arch maintainers tell me its unnecessary.
> 
> Sounds like a redundancy with the cputime type the s390 people did.
> I don't think we should have two ADTs who do such similar things.

Hmm. I should look into that. Thanks for the heads up.

And once again, thanks for the feedback.
-john


      parent reply	other threads:[~2004-09-08 18:34 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-02 21:07 john stultz
2004-09-02 21:09 ` [RFC][PATCH] new timeofday core subsystem (v.A0) john stultz
2004-09-02 21:11   ` [RFC][PATCH] new timeofday i386 hooks (v.A0) john stultz
2004-09-02 21:12     ` [RFC][PATCH] new timeofday i386 timesources (v.A0) john stultz
2004-09-03  1:44     ` [RFC][PATCH] new timeofday i386 hooks (v.A0) George Anzinger
2004-09-03  2:06       ` john stultz
2004-09-03  8:07       ` Ulrich Windl
2004-09-03 18:09         ` George Anzinger
2004-09-02 22:19   ` [RFC][PATCH] new timeofday core subsystem (v.A0) Christoph Lameter
2004-09-02 22:28     ` john stultz
2004-09-02 22:42       ` Christoph Lameter
2004-09-02 23:14         ` john stultz
2004-09-02 23:39           ` Christoph Lameter
2004-09-03  0:07             ` john stultz
2004-09-03  0:47               ` Christoph Lameter
2004-09-03  1:30                 ` john stultz
2004-09-03  7:43                   ` George Anzinger
2004-09-03 19:32                     ` john stultz
2004-09-03 16:18                   ` Christoph Lameter
2004-09-03 21:00                     ` john stultz
2004-09-03 22:04                       ` Christoph Lameter
2004-09-03 23:00                         ` john stultz
2004-09-04  0:11                           ` Christoph Lameter
2004-09-03  1:39   ` George Anzinger
2004-09-03  1:58     ` john stultz
2004-09-03  6:42     ` Albert Cahalan
2004-09-03  7:24       ` George Anzinger
2004-09-03 19:27         ` john stultz
2004-09-03 22:10           ` George Anzinger
2004-09-03 23:32             ` john stultz
2004-09-04  0:02               ` George Anzinger
2004-09-08 18:07                 ` john stultz
2004-09-09  0:08                   ` George Anzinger
2004-09-09  0:51                     ` john stultz
2004-09-09  3:14                       ` Christoph Lameter
2004-09-09  3:32                         ` john stultz
2004-09-09  4:31                           ` George Anzinger
2004-09-09  6:37                             ` Jesse Barnes
2004-09-09  8:09                               ` George Anzinger
2004-09-09 19:07                             ` john stultz
2004-09-09 20:49                               ` George Anzinger
2004-09-13 21:29                                 ` Christoph Lameter
2004-09-13 22:25                                   ` john stultz
2004-09-13 22:45                                     ` Christoph Lameter
2004-09-14  6:53                                       ` Ulrich Windl
2004-09-14 17:49                                     ` Christoph Lameter
2004-09-15  0:57                                       ` George Anzinger
2004-09-15  3:32                                         ` Christoph Lameter
2004-09-15  8:04                                           ` George Anzinger
2004-09-15  8:54                                             ` Dominik Brodowski
2004-09-15 17:54                                               ` George Anzinger
2004-09-15  9:12                                             ` Andi Kleen
2004-09-15 15:46                                             ` Christoph Lameter
2004-09-15 18:00                                               ` George Anzinger
2004-09-15 18:28                                                 ` Christoph Lameter
2004-09-15  6:46                                         ` Christoph Lameter
2004-09-15 16:32                                           ` john stultz
2004-09-15 16:46                                             ` Christoph Lameter
2004-09-15 17:13                                               ` john stultz
2004-09-15 17:30                                                 ` Christoph Lameter
2004-09-15 18:48                                                   ` john stultz
2004-09-15 19:58                                                     ` George Anzinger
2004-09-15 20:20                                                     ` Christoph Lameter
2004-09-16  7:02                                                     ` Ulrich Windl
2004-09-03 19:18       ` john stultz
2004-09-02 22:09 ` [RFC] New Time of day proposal (updated 9/2/04) Christoph Lameter
2004-09-02 22:22   ` john stultz
2004-09-02 22:47     ` Christoph Lameter
2004-09-03  9:54 ` Dominik Brodowski
2004-09-03 19:41   ` john stultz
2004-09-03 20:26     ` Dominik Brodowski
2004-09-03 21:05       ` john stultz
2004-09-06  6:26       ` Ulrich Windl
2004-09-06 11:56         ` Alan Cox
2004-09-07 16:14         ` Christoph Lameter
2004-09-03 15:17 ` Andi Kleen
2004-09-03 20:11   ` john stultz
2004-09-04 13:00     ` Andi Kleen
2004-09-07 16:10       ` Christoph Lameter
2004-09-07 18:24         ` George Anzinger
2004-09-07 20:55           ` Christoph Lameter
2004-09-07 21:42             ` George Anzinger
2004-09-08  6:26           ` Ulrich Windl
2004-09-08 18:25       ` john stultz [this message]

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=1094667956.29408.86.camel@cog.beaverton.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=Ulrich.Windl@rz.uni-regensburg.de \
    --cc=ak@suse.de \
    --cc=albert@users.sourceforge.net \
    --cc=clameter@sgi.com \
    --cc=davidm@hpl.hp.com \
    --cc=george@mvista.com \
    --cc=gone@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=jimix@us.ibm.com \
    --cc=kmannth@us.ibm.com \
    --cc=lcm@us.ibm.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.de \
    --cc=paulus@samba.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=tim@physik3.uni-rostock.de \
    /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

all inboxes | Powered by JetHome®