Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8994688ybi; Fri, 7 Jun 2019 01:32:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJXWmcwXmikTjNZac3JPJNL6Wrz6BZZwhuOSDgcAjafJNidnjLQjFJ+OjVoX2er9o904wo X-Received: by 2002:a17:90a:1951:: with SMTP id 17mr4189098pjh.79.1559896353815; Fri, 07 Jun 2019 01:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559896353; cv=none; d=google.com; s=arc-20160816; b=GNHVL73uM7ppkhASfKz8MXA8vrc1cDYaQKpgQcoAMF5Jl+ujGILSHOx/0yCiN9itdL QkXRjpg495b4l8COjY/MrknUmNQBiIkL1sYfTaqWxjrxTyG5tsvUup551/SpB7RkuvFj 6E7Dgr0LqzRQugBMPlaLX0159xEqkw/jLdRchmwm18tbVATc/76nst+e2nlaGXXCgGeN UpCPeBCNY84jcOlEjW14nHIqj8mlxqRgJmU7WHMVZZmjnWvfT5S2N/NWq8cj1m6pf6/8 lJjcudjdEISgtoYqANC9L9dwC4ok9Q6hnxgYLoSTDgqhq7kDm6RB0IYr4C9CLB9nvKNq zI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pEikf0lz/+ehFxWTVsFBoEGGzwbfmWwbxDox14l2d24=; b=pIIrZXKmp0JiVOu/9YWbswbWy8+9H/A1q7crsqM4kl68jUS1GV8EgWrdHPvd7/dtd5 4VkZtuPnJ3j3mAcWYw25/f1aiK+MfRgBPzez4V5XSDhSAbjCD2+8LIglAoEr9aG85aqp cAoLSCX5N+uVYFM3YKav8r3/Vi7wAyZEPpWLS8NZAhLs7ci+iALzPjuYKbAyCUGLoLd9 x5ke1IBxtj7hoskFL8BuUgUGoxAtop/VUgcUBpAILx4roixOBL8NJMc9arLEeCtLi1Kc elyuLOhw90iML97p7irpua2QUldfLyHNB7GC1EIiLr8X5Gjm4kYTZgGL2H+t8DiEuMTf E4sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="S/F5cs9m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si1161955pfr.94.2019.06.07.01.32.16; Fri, 07 Jun 2019 01:32:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="S/F5cs9m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbfFGI3g (ORCPT + 99 others); Fri, 7 Jun 2019 04:29:36 -0400 Received: from merlin.infradead.org ([205.233.59.134]:47742 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727839AbfFGI3f (ORCPT ); Fri, 7 Jun 2019 04:29:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pEikf0lz/+ehFxWTVsFBoEGGzwbfmWwbxDox14l2d24=; b=S/F5cs9mR+CktwIhwbiymklHgM bpALiLdQ6Snh7vv4Xw460zXM6KnF3D9kRw5/BivR7MKsgB/jAc28kA/qMIUIzhjL2PxTw/LFy2Jaj WR+SGfRCWmaAM4S+zgbQTyjmX8eYyIXKmApOLzpG3XxJhLTpteWUKSERMmNNv8MKfLHw7MdQ9IOC1 KsSfJyHKSJhdGXbo+Z7U9vtA6X7ExIWk7HYT4izPT2vr09aTNiy+TGTgbQ47yA1TmCjQp62eOfK5r vqpwgZpwifudO5M5Oe3eo5OWDgIBp/pKG3kI0kIUMxTAQPwD0pbY8MnZ7XsCRg/DpD3GQFff5x8FM 1I1HJ6Lw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hZAF3-0006VS-8o; Fri, 07 Jun 2019 08:28:53 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B068620973565; Fri, 7 Jun 2019 10:28:51 +0200 (CEST) Date: Fri, 7 Jun 2019 10:28:51 +0200 From: Peter Zijlstra To: Nadav Amit Cc: the arch/x86 maintainers , LKML , Ard Biesheuvel , Andy Lutomirski , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira , Josh Poimboeuf Subject: Re: [PATCH 10/15] static_call: Add basic static call infrastructure Message-ID: <20190607082851.GV3419@hirez.programming.kicks-ass.net> References: <20190605130753.327195108@infradead.org> <20190605131945.125037517@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 06, 2019 at 10:44:23PM +0000, Nadav Amit wrote: > > + * Usage example: > > + * > > + * # Start with the following functions (with identical prototypes): > > + * int func_a(int arg1, int arg2); > > + * int func_b(int arg1, int arg2); > > + * > > + * # Define a 'my_key' reference, associated with func_a() by default > > + * DEFINE_STATIC_CALL(my_key, func_a); > > + * > > + * # Call func_a() > > + * static_call(my_key, arg1, arg2); > > + * > > + * # Update 'my_key' to point to func_b() > > + * static_call_update(my_key, func_b); > > + * > > + * # Call func_b() > > + * static_call(my_key, arg1, arg2); > > I think that this calling interface is not very intuitive. Yeah, it is somewhat unfortunate.. > I understand that > the macros/objtool cannot allow the calling interface to be completely > transparent (as compiler plugin could). But, can the macros be used to > paste the key with the “static_call”? I think that having something like: > > static_call__func(arg1, arg2) > > Is more readable than > > static_call(func, arg1, arg2) Doesn't really make it much better for me; I think I'd prefer to switch to the GCC plugin scheme over this. ISTR there being some propotypes there, but I couldn't quickly locate them. > > +} > > + > > +#define static_call_update(key, func) \ > > +({ \ > > + BUILD_BUG_ON(!__same_type(func, STATIC_CALL_TRAMP(key))); \ > > + __static_call_update(&key, func); \ > > +}) > > Is this safe against concurrent module removal? It is for CONFIG_MODULE=n :-)