Messages in this thread | | | Subject | Re: [PATCH/RFC 1/2] jump label: make enable/disable o(1) | From | Peter Zijlstra <> | Date | Thu, 16 Dec 2010 20:10:02 +0100 |
| |
On Thu, 2010-12-16 at 13:25 -0500, Jason Baron wrote: > Previously, I allowed any variable type to be used as the 'key' for > the jump label. However, by enforcing a type, we can make use of the > contents of the 'key'. This patch thus introduces: > > struct jump_label_key { > void *ptr; > }; > > The 'ptr' is used a pointer into the jump label table of the > corresponding addresses that need to be updated. Thus, when jump labels > are enabled/disabled we have a constant time algorithm. There is no > longer any hashing. > > When jump lables are disabled we simply have: > > struct jump_label_key { > int state; > }; > > I've also defined an analogous structure for ref counted jump labels as > per a request from Peter. > > struct jump_label_keyref { > void *ptr; > }; > > And for the jump labels disabled case: > > > struct jump_label_keyref { > atomic_t refcount; > }; > > The reason I've introduced an additional structure for the reference counted > jump labels is twofold: > > 1) For the jump labels disabled case, reference counted jump labels use an > atomic_read(). I didn't want to impact the jump labels disabled case for > tracepoints which simply accesses an 'int'. > > 2) By introducing a second type, we have two parallel APIs: > > extern void jump_label_enable(struct jump_label_key *key); > extern void jump_label_disable(struct jump_label_key *key); > > static inline void jump_label_inc(struct jump_label_keyref *key) > static inline void jump_label_dec(struct jump_label_keyref *key) > > In this way, we can't mix up the reference counted API, with the straight > enable/disable API since they accept different types.
But why do we want to have two APIs?
| |