Lines Matching +full:cpu +full:- +full:capacity
12 (1) Convenience functions for determining information about power-of-2 sized
27 (*) Measuring power-of-2 buffers.
30 - The producer.
31 - The consumer.
41 (1) A 'head' index - the point at which the producer inserts items into the
44 (2) A 'tail' index - the point at which the consumer finds the next item in
58 than 1 if multiple items or variable-sized items are to be included in the
63 Measuring power-of-2 buffers
66 Calculation of the occupancy or the remaining capacity of an arbitrarily sized
68 modulus (divide) instruction. However, if the buffer is of a power-of-2 size,
69 then a much quicker bitwise-AND instruction can be used instead.
71 Linux provides a set of macros for handling power-of-2 circular buffers. These
78 (#) Measure the remaining capacity of a buffer::
102 (#) Measure the non-wrapping occupancy of a buffer::
110 Each of these macros will nominally return a value between 0 and buffer_size-1,
115 but the consumer may still be depleting the buffer on another CPU and
123 producer may still be filling the buffer on another CPU and moving the
131 independent and may be made on different CPUs - so the result in such a
152 ------------
158 unsigned long head = buffer->head;
160 unsigned long tail = READ_ONCE(buffer->tail);
162 if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
168 smp_store_release(buffer->head,
169 (head + 1) & (buffer->size - 1));
178 This will instruct the CPU that the contents of the new item must be written
180 CPU that the revised head index must be written before the consumer is woken.
186 element currently being read by the consumer. Therefore, the unlock-lock
193 ------------
200 unsigned long head = smp_load_acquire(buffer->head);
201 unsigned long tail = buffer->tail;
203 if (CIRC_CNT(head, tail, buffer->size) >= 1) {
211 smp_store_release(buffer->tail,
212 (tail + 1) & (buffer->size - 1));
217 This will instruct the CPU to make sure the index is up to date before reading
218 the new item, and then it shall make sure the CPU has finished reading the item
225 The smp_load_acquire() additionally forces the CPU to order against
236 See also Documentation/memory-barriers.txt for a description of Linux's memory