* counting examples
@ 2018-07-05 20:09 Imre Palik
2018-07-05 23:05 ` Paul E. McKenney
0 siblings, 1 reply; 2+ messages in thread
From: Imre Palik @ 2018-07-05 20:09 UTC (permalink / raw)
To: paulmck, perfbook
Hi All,
first of all, thanks for the great book.
I have some doubts about some of the counting examples. Namely, those
that implement inc_count() as a simple increment operation. If there
is nothing to restrain the compiler/linker, they can possibly merge
several increments together, or optionally keep the counter value in a
register.
Of course, this won't happen with counttorture, because of the
barrier() in the loop. But I wonder if that barrier() should be part
of inc_count() instead. What do you think?
Thanks,
Imre
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: counting examples
2018-07-05 20:09 counting examples Imre Palik
@ 2018-07-05 23:05 ` Paul E. McKenney
0 siblings, 0 replies; 2+ messages in thread
From: Paul E. McKenney @ 2018-07-05 23:05 UTC (permalink / raw)
To: Imre Palik; +Cc: perfbook
On Thu, Jul 05, 2018 at 10:09:49PM +0200, Imre Palik wrote:
> Hi All,
>
> first of all, thanks for the great book.
On behalf of all of its contributors, glad you like it!
> I have some doubts about some of the counting examples. Namely, those
> that implement inc_count() as a simple increment operation. If there
> is nothing to restrain the compiler/linker, they can possibly merge
> several increments together, or optionally keep the counter value in a
> register.
>
> Of course, this won't happen with counttorture, because of the
> barrier() in the loop. But I wonder if that barrier() should be part
> of inc_count() instead. What do you think?
I actually put this on my todo list as a results of the C++ discussion,
but given that I am in the process of (almost) rewriting Linux-kernel
RCU, it will take time to get to it. So if you are interested, I would
welcome a patch that added READ_ONCE() and WRITE_ONCE as appropriate.
If you are curious about the historical perspective, some of the counter
code predates ACCESS_ONCE() -- let alone READ_ONCE() and WRITE_ONCE()
-- in the Linux kernel. Compilers have gotten more aggressive over
the decades. ;-)
Thanx, Paul
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-05 23:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-05 20:09 counting examples Imre Palik
2018-07-05 23:05 ` 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