Re: [RFC 0/3] Examples for the new sparse context trackingfunctionality

From: Johannes Berg
Date: Mon Apr 21 2008 - 11:15:22 EST



> > my_specific_rcu_get() __acquires(RCU) __acquires(specificRCU);
> >
> > and then annotate whatever needs the specific RCU type with
> > __requires(specificRCU)
>
> Cute!!! I didn't realize you could mark a single interface with
> multiple __acquires() markings.
>
> So if there is at least one match, sparse is happy?

No, sparse requires all the given contexts to match. For example, say
you have

#define __requires_rcu __requires(RCU)

#define __requires_special_rcu \
__requires(specificRCU)

#define __acquires_special_rcu \
__acquires(RCU) __acquires(specificRCU)

ï#define __acquires_regular_rcu __acquires(RCU)

Then a function marked "__acquires_special_rcu" with acquire *both*
contexts, and a function marked __requires_special_rcu will require just
the special one. And a function marked __requires_rcu just requires the
regular one. So say you have

rcu_special_lock __acquires_special_rcu
ïrcu_special_unlock __releases_special_rcu
ï
rcu_regular_lock __acquires_rcu
ïrcu_regular_unlock __releases_rcu

rcu_do_special __requires_special_rcu
rcu_do_something __requires_rcu


Then both this will be fine:


rcu_special_lock()
rcu_do_special()
rcu_do_something()
rcu_special_unlock()


but this will result in a warning:


rcu_regular_lock()
rcu_do_special()
rcu_regular_unlock()

because the "specialRCU" context is missing.

You could mark do_special with *both* __requires(RCU) and
__requires(specialRCU) but as long as the acquires/releases parts have a
strict dependency (ïspecialRCU implies RCU) that isn't necessary.

johannes

Attachment: signature.asc
Description: This is a digitally signed message part