locking/seqlock: Change __seqprop() to return the function pointer
authorOleg Nesterov <oleg@redhat.com>
Thu, 12 Oct 2023 14:32:27 +0000 (16:32 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 12 Oct 2023 18:18:21 +0000 (20:18 +0200)
commite6115c6f7a0ce3388cc60b69a284facf78b5dbfd
treee459f09c95c11e69c64bcb64bb31b215a5c1cd7f
parentf995443f01b4dbcce723539b99050ce69b319e58
locking/seqlock: Change __seqprop() to return the function pointer

This simplifies the macro and makes it easy to add the new seqprop's
with 2 or more args.

Plus this way we do not lose the type info, the (void*) type cast is
no longer needed.

And the latter reveals the problem: a lot of seqcount_t helpers pass
the "const seqcount_t *s" argument to __seqprop_ptr(seqcount_t *s)
but (before this patch) "(void *)(s)" masked the problem.

So this patch changes __seqprop_ptr() and __seqprop_##lockname##_ptr()
to accept the "const LOCKNAME *s" argument. This is not nice either,
they need to drop the constness on return because these helpers are used
by both the readers and writers, but at least it is clear what's going on.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.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: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/20231012143227.GA16143@redhat.com
include/linux/seqlock.h