summaryrefslogtreecommitdiff
path: root/Documentation/riscv
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-11-15 13:30:32 +0000
committerDavid Howells <dhowells@redhat.com>2019-10-31 15:12:34 +0000
commit8cefc107ca54c8b06438b7dc9cc08bc0a11d5b98 (patch)
tree3e01800bf202ddff7841a717ddc47d1e5771768a /Documentation/riscv
parentf94df9890e98f2090c6a8d70c795134863b70201 (diff)
downloadlinux-rpi-8cefc107ca54c8b06438b7dc9cc08bc0a11d5b98.tar.gz
linux-rpi-8cefc107ca54c8b06438b7dc9cc08bc0a11d5b98.tar.bz2
linux-rpi-8cefc107ca54c8b06438b7dc9cc08bc0a11d5b98.zip
pipe: Use head and tail pointers for the ring, not cursor and length
Convert pipes to use head and tail pointers for the buffer ring rather than pointer and length as the latter requires two atomic ops to update (or a combined op) whereas the former only requires one. (1) The head pointer is the point at which production occurs and points to the slot in which the next buffer will be placed. This is equivalent to pipe->curbuf + pipe->nrbufs. The head pointer belongs to the write-side. (2) The tail pointer is the point at which consumption occurs. It points to the next slot to be consumed. This is equivalent to pipe->curbuf. The tail pointer belongs to the read-side. (3) head and tail are allowed to run to UINT_MAX and wrap naturally. They are only masked off when the array is being accessed, e.g.: pipe->bufs[head & mask] This means that it is not necessary to have a dead slot in the ring as head == tail isn't ambiguous. (4) The ring is empty if "head == tail". A helper, pipe_empty(), is provided for this. (5) The occupancy of the ring is "head - tail". A helper, pipe_occupancy(), is provided for this. (6) The number of free slots in the ring is "pipe->ring_size - occupancy". A helper, pipe_space_for_user() is provided to indicate how many slots userspace may use. (7) The ring is full if "head - tail >= pipe->ring_size". A helper, pipe_full(), is provided for this. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'Documentation/riscv')
0 files changed, 0 insertions, 0 deletions