Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751143AbbG2ItW (ORCPT ); Wed, 29 Jul 2015 04:49:22 -0400 Received: from casper.infradead.org ([85.118.1.10]:48341 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750791AbbG2ItU (ORCPT ); Wed, 29 Jul 2015 04:49:20 -0400 Date: Wed, 29 Jul 2015 10:49:06 +0200 From: Peter Zijlstra To: Vlastimil Babka Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jasonbaron0@gmail.com, bp@alien8.de, luto@amacapital.net, tglx@linutronix.de, rostedt@goodmis.org, will.deacon@arm.com, liuj97@gmail.com, rabin@rab.in, ralf@linux-mips.org, ddaney@caviumnetworks.com, benh@kernel.crashing.org, michael@ellerman.id.au, heiko.carstens@de.ibm.com, davem@davemloft.net Subject: Re: [PATCH -v2 6/8] jump_label: Add a new static_key interface Message-ID: <20150729084906.GH19282@twins.programming.kicks-ass.net> References: <20150728132055.203176565@infradead.org> <20150728132313.164884020@infradead.org> <55B87E7A.2070509@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55B87E7A.2070509@suse.cz> 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: 930 Lines: 28 On Wed, Jul 29, 2015 at 09:19:22AM +0200, Vlastimil Babka wrote: > How would one define a static key that's e.g. expected to be mostly false, but > with initial value of true, e.g. during boot? DEFINE_STATIC_KEY_TRUE(blah); will get you the true at boot time. You'll then want to use: if (static_branch_unlikely(&blah)) { /* code that mostly doesn't happen */ } To indicate you expect it to be false most of the time. And you'll flip it to false at runtime using: static_branch_disable(&blah); If GCC co-operates, the body of the branch will be placed out-of-line, we'll emit a jump to it by default, but once you disable it, we'll nop the jump and fall straight through. -- 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/