Re: counting examples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux