Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp2010785ybj; Wed, 6 May 2020 09:05:35 -0700 (PDT) X-Google-Smtp-Source: APiQypLNeyj/VXbaGAB5/SU1/JLo+3BDltD72BcapSRjrE0w4E8B770GGYTZ4RoH8uJ195Ui8fw4 X-Received: by 2002:a50:ec95:: with SMTP id e21mr7652715edr.253.1588781135260; Wed, 06 May 2020 09:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588781135; cv=none; d=google.com; s=arc-20160816; b=kBd9zlQHmqBzAbmMPR3caNIje/7+gJ01cNjVy38SzK+DMUgmpGDgULRXd9755OJspU NLLGco6twaXJkldVdaTkBt3QhDjfal3CS0owhFZOYEXjO9Py6k6B7gy8V5BpMrMoetfJ meQXlU4IocR8JC1ix0uJapEDc8/YYJQicYZrZqdRFAphp3erKLKuddeDrV/REw3AvH8v 8X7azL/j1EWqBayqnJ6PsB/5Bq2wrbYS9ShetQUkmF4JeaEC8vjsnbJAz1YMaJF1JO4P ZtvhZ+y5MfFzNXZHvCHCOqgusay0k07w6JgcuWdpF2RIWSLc7zdZlRv8t1ayFlVYvYbw 8yQg== 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=O+yvLTLG1IJONNPK9WJhPabLzQvN7JA3hPuY2O/IAJU=; b=Uv5x77jfzRhSh+ptaiyqGF2eqccXQiJiJlAnxQRRUEE4WyDVmPI1w39PtlrVEnL3p5 nLK+mZ90+8cU4XdBQ7geqLZmWRFVb/BhBcVHBsWNuwbCVBsnNdBlQQW5CdKeDNOAqI8d 9Z495LdczrE3kQ/i8AkBq9N7gwymUWSgiOO04OKoAaur0qXp8O9DmIoM0AtkUXuP8Dfj 7sMh7OPo4zmNaqd190IhVK+wdBo9V9ofAQ1AqA27OfneH9NdSiFM+GXAohSTJ00uLWBa HRTIPxBiV9B3ze6XVnVUR5vkMHAjOpdc61FBaq/c58n7hwZracQybxN1AzT8l1f4xwyo Hz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=X6KbbuJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si1242170edv.171.2020.05.06.09.05.07; Wed, 06 May 2020 09:05:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=X6KbbuJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbgEFQAt (ORCPT + 99 others); Wed, 6 May 2020 12:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbgEFQAt (ORCPT ); Wed, 6 May 2020 12:00:49 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E77C061A0F for ; Wed, 6 May 2020 09:00:49 -0700 (PDT) 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=O+yvLTLG1IJONNPK9WJhPabLzQvN7JA3hPuY2O/IAJU=; b=X6KbbuJMA4+Y+nXIsY2WieFhK0 d6v00Rrm6aGtpfVotfsYjfvcIU9soFbpUG+abI0r2UhD2qPBRlV20NLiajCCX+RRW1pagGeNNOYZK kzRHYhm8fZgmRzl01Lfo7JPCkr0VSegle9KSYVo2Ku1eKJPrXArll0W3YCYoLeS6C2biaU18yjktP vATXv00QiLKl/bJN8Zxqpl6iAXbkPPdzkwJAPpxtK/t7DSSsc+KkjDJqQIR9xzIyOCKvJGxS9A4qy Nz2cfBC4UKeAULRHEb7yZdj7PhEt55KKdFJ8cp4DEa5r1krePrzOzorBI1xyRjuqmlogLStEXPa+q mSG6lHWg==; 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 1jWMTD-0002vv-Gk; Wed, 06 May 2020 16:00:27 +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 62D0F30018B; Wed, 6 May 2020 18:00:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4A3EC29DAC133; Wed, 6 May 2020 18:00:25 +0200 (CEST) Date: Wed, 6 May 2020 18:00:25 +0200 From: Peter Zijlstra To: Nick Desaulniers Cc: Rasmus Villemoes , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , Steven Rostedt , Masami Hiramatsu , bristot@redhat.com, Jason Baron , Linus Torvalds , Thomas Gleixner , Ingo Molnar , Nadav Amit , "H. Peter Anvin" , Andy Lutomirski , Ard Biesheuvel , Josh Poimboeuf , Paolo Bonzini , Mathieu Desnoyers , "H.J. Lu" , clang-built-linux Subject: Re: [PATCH v4 14/18] static_call: Add static_cond_call() Message-ID: <20200506160025.GB5324@hirez.programming.kicks-ass.net> References: <20200501202849.647891881@infradead.org> <20200501202944.593400184@infradead.org> <1238787e-d97d-f09b-d76d-2df2dc273f4b@rasmusvillemoes.dk> <20200503125813.GL3762@hirez.programming.kicks-ass.net> <20200504201445.GQ3762@hirez.programming.kicks-ass.net> <20200505093625.GE5298@hirez.programming.kicks-ass.net> <20200506135128.GR3762@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506135128.GR3762@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 06, 2020 at 03:51:28PM +0200, Peter Zijlstra wrote: > On Tue, May 05, 2020 at 11:13:53AM -0700, Nick Desaulniers wrote: > > On Tue, May 5, 2020 at 2:36 AM Peter Zijlstra wrote: > > > > > > > > > HJ, Nick, > > > > > > Any chance any of you can see a way to make your respective compilers > > > not emit utter junk for this? > > > > > > On Mon, May 04, 2020 at 10:14:45PM +0200, Peter Zijlstra wrote: > > > > > > > https://godbolt.org/z/SDRG2q > > > > Woah, a godbolt link! Now we're speaking the same language. What were > > you expecting? > > Given the output for x86-64 clang (trunk) > > bar: # @bar > movl %edi, .L_x$local(%rip) > retq > ponies: # @ponies > movq .Lfoo$local(%rip), %rax > testq %rax, %rax > movl $__static_call_nop, %ecx > cmovneq %rax, %rcx > jmpq *%rcx # TAILCALL > __static_call_nop: # @__static_call_nop > retq > _x: > .L_x$local: > .long 0 # 0x0 > > foo: > .Lfoo$local: > .zero 8 > > > I was hoping for: > > bar: # @bar > movl %edi, .L_x$local(%rip) > retq > ponies: # @ponies > movq .Lfoo$local(%rip), %rax > testq %rax, %rax > jz 1f > jmpq *%rcx # TAILCALL Obviously this then wants to be *%rax. > 1: > retq > > That avoids the indirect call (possible retpoline) and does an immediate > return. > > So it does 2 things different: > > - it realizes the NULL case is a constant and uses an > immediate call and avoids the indirect call/jmp. > > - it realizes __static_call_nop() is a no-op and avoids the call > entirely and does an immediate return. IOW, have it inline __static_call_nop().