Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2310063ybb; Fri, 27 Mar 2020 03:09:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtoo5b62oNwNMzUzegSv27CQ1ovtFcSg4zB4bM7+U42nmkO1vOAvmAc0jOEVbW1oCgKoqgI X-Received: by 2002:a05:6830:12d5:: with SMTP id a21mr227498otq.6.1585303785971; Fri, 27 Mar 2020 03:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585303785; cv=none; d=google.com; s=arc-20160816; b=D0FKIikM9CGdForD9FF19/x//FP7opJStcWDEroQiq8OdV6oBR+IXBLOybX7bPRUM4 NEBqLUjd4ebLceR2N1mYky70MvxILGLIwFJN3ffppZfbxVYv6y0NnrERYF963yMPF9Cj NON1KFrTNF5o+/a066OVClQO0gR9qEp6akAZiHe2dvtbjHjYt580sbyuoSHeVGEyHIYh DIcIzV1UgsEymWHkstFkgk2nuUXsqfrXDb/CogWpc6mHId4C2iUcw1+kVIZFfI4RDPWk q66LIdu99BtvqeImzyHDmw+heAFFM0lS5pyuEbTdNI5pt4f2UtRHn7piqjIYhQrerzSI K5FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Ow9wspP4ZB5j6pWkHUXbOlu3r+KhuaS3yvNnb3J3+Xo=; b=A1bm1EtTCix0+PwJ6FDNfuHAqx/cTT6IcIPR/ekAN2yM67EUUYDcn47YgjE8jPcnnE uT5j7RpHJxM74eYfUDqXqM29KXpnDf0/DrdpYqSn/CjPxAkdY0rKqMKq3uBl6euE6jmM FsVhRlWx31OGLfJhyL4wYDgregtXu0AAuQQkKx9ndu3Z39ZtwxLIKD2T6ATiOVHyU9sg 5jGw0Qcm3wsmlBulLkDDrZcuWHCWJemYm4Xqt+dfKdz9oaJhOWxW2SPEHDLkMzqGbvLB rjxoabd1R9K+D3jjT/I5kezQ6yB5+Z/7AiPdoNyYJZQMBMpIlV8iHr7mPRXRlBskY3xN Czlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=LG3Ha+qs; 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 v2si2286408oov.20.2020.03.27.03.09.32; Fri, 27 Mar 2020 03:09:45 -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=LG3Ha+qs; 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 S1726427AbgC0KIw (ORCPT + 99 others); Fri, 27 Mar 2020 06:08:52 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44136 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbgC0KIw (ORCPT ); Fri, 27 Mar 2020 06:08:52 -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-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Ow9wspP4ZB5j6pWkHUXbOlu3r+KhuaS3yvNnb3J3+Xo=; b=LG3Ha+qssDr5iexXh9ZU+6Xv9r jC2PwRQqxcOsjBKD6T5lOsXEYZM6LBXl7aHA3GfBQ7UmNDMSfvsk0/QXa080B3a1iSnnQRGrxIqz6 Q6im6mg0znSbenyQMfb4BPTFQOyPDC705a/N85eE2PyS282HqSvCExh+EeKL/cFzcuKF8pY5BBpSj T+m9ThDURcPZyB+laOkgxBUDJDsm9g84EK/3PnCx3JB+NH56jpB7fcTc928AtV6x+QJKYnsrARVFp BgCqNZKtHeJvVoykBq73cmZzeGjt8vG9KDLZqXpJvKusBdYL1OaObR/TBiBQMX5/tjhfzXBY6RKp2 cFEoZNdg==; 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.3 #3 (Red Hat Linux)) id 1jHluj-0003PM-Kh; Fri, 27 Mar 2020 10:08:33 +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 6E21D3010C2; Fri, 27 Mar 2020 11:08:31 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 474E129CA13C6; Fri, 27 Mar 2020 11:08:31 +0100 (CET) Date: Fri, 27 Mar 2020 11:08:31 +0100 From: Peter Zijlstra To: Rasmus Villemoes Cc: x86@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, jpoimboe@redhat.com Subject: Re: [RESEND][PATCH v3 14/17] static_call: Add static_cond_call() Message-ID: <20200327100831.GT20713@hirez.programming.kicks-ass.net> References: <20200324135603.483964896@infradead.org> <20200324142246.127013582@infradead.org> <10ef25bf-87df-6917-1d50-c29ece442766@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10ef25bf-87df-6917-1d50-c29ece442766@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 27, 2020 at 12:37:35AM +0100, Rasmus Villemoes wrote: > On 24/03/2020 14.56, Peter Zijlstra wrote: > > Extend the static_call infrastructure to optimize the following common > > pattern: > > > > if (func_ptr) > > func_ptr(args...) > > > > > +#define DEFINE_STATIC_COND_CALL(name, _func) \ > > + DECLARE_STATIC_CALL(name, _func); \ > > + struct static_call_key STATIC_CALL_NAME(name) = { \ > > + .func = NULL, \ > > + } > > + > > #define static_call(name) \ > > ((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_NAME(name).func)) > > > > +#define static_cond_call(name) \ > > + if (STATIC_CALL_NAME(name).func) \ > > + ((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_NAME(name).func)) > > + > > What, apart from fear of being ridiculed by kernel folks, prevents the > compiler from reloading STATIC_CALL_NAME(name).func ? IOW, doesn't this > want a READ_ONCE somewhere? Hurmph.. I suspect you're quite right, but at the same time I can't seem to write a macro that does that :/ Let me try harder. > And please remind me, what is the consensus for sizeof(long) loads: does > static_call() need load-tearing protection or not? We all like to believe compilers are broken when they tear naturally aligned words, but we're also not quite comfortable trusting that.