mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [patch] Re: using long instead of atomic_t when only set/read is required
@ 2008-03-05 17:07 Matti Linnanvuori
  0 siblings, 0 replies; 23+ messages in thread
From: Matti Linnanvuori @ 2008-03-05 17:07 UTC (permalink / raw)
  To: linux-kernel

On Mon, 2008-03-03 at 18:24 +0100, Pavel Machek wrote:
> "For all properly-aligned pointer and integral types other than short or
> long long..."

As far as I know, Linux kernel supports Alpha that does not have atomic
updates of integral types with less than 32 bits.


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

^ permalink raw reply	[flat|nested] 23+ messages in thread
* using long instead of atomic_t when only set/read is required (was Re: [Bug 10030] Suspend doesn't work when SD card is inserted)
@ 2008-02-25  9:03 Pavel Machek
  2008-02-25 14:46 ` Alan Stern
  0 siblings, 1 reply; 23+ messages in thread
From: Pavel Machek @ 2008-02-25  9:03 UTC (permalink / raw)
  To: Alan Stern, zdenek.kabelac, davem
  Cc: Rafael J. Wysocki, Pierre Ossman, Zdenek Kabelac,
	Kernel development list, pm list

Hi!

Alan thinks that `subj` is correct...

> > > > At the very least, you'd need rmb() before reading it and wmb() after
> > > > writing to it, but I'm not sure if that's enough on every obscure
> > > > architecture out there.
> > > 
> > > No, neither one is needed because of the way suspending_task is used.  
> > > 
> > > It's not necessary for a reader R to see the variable's actual value;  
> > > all R needs to know is whether or not suspending_task is equal to R.  
> > > Since the only process which can set suspending_task to R is R itself,
> > > and since R will set suspending_task back to NULL before releasing the
> > > write lock on pm_sleep_rwsem, there's never any ambiguity.
> > 
> > Subtle.
> > 
> > Very subtly wrong ;-).
> > 
> > imagine suspending_task == 0xabcdef01. Now task "R" with current ==
> > 0xabcd0000 reads suspending_task while the other cpu is writing to it,
> > and sees 0xabcd0000 (0xef01 was not yet written) -- and mistakenly
> > believes that  "R" == suspending_task.
> 
> I always thought that reads and writes of pointers are atomic, just 
> like reads and writes of longs.  Is that wrong?

...but I'm not that sure. Can someone clarify?

I guess it only works as long as longs are aligned? Should it be
written down to atomic_ops.txt?
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

end of thread, other threads:[~2008-03-06 16:27 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-05 17:07 [patch] Re: using long instead of atomic_t when only set/read is required Matti Linnanvuori
  -- strict thread matches above, loose matches on Subject: below --
2008-02-25  9:03 using long instead of atomic_t when only set/read is required (was Re: [Bug 10030] Suspend doesn't work when SD card is inserted) Pavel Machek
2008-02-25 14:46 ` Alan Stern
2008-03-03 12:08   ` [patch] Re: using long instead of atomic_t when only set/read is required Pavel Machek
2008-03-03 15:42     ` Alan Stern
2008-03-03 15:53       ` Alan Cox
2008-03-03 17:11         ` Alan Stern
2008-03-03 17:26           ` Linus Torvalds
2008-03-03 17:44             ` Pavel Machek
2008-03-03 19:27               ` Alan Stern
2008-03-06 15:58             ` Mark Lord
2008-03-06 16:11               ` Linus Torvalds
2008-03-06 16:27                 ` Mark Lord
2008-03-03 17:16         ` Nick Piggin
2008-03-03 17:31           ` Paul E. McKenney
2008-03-03 17:33           ` Alan Cox
2008-03-03 17:22       ` Paul E. McKenney
2008-03-03 15:48     ` Alan Cox
2008-03-03 17:24       ` Pavel Machek
2008-03-03 20:27         ` Rafael J. Wysocki
2008-03-03 21:12           ` Paul E. McKenney
2008-03-03 22:23           ` Linus Torvalds
2008-03-04 23:32         ` Peter Hartley
2008-03-04 23:54           ` Rafael J. Wysocki
2008-03-05  0:26             ` Paul E. McKenney

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®