From: Christoffer Dall <christoffer.dall@linaro.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
linux-kernel@vger.kernel.org, Jason Baron <jbaron@akamai.com>,
Jonathan Corbet <corbet@lwn.net>,
Vladimir Murzin <vladimir.murzin@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures
Date: Tue, 20 Sep 2016 14:25:14 +0200 [thread overview]
Message-ID: <20160920122514.GA16763@cbox> (raw)
In-Reply-To: <20160920094223.GR5012@twins.programming.kicks-ass.net>
On Tue, Sep 20, 2016 at 11:42:23AM +0200, Peter Zijlstra wrote:
> On Mon, Sep 19, 2016 at 06:21:27PM +0100, Marc Zyngier wrote:
> > It is desirable to allow static keys to be integrated in structures,
> > as it can lead do slightly more readable code. But the current API
> > only provides DEFINE_STATIC_KEY_TRUE/FALSE, which is not exactly
> > nice and leads to the following idiom:
> >
> > static struct {
> > int foo;
> > struct static_key_false key;
> > } bar = {
> > .key = STATIC_KEY_FALSE_INIT,
> > };
> >
> > [...]
> >
> > if (static_branch_unlikely(&bar.key))
> > foo = -1;
> >
> > which doesn't follow the recommended API, and uses the internals
> > of the static key implementation.
> >
> > This patch introduces DECLARE_STATIC_KEY_TRUE/FALSE, as well as
> > INIT_STATIC_KEY_TRUE/FALSE, which abstract such construct and
> > allow the internals to evolve without having to fix everything else:
> >
> > static struct {
> > int foo;
> > DECLARE_STATIC_KEY_FALSE(key);
> > } bar = {
> > INIT_STATIC_KEY_FALSE(.key),
> > };
>
> Hurm..
>
> I think I like the first better, it looks more like actual C. Either way
> around you need to now manually match up the type and initializer.
>
It may have been one of my review comments the prompted these patches,
because from reading Documentation/static-keys.txt, it seems that
referencing 'struct static_key' directly should be deprecated, and
instead developers should use the update API replacements.
I wonder if it's worth slightly updating the documentation then?
Thanks,
-Christoffer
next prev parent reply other threads:[~2016-09-20 12:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 17:21 [PATCH 0/2] jump_labels: Embedding static keys inside structures Marc Zyngier
2016-09-19 17:21 ` [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Marc Zyngier
2016-09-20 9:42 ` Peter Zijlstra
2016-09-20 9:46 ` Marc Zyngier
2016-09-20 12:25 ` Christoffer Dall [this message]
2016-09-20 12:42 ` Peter Zijlstra
2016-09-20 12:54 ` Christoffer Dall
2016-09-22 7:47 ` Peter Zijlstra
2016-09-19 17:21 ` [PATCH 2/2] dynamic_debug: Use updated jump label API Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160920122514.GA16763@cbox \
--to=christoffer.dall@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=jbaron@akamai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=peterz@infradead.org \
--cc=vladimir.murzin@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox