On Wed, Dec 18, 2024 at 11:10:01AM -0500, Waiman Long wrote:
On 12/18/24 10:45 AM, Paul E. McKenney wrote:The state space includes the set of possible values that might be stored
On Tue, Dec 17, 2024 at 10:30:39PM -0500, Waiman Long wrote:I don't quite get what you mean by "state space".
For seqcount, its actual value isn't important. What is important is whetherBut why expand the state space?
the value changes and whether it is even or odd. So even if store tearing is
happening, it shouldn't affect its operation. I doubt we need to use
WRITE_ONCE() here. Could you come up with a scenario where store tearing
will make it behave incorrectly?
in .sequence at any given point in time. So if you allow the compiler to
tear the store, you are increasing the number of values that a concurrent
reader can return, and thus also increasing the number of states that must
be considered. On the other hand, if you use WRITE_ONCE() to constrain
the compiler to do a single store, then you don't have to even worry
about the added states due to these partial updates.
One other potential optimization is using the variable for scratch storageAlso, there are potentially "optimizations" other than store tearing.All the inc's are bounded by smp_wmb()'s which should limit the kind of
No, I haven't seen them yet, but then again, there were a great many
optimizations that were not being used back when I started coding C.
optimizations that can be done by the compiler. That is why I don't see a
need to use WRITE_ONCE() here. Of course, there may be some corner cases
that I may miss. So I ask for whether such a case exists.
immediately prior to the update, which could store any value there.
I haven't seen this myself, but the standard permits it, and in some
cases register pressure might encourage it.
And who knows what else our creative compiler writers will come up with?
Thanx, Paul