git: ada94bf9e8cb - stable/14 - LinuxKPI: Add write_seqcount_invalidate() and seqprop_sequence()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Feb 2024 21:33:05 UTC
The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=ada94bf9e8cb09e61c6c517dadb87fc5ccafa426 commit ada94bf9e8cb09e61c6c517dadb87fc5ccafa426 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2023-12-24 08:19:59 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-02-17 20:58:38 +0000 LinuxKPI: Add write_seqcount_invalidate() and seqprop_sequence() functions to linux/seqlock.h Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42810 (cherry picked from commit 64e30cba3f0432fa684728b67850b6254d3713ea) --- sys/compat/linuxkpi/common/include/linux/seqlock.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/seqlock.h b/sys/compat/linuxkpi/common/include/linux/seqlock.h index a7b9dd12e493..48e42efc10fe 100644 --- a/sys/compat/linuxkpi/common/include/linux/seqlock.h +++ b/sys/compat/linuxkpi/common/include/linux/seqlock.h @@ -31,6 +31,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/cdefs.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/rwlock.h> @@ -84,9 +85,24 @@ seqcount_mutex_init(struct seqcount_mutex *seqcount, void *mutex __unused) struct seqcount_mutex: seqc_write_end \ )(&(s)->seqc) +static inline void +lkpi_write_seqcount_invalidate(seqc_t *seqcp) +{ + atomic_thread_fence_rel(); + *seqcp += SEQC_MOD * 2; +} +#define write_seqcount_invalidate(s) lkpi_write_seqcount_invalidate(&(s)->seqc) + #define read_seqcount_begin(s) seqc_read(&(s)->seqc) #define raw_read_seqcount(s) seqc_read_any(&(s)->seqc) +static inline seqc_t +lkpi_seqprop_sequence(const seqc_t *seqcp) +{ + return (atomic_load_int(__DECONST(seqc_t *, seqcp))); +} +#define seqprop_sequence(s) lkpi_seqprop_sequence(&(s)->seqc) + /* * XXX: Are predicts from inline functions still not honored by clang? */