]> git.ipfire.org Git - thirdparty/linux.git/commit
locking/seqlock: Propagate 'const' pointers within read-only methods, remove forced...
authorIngo Molnar <mingo@kernel.org>
Fri, 13 Oct 2023 08:15:46 +0000 (10:15 +0200)
committerIngo Molnar <mingo@kernel.org>
Sat, 14 Oct 2023 09:06:15 +0000 (11:06 +0200)
commit886ee55eabac0d46faf8bc0b22207ca2740847ba
treec8a64934abca06127367ecafcb68805206f78688
parentac8b60be078abebc3ab8836f3f0ecac6980e0b4f
locking/seqlock: Propagate 'const' pointers within read-only methods, remove forced type casts

Currently __seqprop_ptr() is an inline function that must chose to either
use 'const' or non-const seqcount related pointers - but this results in
the undesirable loss of 'const' propagation, via a forced type cast.

The easiest solution would be to turn the pointer wrappers into macros that
pass through whatever type is passed to them - but the clever maze of
seqlock API instantiation macros relies on the GCC CPP '##' macro
extension, which isn't recursive, so inline functions must be used here.

So create two wrapper variants instead: 'ptr' and 'const_ptr', and pick the
right one for the codepaths that are const: read_seqcount_begin() and
read_seqcount_retry().

This cleans up type handling and allows the removal of all type forcing.

No change in functionality.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul E. McKenney <paulmck@kernel.org>
include/linux/seqlock.h