srcu: Use export for srcu_struct defined by DEFINE_STATIC_SRCU()
authorAlexander Aring <aahringo@redhat.com>
Wed, 26 Jan 2022 15:03:54 +0000 (10:03 -0500)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 8 Feb 2022 19:10:18 +0000 (11:10 -0800)
commit3bc76a654237d5c71e55e55af511098988f4a631
tree03208c98d5e228369083accbc7e7d1d101bb5a3e
parent53e008fa97771c243f724b98d645cbe22a478441
srcu: Use export for srcu_struct defined by DEFINE_STATIC_SRCU()

If an srcu_struct structure defined by tree SRCU's DEFINE_STATIC_SRCU()
is used by a module, sparse will give the following diagnostic:

sparse: symbol '__srcu_struct_nodes_srcu' was not declared. Should it be static?

The problem is that a within-module DEFINE_STATIC_SRCU() must define
a non-static srcu_struct because it is exported by referencing it in a
special '__section("___srcu_struct_ptrs")'.  This reference is needed
so that module load and unloading can invoke init_srcu_struct() and
cleanup_srcu_struct(), respectively.  Unfortunately, sparse is unaware of
'__section("___srcu_struct_ptrs")', resulting in the above false-positive
diagnostic.  To avoid this false positive, this commit therefore creates
a prototype of the srcu_struct with an "extern" keyword.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/srcutree.h