Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp9007822ybi; Fri, 7 Jun 2019 01:51:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQTlyRvzyGHSfMvec2wllE1WZP+q+jzFu6Aj+eIcJt8NuYNGNKwF+oTBqVcDkPLj0cQ0Qe X-Received: by 2002:a17:90a:29a4:: with SMTP id h33mr4153655pjd.105.1559897462943; Fri, 07 Jun 2019 01:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559897462; cv=none; d=google.com; s=arc-20160816; b=elTYmgBc/1VYz2NJqjErdRlt5zI99/j9jcOcfcOKTRuquLtxt2zX4ZnzGPm9WGzQyt 6dtd1Wh6tZyzpqt0y90KuzGHPko/3XTe/P5tDBXPvXKlaPGxTFLQDEDhA32ag2JxmiRR 7PTWj30TTKkFM1fwnIMxWnzPjoFDeIpV/Oj8n4yGv2xOqQ3EO87CUh5dxid9mvRzz27+ fHWM11JvHVqsgNWHpQLYr6aeqQDTK0d98N9QO77xSKIAwpPgZf5jL4RZcx9ikxLNN4da C4tM5xno/MjnqlzlTErotnXuSV6M4zzKqdjt/TgJsbyI9V6yQz8xPvnkvtte3HCW5zIh fdRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=adnKoWQTMzO2+3oj6bzIQQSJxMqy6PQK9AaINLk4VKk=; b=kBoKZiPNfo8zJpdqN2hbk1RwIdED/IcfNGWcCMdfkRc+LKxDmRBIg2tBUn0V3KSkDO D828+ragobkFYSDoxtm74J8GJqgRbQtfVNetl0wGI+AuKLtEiPjBJ3xkXeLW61mSuKlS 3wYZitsih8hvnkTZ6/Fm3P477MqkS4MLYrnVtrTFJr5DTE8+Lj6M/RdwOZNpKKZkxIxa 9U6ewrsMnKfTakYcGRJHEWXv6eMkzpCLUeb2Ot9hZRGGrW3lhkX2J/6nuVP9togbqkVk m3HJQD8QNHMc/ftA7Nebi4FzmzU9qOH9Bffj1vG7BuFkcMorRRClrdg4lBv89TkKw4Wc R1zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fYRHGnDB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f69si1298384pjg.43.2019.06.07.01.50.46; Fri, 07 Jun 2019 01:51:02 -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=pass header.i=@linaro.org header.s=google header.b=fYRHGnDB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfFGItd (ORCPT + 99 others); Fri, 7 Jun 2019 04:49:33 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:38238 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726531AbfFGItd (ORCPT ); Fri, 7 Jun 2019 04:49:33 -0400 Received: by mail-it1-f193.google.com with SMTP id h9so1556606itk.3 for ; Fri, 07 Jun 2019 01:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=adnKoWQTMzO2+3oj6bzIQQSJxMqy6PQK9AaINLk4VKk=; b=fYRHGnDBC83ZNMfN01VXg8LH+MDfZ2+Mrl7HGcO/O0vYbnZ6xMKpuM3zSUENZko1o3 2j8a16D64nA8xzTKEwIBH/5oo0qfrFzjWrnMIGJZu8P0N3Rnqg3Hfjwdus2b8hdwaXKW CQa8oRnRTooeVogOV9B6hmD1BL9+bUMH/rksuw9AoLdZgllJXQDP/I4WjKS3FBBPFy9B 8mzVB1VgTRZXF6SiF61kXAdkjnFD8Ejy4XeWG5f9Yq+s9gmeoDHfJ2SOUvxhB6e25YE4 9jXKe3Cbo5CBp6bJLSPMS9cKfzvwlnIbmrva6BrwqX+NqGZg0RCCUKxlbvUCaeJDi6+9 XcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=adnKoWQTMzO2+3oj6bzIQQSJxMqy6PQK9AaINLk4VKk=; b=Ury2NRjv56K2rUonWLslJb7L71TrQsrwTSQULwoFOj0vYz3/+KgjQUIb1tueS1Zu2N bZLSOcbNDN3pWqhEgt3ySyg5H7QID0x0g7G1/bRVgv5btA/8E5llfjUah6edVO0fdw3R BRvCQp301bAkgGTwhXY3gcTLv9+zGoiCbF2aQwOfMc2/SMeU16kf4gMI9kzxZ8Ngj3d7 2sgB68KQBk1tCUh4B/wZzXYN8bNA3eh21Tlak2q6dJV6Kv4KFOdgbDw5sD70nI1al1Ju gkneJOwdew22UYqowVBEVUYbUeE+Rjf1ITUbZYoMEM4M86MQwi5Oere1ZSHQhD/ROEZx iXWA== X-Gm-Message-State: APjAAAVhY2nGEcAa1Lm3jGvHyheP3qDy4y5hCzIRZMdG6rIXoBPoX/ll fd4r6ttvEVMA+5BDBxSmFn2Ox53Jgu2UmI3DuRmjBWu0SIA19g== X-Received: by 2002:a02:b01c:: with SMTP id p28mr34991386jah.130.1559897372103; Fri, 07 Jun 2019 01:49:32 -0700 (PDT) MIME-Version: 1.0 References: <20190605130753.327195108@infradead.org> <20190605131945.125037517@infradead.org> <20190607082851.GV3419@hirez.programming.kicks-ass.net> In-Reply-To: <20190607082851.GV3419@hirez.programming.kicks-ass.net> From: Ard Biesheuvel Date: Fri, 7 Jun 2019 10:49:18 +0200 Message-ID: Subject: Re: [PATCH 10/15] static_call: Add basic static call infrastructure To: Peter Zijlstra Cc: Nadav Amit , "the arch/x86 maintainers" , LKML , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Jun 2019 at 10:29, 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 defa= ult > > > + * 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.. > Another thing I brought up at the time is that it would be useful to have the ability to 'reset' a static call to its default target. E.g., for crypto modules that implement an accelerated version of a library interface, removing the module should revert those call sites back to the original target, without putting a disproportionate burden on the module itself to implement the logic to support this. > > 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 =E2=80=9Cstatic_call=E2=80=9D? I think that havi= ng 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. > I implemented the GCC plugin here https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=3Dsta= tic-calls but IIRC, all it does is annotate call sites exactly how objtool does it. > > > +} > > > + > > > +#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=3Dn :-)