rcu: Mollify sparse with RCU guard
authorJohannes Berg <johannes.berg@intel.com>
Mon, 25 Mar 2024 17:39:08 +0000 (18:39 +0100)
committerUladzislau Rezki (Sony) <urezki@gmail.com>
Mon, 15 Apr 2024 17:43:48 +0000 (19:43 +0200)
commit80cd613a9ae091dbf52e27a409d58da988ffc8f3
tree7345fe442e147dea55e07efc77ef5efec0010fc1
parent10c9e40f297d3f1b0d4df6e73618d4466a0b2cfc
rcu: Mollify sparse with RCU guard

When using "guard(rcu)();" sparse will complain, because even
though it now understands the cleanup attribute, it doesn't
evaluate the calls from it at function exit, and thus doesn't
count the context correctly.

Given that there's a conditional in the resulting code:

  static inline void class_rcu_destructor(class_rcu_t *_T)
  {
      if (_T->lock) {
          rcu_read_unlock();
      }
  }

it seems that even trying to teach sparse to evalulate the
cleanup attribute function it'd still be difficult to really
make it understand the full context here.

Suppress the sparse warning by just releasing the context in
the acquisition part of the function, after all we know it's
safe with the guard, that's the whole point of it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
include/linux/rcupdate.h