Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Segher Boessenkool
Date: Monday, August 20, 2007 - 3:04 pm

>> Right. ROTFL... volatile actually breaks atomic_t instead of making 

Nah, this whole argument is flawed -- "without volatile" we still
*cannot* "increment the memory directly".  On x86, you need a lock
prefix; on other archs, some other mechanism to make the memory
increment an *atomic* memory increment.

And no, RMW on MMIO isn't "problematic" at all, either.

An RMW op is a read op, a modify op, and a write op, all rolled
into one opcode.  But three actual operations.


The advantages of asm code for atomic_{read,set} are:
1) all the other atomic ops are implemented that way already;
2) you have full control over the asm insns selected, in particular,
    you can guarantee you *do* get an atomic op;
3) you don't need to use "volatile <data>" which generates
    not-all-that-good code on archs like x86, and we want to get rid
    of it anyway since it is problematic in many ways;
4) you don't need to use *(volatile <type>*)&<data>, which a) doesn't
    exist in C; b) isn't documented or supported in GCC; c) has a recent
    history of bugginess; d) _still uses volatile objects_; e) _still_
    is problematic in almost all those same ways as in 3);
5) you can mix atomic and non-atomic accesses to the atomic_t, which
    you cannot with the other alternatives.

The only disadvantage I know of is potentially slightly worse
instruction scheduling.  This is a generic asm() problem: GCC
cannot see what actual insns are inside the asm() block.


Segher

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Christoph Lameter, (Tue Aug 14, 4:14 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 11:31 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Paul E. McKenney, (Wed Aug 15, 11:57 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 1:47 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 1:52 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 2:05 pm)
[No subject], Satyam Sharma, (Wed Aug 15, 5:36 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:23 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:26 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Wed Aug 15, 6:30 pm)
Re: , Segher Boessenkool, (Wed Aug 15, 6:38 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Thu Aug 16, 12:32 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Thu Aug 16, 12:33 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Paul E. McKenney, (Thu Aug 16, 10:18 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Geert Uytterhoeven, (Thu Aug 16, 11:42 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 10:37 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 3:29 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 3:49 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Fri Aug 17, 4:55 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Christoph Lameter, (Fri Aug 17, 6:24 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Mon Aug 20, 3:04 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Mon Aug 20, 4:02 pm)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Tue Aug 21, 7:39 am)
Re: [PATCH 0/24] make atomic_read() behave consistently ac ..., Segher Boessenkool, (Tue Aug 21, 7:48 am)
Re: [PATCH] i386: Fix a couple busy loops in mach_wakecpu. ..., Christoph Lameter, (Fri Aug 24, 10:06 am)