From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752651AbbIKLKM (ORCPT ); Fri, 11 Sep 2015 07:10:12 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:60066 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbbIKLKJ (ORCPT ); Fri, 11 Sep 2015 07:10:09 -0400 Date: Fri, 11 Sep 2015 13:10:03 +0200 From: Peter Zijlstra To: Johannes Berg Cc: Jason Baron , linux-kernel Subject: Re: static key arrays? Message-ID: <20150911111003.GK18489@twins.programming.kicks-ass.net> References: <1441964735.2083.4.camel@sipsolutions.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441964735.2083.4.camel@sipsolutions.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 On Fri, Sep 11, 2015 at 11:45:35AM +0200, Johannes Berg wrote: > Hi Peter, Jason, all, > > Per the recent type-safe API changes, it's no longer easy to generate > an array of static keys. I was planning to do that for a set of very > unlikely debug options. > > It sounds like you're planning to remove the previous API entirely at > some point, so I'm wondering if you've given any thought to this > possibility. If possible I'd kill static_key_{true,false}() and static_key_slow_{inc,dec}. Not sure how much more makes sense, the new interface builds on parts of the old stuff. > I briefly played with the idea of adding a macro for that, but the > necessary "REPEAT(n, d)" macro for the initialisation becomes ugly > pretty quickly and, afaict, needs to have enough macros for the maximum > expected numbers. > > For the case I was looking at it's static_key_false so a zero > -initialized array would be sufficient, but that can't be done easily > with a static_key_true. As long as its all the same type it shouldn't be too hard; struct static_key_false array[n] = { STATIC_KEY_FALSE_INIT, }; or something like that. The scheduler has an array of these things that has different types; which if going to be even more interesting. I'm not quite sure what to do there, but I think it'll end up relying on the fact that both types share the same base (struct static_key) and involve a lot of type casting :-)