]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ptr_ring: __ptr_ring_zero_tail micro optimization
authorMichael S. Tsirkin <mst@redhat.com>
Sat, 27 Sep 2025 12:29:35 +0000 (08:29 -0400)
committerJakub Kicinski <kuba@kernel.org>
Tue, 30 Sep 2025 01:13:10 +0000 (18:13 -0700)
commitc39d6d4d933381714b6e5d735545256558ec6c05
tree6980bc86e94659c058f7e8d912204cadeb74c0ac
parente8c4840d0c198215866728626b5c197048d4368b
ptr_ring: __ptr_ring_zero_tail micro optimization

__ptr_ring_zero_tail currently does the - 1 operation twice:
- during initialization of head
- at each loop iteration

Let's just do it in one place, all we need to do
is adjust the loop condition. this is better:
- a slightly clearer logic with less duplication
- uses prefix -- we don't need to save the old value
- one less - 1 operation - for example, when ring is empty
  we now don't do - 1 at all, existing code does it once

Text size shrinks from 15081 to 15050 bytes.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/bcd630c7edc628e20d4f8e037341f26c90ab4365.1758976026.git.mst@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/ptr_ring.h