All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wedgwood <cw@f00f.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
	Andrew Morton <akpm@osdl.org>, Paul Jackson <pj@sgi.com>,
	PARISC list <parisc-linux@lists.parisc-linux.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: more (insane) jiffies ranting
Date: Sat, 26 Jun 2004 18:55:01 -0700	[thread overview]
Message-ID: <20040627015501.GA14647@taniwha.stupidest.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0406261536590.16079@ppc970.osdl.org>

Continuing my rant...

On Sat, Jun 26, 2004 at 03:48:34PM -0700, Linus Torvalds wrote:

> But for most data structures, the way to control access is either
> with proper locking (at which point they aren't volatile any more)
> or through proper accessor functions (ie "jiffies_64" should
> generally only be accessed with something that understands about
> low/high word and update ordering and re-testing).

I don't entirely buy this.  Right now x86 code just assumes 32-bit
loads are atomic and does them blindly in lots of places (ie. every
user of jiffies just about).

Without the volatile it seems entirely reasonable gcc will produce
correct, but wrong code here so I would argue 'volatile' is a property
of the data in this case.

> I repeat: it is the _code_ that knows about volatile rules, not the
> data structure.

Except as I mentioned we have exceptions to this right now.

As far as I can tell jiffies is a mess (I'm talking mostly ia32 here):

  jiffies_64 is protected by xtime_lock, this is a seqlock_t which
  is IMO overly complicated and unnecessary, and this lock is shared
  for xtime as well

  jiffies_64 could be done locklessly as far as I can tell anyhow.

  jiffies is linker-magic to jiffies_64 and works because a
  little-endian load at the same address gives you the 32 lower bits.
  I'm not opposed to this, but a comment wouldn't kill anyone.

  we also have wall_jiffies which is 32-bit (unsigned long, ia32) and
  is used get the gettimeofday code to detect lost ticks, having
  this as well as jiffies_64 seems overkill

  we do xtime updates w/o a lock on most platforms

Perhaps I misunderstand the code right now, the need for the
complexity and what-not --- but I don't like it.

It's either because it's too complicated or it's not-clear what is
going on, I don't know which one matches reality most closely,
probably the latter.

I know there are NTP implications of this this code but it feels more
like "it happens to work, please don't touch it" rather than anything
clean and well designed.  I'm pretty sure there are some tricky corner
cases and subtle interactions to worry about, especially when we look
at leap-seconds.

Maybe having all this code moved into a single place would help, I'm
not sure, with platform-provided abstraction as required so older
platforms which can't do atomic 64-bit updates will still behave
sanely.

To be quite honest I'd like to see jiffies die and xtime become a
per-cpu thing (if that can be made to work reliably, I have some
concerns), or at least have this option on a platform by platform
basis.



  --cw

  parent reply	other threads:[~2004-06-27  1:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-26 16:08 [PATCH] Fix the cpumask rewrite James Bottomley
2004-06-26 16:32 ` Linus Torvalds
2004-06-26 16:44   ` Linus Torvalds
2004-06-26 16:46   ` James Bottomley
2004-06-26 16:54     ` Linus Torvalds
2004-06-26 17:18       ` James Bottomley
2004-06-26 18:01         ` Linus Torvalds
2004-06-26 18:28           ` Vojtech Pavlik
2004-06-26 18:54             ` Linus Torvalds
2004-06-26 19:02               ` James Bottomley
2004-06-26 19:13                 ` Linus Torvalds
2004-06-26 19:13               ` Vojtech Pavlik
2004-06-26 18:59           ` James Bottomley
2004-06-26 19:11             ` Linus Torvalds
2004-06-26 19:33               ` James Bottomley
2004-06-28 23:16           ` Jonathan Lundell
2004-07-01 13:11       ` Pavel Machek
2004-07-01 14:07         ` [parisc-linux] " Alan Cox
2004-07-01 16:15           ` Linus Torvalds
2004-07-01 16:52             ` Jeff Garzik
2004-07-01 17:42               ` Linus Torvalds
2004-06-26 22:18   ` Chris Wedgwood
2004-06-26 22:48     ` Linus Torvalds
2004-06-26 22:54       ` [parisc-linux] " Alan Cox
2004-06-27  0:05         ` Chris Wedgwood
2004-06-27 12:00           ` Matthias Urlichs
2004-06-27 22:41             ` Chris Wedgwood
2004-06-28  1:24               ` Matthias Urlichs
2004-06-28  5:42                 ` Chris Wedgwood
2004-06-28  6:55                   ` Matthias Urlichs
2004-06-28  7:02                     ` Chris Wedgwood
2004-06-28  7:19                       ` Matthias Urlichs
2004-06-27 14:37           ` Alan Cox
2004-07-01 13:33             ` Pavel Machek
2004-07-01 17:43               ` Chris Wedgwood
2004-06-26 23:37       ` jiffies_64 Chris Wedgwood
2004-06-27  1:55       ` Chris Wedgwood [this message]
2004-06-27 17:39         ` more (insane) jiffies ranting Linus Torvalds
2004-06-27 17:39         ` [parisc-linux] " Linus Torvalds
2004-06-27 17:39         ` Linus Torvalds
2004-06-26 16:32 ` [PATCH] Fix the cpumask rewrite Linus Torvalds

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=20040627015501.GA14647@taniwha.stupidest.org \
    --to=cw@f00f.org \
    --cc=James.Bottomley@SteelEye.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=parisc-linux@lists.parisc-linux.org \
    --cc=pj@sgi.com \
    --cc=torvalds@osdl.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 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.