lkml.org 
[lkml]   [2010]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Document Linux's circular buffering capabilities
David Howells wrote:
> Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
>> "...do this" could be misunderstood as "use a modulus instruction",
...
> How about:
>
> Calculation of the occupancy or the remaining capacity of an
> arbitrarily sized circular buffer would normally be a slow operation,
> requiring the use of a modulus (divide) instruction. However, if the
> buffer is of a power-of-2 size,
[...]

Yep.

>> I don't understand why ACCESS_ONCE is needed here. The CIRC_SPACE and
>> CIRC_CNT macros do not look at head and tail more than once.
>
> In this example they don't, but say someone wants to read several elements
> from the buffer, they might end up accessing their copy of head several times.

Would you agree to add a quick note that these examples are simple
enough to not strictly require ACCESS_ONCE but are meant to show what
more general code would have to do? Else a reader might be left puzzled
why he can't see in the example code the circumstances which require
ACCESS_ONCE and may remain unsure about where to use it in his own works...

(BTW, good that I came across your documentation posting. This twist
with possibly multiple loads was not apparent to me too. I am going to
have to have another look at some driver code with this in mind...)
--
Stefan Richter
-=====-==-=- --== -==-=
http://arcgraph.de/sr/


\
 
 \ /
  Last update: 2010-03-13 10:29    [W:0.091 / U:2.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site