From 61d82b0794197af2a27f4bb7144d2bef164f25b3 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 8 Apr 2020 16:07:57 +0000 Subject: [PATCH] Some fixes for SRCU in the LinuxKPI. - Make sure to use READ_ONCE() when deferring variables. - Remove superfluous zero initializer. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/srcu.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/srcu.h b/sys/compat/linuxkpi/common/include/linux/srcu.h index b5cebe12365..58c9800511b 100644 --- a/sys/compat/linuxkpi/common/include/linux/srcu.h +++ b/sys/compat/linuxkpi/common/include/linux/srcu.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015-2017 Mellanox Technologies, Ltd. + * Copyright (c) 2015-2020 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,13 +29,16 @@ #ifndef _LINUX_SRCU_H_ #define _LINUX_SRCU_H_ +#include + struct srcu_struct { }; -#define srcu_dereference(ptr,srcu) ((__typeof(*(ptr)) *)(ptr)) +#define srcu_dereference(p, srcu) \ + ((__typeof(*(p)) *)READ_ONCE(p)) #define DEFINE_STATIC_SRCU(name) \ - static struct srcu_struct name = {} + static struct srcu_struct name /* prototypes */