Re: [PATCH -v2 6/8] jump_label: Add a new static_key interface

From: Vlastimil Babka
Date: Wed Jul 29 2015 - 03:19:38 EST


On 07/28/2015 03:21 PM, Peter Zijlstra wrote:
> +/* -------------------------------------------------------------------------- */
> +
> +/*
> + * Two type wrappers around static_key, such that we can use compile time
> + * type differentiation to emit the right code.
> + *
> + * All the below code is macros in order to play type games.
> + */
> +
> +struct static_key_true {
> + struct static_key key;
> +};
> +
> +struct static_key_false {
> + struct static_key key;
> +};
> +
> +#define STATIC_KEY_TRUE_INIT (struct static_key_true) { .key = STATIC_KEY_INIT_TRUE, }
> +#define STATIC_KEY_FALSE_INIT (struct static_key_false){ .key = STATIC_KEY_INIT_FALSE, }

How would one define a static key that's e.g. expected to be mostly false, but
with initial value of true, e.g. during boot?

Is the following legal? Should there be an API wrapper as well?

(struct static_key_false){ .key = STATIC_KEY_INIT_TRUE, }

Otherwise the new API seems like a big improvement, thanks :)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/