Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp831632ybn; Wed, 2 Oct 2019 06:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxklywRAtyj2wH0xftrUYA9YzsPphrj7MGNi9kgWfgnTVVHLtj7xaZ/CoL+jA6d4hK44Ct7 X-Received: by 2002:a05:6402:1adc:: with SMTP id ba28mr4028425edb.103.1570024557888; Wed, 02 Oct 2019 06:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570024557; cv=none; d=google.com; s=arc-20160816; b=EWID6pHQ/sAvpwF+JZwkOCc5RPUN3nf5CilhSec3SLw+xzMLtjwPu4mpWI/afpZLeK ORjefVA6USOHd9fGJoEkJv0y+pPwEO/vPSV6TACqynT3m0vAsfHY7XwdNV0IVnB3OyAy Ai0O7cC1BYL14Ky6LybjiSn2PKpsRT105ZdwhEAoNKLgs8Hy+PvKYA6QVFMu/brfp14V e5nBG+FzBW4ShJrhoNqLnTNXIuK6a1taiXdbXuyiA7S6youQAm1EPQOhBP+/nalFyyWC 0Hht89fgvlIJyj9VM3C634Z4GyNfZYzIZXYok4FbEs15z8MTJYinvqdtyYFEsZ3xhxTZ R8qA== 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=I+rlKx0E0VhGVcz2gnhriX/DpMY+Lt7Foh8DXUD24cY=; b=HdltKpe7+mUVwNvCoDSpbgZ5rMaR6e8l0xNz8Uea1EP7ycr171bpsiWCi6PKFzO4qw wzuueEzYio8UyYA0HAt3VQQH+ocuGfSyP5I4bDd0Xl4DFhwUTxvn+dZn49MZP0C7ibMf 6emq6XgxS2AlBqUIGZyXe42hK26HLht7ivpgk7wrEdZB/qMfNDx+zjLX4rE1aAHM4yrO jDjdb7WxY11lgJLa4xtTEVGLsf+Pw0B8twEQvKZdCw3O8tXMxPlFAN0ZnTII0qpO4py6 hyWYn7fTIVPTRge/MBA/iWOG+NvizY3mZ08975C8ebCEDrAGP0hRY1OF87JkEFzuRcFs OOJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hw0oCQP2; 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 g25si11181253eds.210.2019.10.02.06.55.32; Wed, 02 Oct 2019 06:55:57 -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=bombadil.20170209 header.b=hw0oCQP2; 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 S1727590AbfJBNyj (ORCPT + 99 others); Wed, 2 Oct 2019 09:54:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51656 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfJBNyj (ORCPT ); Wed, 2 Oct 2019 09:54:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=I+rlKx0E0VhGVcz2gnhriX/DpMY+Lt7Foh8DXUD24cY=; b=hw0oCQP24Wyb5uZtrQUsgbMSvH wvvHSo034IiKeD9YUDPBbW8TiWSQ9cKvlP8BktvvqGt6iW6mSz73TyMv2xwDNtZW26KrMaxzbLTHU qMdoQiCJGR0c+Wfv39w0EkwCfp7hOkQo7DmgFP697dzP7qdxpq9Bc2n0JAy9r9rMn7f2cYLN/ZWfI Nt7zHk72qQ/IbTr1QWm1pf4A0Zig3vpdQVym7PmzrpWuP2jDOxRfR8Lud6BCvJkUVn1iU1tl9z18i t6WITzU6xXhbx9pw5uQXybdFduZSHTQirbkfRRTukyCIWTttEnPjW1LGeIWGF8KFvq1G4o8WSinqJ JjYC5T0g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iFf5A-0000ia-FY; Wed, 02 Oct 2019 13:54:21 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6362C304B4C; Wed, 2 Oct 2019 15:53:28 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 32BBA29CB4B64; Wed, 2 Oct 2019 15:54:17 +0200 (CEST) Date: Wed, 2 Oct 2019 15:54:17 +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: <20191002135417.GS4519@hirez.programming.kicks-ass.net> References: <20190605130753.327195108@infradead.org> <20190605131945.125037517@infradead.org> <20190607082851.GV3419@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190607082851.GV3419@hirez.programming.kicks-ass.net> 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 Fri, Jun 07, 2019 at 10:28:51AM +0200, Peter Zijlstra wrote: > 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. How about something like: static_call(key)(arg1, arg2); which is very close to the regular indirect call syntax. Furthermore, how about we put the trampolines in .static_call.text instead of relying on prefixes? Also, I think I can shrink static_call_key by half: - we can do away with static_call_key::tramp; there are only two usage sites: o __static_call_update, the static_call() macro can provide the address of STATIC_CALL_TRAMP(key) directly o static_call_add_module(), has two cases: * the trampoline is from outside the module; in this case it will already have been updated by a previous call to __static_call_update. * the trampoline is from inside the module; in this case it will have the default value and it doesn't need an update. so in no case does static_call_add_module() need to modify a trampoline. - we can change static_call_key::site_mods into a single next pointer, just like jump_label's static_key. But so far all the schemes I've come up with require 'key' to be a name, it cannot be an actual 'struct static_call_key *' value. And therefore usage from within structures isn't allowed.