Message ID | 1440072876-8321-4-git-send-email-haokexin@gmail.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Thu, Aug 20, 2015 at 08:14:31PM +0800, Kevin Hao wrote:
> These are used to define a static_key_{true,false} array.
Yes but why...
there might have been some clue in the patches you didn't send me, but
since you didn't send them, I'm left wondering.
On Thu, Aug 20, 2015 at 08:31:58PM +0200, Peter Zijlstra wrote: > On Thu, Aug 20, 2015 at 08:14:31PM +0800, Kevin Hao wrote: > > These are used to define a static_key_{true,false} array. > > Yes but why... > > there might have been some clue in the patches you didn't send me, but > since you didn't send them, I'm left wondering. Sorry for the confusion. In order to use jump label for the {cpu,mmu}_has_feature() functions on powerpc, we need to declare an array of 32 or 64 static_key_true (one static_key_true for each cpu or mmu feature). The following are the two patches which depends on this patch. https://lkml.org/lkml/2015/8/20/355 https://lkml.org/lkml/2015/8/20/356 So far only DEFINE_STATIC_KEY_TRUE_ARRAY macro is used, but I think it may seem canonical to define the macros for both true or false keys at the same time. Thanks, Kevin
* Kevin Hao <haokexin@gmail.com> wrote: > These are used to define a static_key_{true,false} array. > > Signed-off-by: Kevin Hao <haokexin@gmail.com> > --- > include/linux/jump_label.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h > index 7f653e8f6690..5c1d6a49dd6b 100644 > --- a/include/linux/jump_label.h > +++ b/include/linux/jump_label.h > @@ -267,6 +267,12 @@ struct static_key_false { > #define DEFINE_STATIC_KEY_FALSE(name) \ > struct static_key_false name = STATIC_KEY_FALSE_INIT > > +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ > + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } > + > +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ > + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } I think the define makes the code more obfuscated and less clear, the open-coded initialization is pretty dense and easy to read to begin with. Thanks, Ingo
On Fri, Aug 21, 2015 at 08:28:26AM +0200, Ingo Molnar wrote: > > * Kevin Hao <haokexin@gmail.com> wrote: > > > These are used to define a static_key_{true,false} array. > > > > Signed-off-by: Kevin Hao <haokexin@gmail.com> > > --- > > include/linux/jump_label.h | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h > > index 7f653e8f6690..5c1d6a49dd6b 100644 > > --- a/include/linux/jump_label.h > > +++ b/include/linux/jump_label.h > > @@ -267,6 +267,12 @@ struct static_key_false { > > #define DEFINE_STATIC_KEY_FALSE(name) \ > > struct static_key_false name = STATIC_KEY_FALSE_INIT > > > > +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ > > + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } > > + > > +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ > > + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } > > I think the define makes the code more obfuscated and less clear, the open-coded > initialization is pretty dense and easy to read to begin with. OK, I will drop this patch and move the initialization of the array to the corresponding patch. Thanks, Kevin
* Kevin Hao <haokexin@gmail.com> wrote: > On Fri, Aug 21, 2015 at 08:28:26AM +0200, Ingo Molnar wrote: > > > > * Kevin Hao <haokexin@gmail.com> wrote: > > > > > These are used to define a static_key_{true,false} array. > > > > > > Signed-off-by: Kevin Hao <haokexin@gmail.com> > > > --- > > > include/linux/jump_label.h | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h > > > index 7f653e8f6690..5c1d6a49dd6b 100644 > > > --- a/include/linux/jump_label.h > > > +++ b/include/linux/jump_label.h > > > @@ -267,6 +267,12 @@ struct static_key_false { > > > #define DEFINE_STATIC_KEY_FALSE(name) \ > > > struct static_key_false name = STATIC_KEY_FALSE_INIT > > > > > > +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ > > > + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } > > > + > > > +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ > > > + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } > > > > I think the define makes the code more obfuscated and less clear, the open-coded > > initialization is pretty dense and easy to read to begin with. > > OK, I will drop this patch and move the initialization of the array to the > corresponding patch. Please also Cc: peterz and me to the next submission of the series - static key (and jump label) changes go through the locking tree normally, and there's a number of changes pending already for v4.3: 20f9ed1568c0 locking/static_keys: Make verify_keys() static 412758cb2670 jump label, locking/static_keys: Update docs 2bf9e0ab08c6 locking/static_keys: Provide a selftest ed79e946732e s390/uaccess, locking/static_keys: employ static_branch_likely() 3bbfafb77a06 x86, tsc, locking/static_keys: Employ static_branch_likely() 1987c947d905 locking/static_keys: Add selftest 11276d5306b8 locking/static_keys: Add a new static_key interface 706249c222f6 locking/static_keys: Rework update logic e33886b38cc8 locking/static_keys: Add static_key_{en,dis}able() helpers 7dcfd915bae5 jump_label: Add jump_entry_key() helper a1efb01feca5 jump_label, locking/static_keys: Rename JUMP_LABEL_TYPE_* and related helpers to the static_key* pattern Thanks, Ingo
On Fri, Aug 21, 2015 at 08:40:59AM +0200, Ingo Molnar wrote: > Please also Cc: peterz and me to the next submission of the series - static key > (and jump label) changes go through the locking tree normally, and there's a > number of changes pending already for v4.3: Sure. Thanks, Kevin
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 7f653e8f6690..5c1d6a49dd6b 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -267,6 +267,12 @@ struct static_key_false { #define DEFINE_STATIC_KEY_FALSE(name) \ struct static_key_false name = STATIC_KEY_FALSE_INIT +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } + +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } + #ifdef HAVE_JUMP_LABEL /*
These are used to define a static_key_{true,false} array. Signed-off-by: Kevin Hao <haokexin@gmail.com> --- include/linux/jump_label.h | 6 ++++++ 1 file changed, 6 insertions(+)