From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753872AbcITMZN (ORCPT ); Tue, 20 Sep 2016 08:25:13 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:38342 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbcITMZL (ORCPT ); Tue, 20 Sep 2016 08:25:11 -0400 Date: Tue, 20 Sep 2016 14:25:14 +0200 From: Christoffer Dall To: Peter Zijlstra Cc: Marc Zyngier , linux-kernel@vger.kernel.org, Jason Baron , Jonathan Corbet , Vladimir Murzin , Catalin Marinas Subject: Re: [PATCH 1/2] jump_labels: Add API to deal with keys embedded in structures Message-ID: <20160920122514.GA16763@cbox> References: <1474305688-22553-1-git-send-email-marc.zyngier@arm.com> <1474305688-22553-2-git-send-email-marc.zyngier@arm.com> <20160920094223.GR5012@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160920094223.GR5012@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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