Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1487300
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures |
| Date | 2016-09-20 14:50 +0200 |
| Message-ID | <sjsEO-31h-7@gated-at.bofh.it> (permalink) |
| References | <sjaye-8kP-19@gated-at.bofh.it> <sjaye-8kP-21@gated-at.bofh.it> <sjpQB-1av-5@gated-at.bofh.it> <sjsls-2V3-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Sep 20, 2016 at 02:25:14PM +0200, Christoffer Dall wrote:
> 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.
'struct static_key' should indeed not be used and is deprecated. 'struct
static_key_{true,false}' however should be fine.
Part of the problem is naming, everything using 'struct static_key' has
_insane_ names and the API is utterly confusing. The other part is that
the new 2 type API simply has more functionality.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] jump_labels: Embedding static keys inside structures Marc Zyngier <marc.zyngier@arm.com> - 2016-09-19 19:30 +0200
[PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Marc Zyngier <marc.zyngier@arm.com> - 2016-09-19 19:30 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Peter Zijlstra <peterz@infradead.org> - 2016-09-20 11:50 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Marc Zyngier <marc.zyngier@arm.com> - 2016-09-20 11:50 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Christoffer Dall <christoffer.dall@linaro.org> - 2016-09-20 14:30 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Peter Zijlstra <peterz@infradead.org> - 2016-09-20 14:50 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Christoffer Dall <christoffer.dall@linaro.org> - 2016-09-20 15:00 +0200
Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Peter Zijlstra <peterz@infradead.org> - 2016-09-22 09:50 +0200
[PATCH 2/2] dynamic_debug: Use updated jump label API Marc Zyngier <marc.zyngier@arm.com> - 2016-09-19 19:30 +0200
csiph-web