Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755639AbbGUPzN (ORCPT ); Tue, 21 Jul 2015 11:55:13 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:55330 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754146AbbGUPzL (ORCPT ); Tue, 21 Jul 2015 11:55:11 -0400 Date: Tue, 21 Jul 2015 17:54:54 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Andy Lutomirski , Jason Baron , Mikulas Patocka , Paul Mackerras , Arnaldo Carvalho de Melo , Kees Cook , Andrea Arcangeli , Vince Weaver , "hillf.zj" , Valdis Kletnieks , "linux-kernel@vger.kernel.org" , Borislav Petkov , Steven Rostedt Subject: Re: Kernel broken on processors without performance counters Message-ID: <20150721155454.GH18673@twins.programming.kicks-ass.net> References: <20150708160750.GQ19282@twins.programming.kicks-ass.net> <559D8250.8000707@gmail.com> <20150710141359.GJ19282@twins.programming.kicks-ass.net> <20150721082107.GE18673@twins.programming.kicks-ass.net> <20150721154959.GS19282@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150721154959.GS19282@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1438 Lines: 41 On Tue, Jul 21, 2015 at 05:49:59PM +0200, Peter Zijlstra wrote: > On Tue, Jul 21, 2015 at 05:43:27PM +0200, Thomas Gleixner wrote: > > On Tue, 21 Jul 2015, Peter Zijlstra wrote: > > > > > > -#endif /* _LINUX_JUMP_LABEL_H */ > > > > +static inline void static_key_enable(struct static_key *key) > > > > +{ > > > > + int count = static_key_count(key); > > > > + > > > > + WARN_ON_ONCE(count < 0 || count > 1); > > > > + > > > > + if (!count) > > > > + static_key_slow_inc(key); > > > > +} > > > > + > > > > +static inline void static_key_disable(struct static_key *key) > > > > +{ > > > > + int count = static_key_count(key); > > > > + > > > > + WARN_ON_ONCE(count < 0 || count > 1); > > > > + > > > > + if (count) > > > > + static_key_slow_dec(key); > > > > +} > > > > The functions above are not part of the interface which should be used > > in code, right? > > They are in fact. They make it easier to deal with the refcount thing > when all you want is boolean states. That is, things like sched_feat_keys[] which is an array of static keys, the split types doesn't work -- an array can after all have only one type. In such cases you do have to be very careful to not wreck things. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/