Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2215980pja; Thu, 26 Mar 2020 11:30:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvopl65oXKrZlmU+PxfVPlCOsga9Z/HquouY+52zyAePoz6xU1gF9OUAlqexiE0Cs/e+qBx X-Received: by 2002:a4a:8962:: with SMTP id g31mr6217971ooi.97.1585247437985; Thu, 26 Mar 2020 11:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585247437; cv=none; d=google.com; s=arc-20160816; b=pv+OdH0mjczeKWX/S6VVmlPpkEySvaUnqJqHDKiwtf8ILlSe41nzBaSLvpyN13Xwix B5MSW6pKFpmf1al3zyuNJPoLdLqTZfyAEwS/vGzkhN6ibdGWVDPXk0j6eADrIGepncS2 86Xotwurcl5UZZGaZmOqdDfu4ewjmRd7W1Vzm27irOKxIXnSVm3MYGEF9tzJx7UOxgo5 FlJ6GHLxZO6+TyGe3na2+kkv4eM+CpZSy04uw3zxcgxD9nX91Q+UI19a5vL78B8id4Kz iCRqr3f+ThDcUf0rIsSj3J8FqfVM2JpSzFBVWc7te+0nGhSjhFuqQNTM6Q+YxbdoHzKh 7AKQ== 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=mchJhWy78UOAMgl1C3IsTG+i6Njh78XReHFvvDrBBYI=; b=saGgj9gbZMuGWMp6uBgTfcLVPm6Ybtah/7x0ca8eFMVzB3BcjJOznri1Dx+zmA4iQT s6TxCXNeAaBKVDICFwOt+5FsD30YSLpFCkiSiLbDDqQqwfjLSpyWu3sWUmBGVZGPsI5k N/jY5c7uW/uV412CLdq3/YKklVtPyXAKHd2wBeMVDEbzWrMPVrr1eYNoMNvZt9FqL8dt lV3ZzK+w61aGGCGB6HqkJOW2IjJnnE30V8EHx4D9Ol515+da3YztB/bOSAIA4QZoW8hx xpRvMM2Jj63p0EnQrdgTlash8Ae/dGEnzPDeiSqX3h0Ta8du5cn/EVQiv4i2XLC1sOjo KXIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=I+G+8vAi; 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 r17si1394966ota.32.2020.03.26.11.30.24; Thu, 26 Mar 2020 11:30:37 -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=I+G+8vAi; 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 S1727995AbgCZS2e (ORCPT + 99 others); Thu, 26 Mar 2020 14:28:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39986 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbgCZS2e (ORCPT ); Thu, 26 Mar 2020 14:28:34 -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; bh=mchJhWy78UOAMgl1C3IsTG+i6Njh78XReHFvvDrBBYI=; b=I+G+8vAiultIOC5GApAmNq0dsd S5djnLy/8+F9ob6Bo9Glu4BwoJne3D7OMuWPqXCm2tWWygSn3ojNOtwfkMqB7P09tvRdibdAe8XGE Ug1xN0wYsEyIMSFRuWnwBgIG0nOKLAW/OuLhpW3RFNacrqWXX2XYjNtqklIze9ibQHCGx85zYmChT his8KsXMsge+Xk4mRYbkcPizS4oDFX9xYLdG/uIMY2glCLYJOqad2NmEWuibrbDiCc7aKiHov8dAh +rz6xMapLhRZAXl7zsVufGDBeurhLf0J6RxJzmOrO3gAfV3QghpRdsqA5On9k+Q1121sIDyq7QdR5 URqA+kgg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHXEw-0007XV-Gb; Thu, 26 Mar 2020 18:28:26 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id DF411983531; Thu, 26 Mar 2020 19:28:23 +0100 (CET) Date: Thu, 26 Mar 2020 19:28:23 +0100 From: Peter Zijlstra To: Nadav Amit Cc: x86 , LKML , "rostedt@goodmis.org" , "mhiramat@kernel.org" , "bristot@redhat.com" , "jbaron@akamai.com" , "torvalds@linux-foundation.org" , tglx , "mingo@kernel.org" , "hpa@zytor.com" , Andy Lutomirski , "ard.biesheuvel@linaro.org" , "jpoimboe@redhat.com" Subject: Re: [RESEND][PATCH v3 06/17] static_call: Add basic static call infrastructure Message-ID: <20200326182823.GB2452@worktop.programming.kicks-ass.net> References: <20200324135603.483964896@infradead.org> <20200324142245.632535759@infradead.org> <12A30BA0-18DA-4748-B82F-6008179CC88C@vmware.com> <20200326170128.GQ20713@hirez.programming.kicks-ass.net> <9D47A4CA-39AD-4408-879B-677BE9D891B7@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9D47A4CA-39AD-4408-879B-677BE9D891B7@vmware.com> 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, Mar 26, 2020 at 06:09:07PM +0000, Nadav Amit wrote: > I think that the kernel underutilizes the pure attribute in general. > Building it with "-Wsuggest-attribute=pure” results in many warnings. > Function pointers such kvm_x86_ops.get_XXX() could have been candidates to > use the “pure” attribute. > > The syntax is what you would expect: > > static void __attribute__((pure))(*ptr)(void); > Well, I didn't in fact expect that, because an attribute is not a type qualifier. > However, you have a point, gcc does not appear to respect “pure” for > function pointers and emits a warning it is ignored. GCC apparently only > respects “const”. In contrast clang appears to respect the pure attribute > for function pointers. Still, we can probably make it happen for static_call(), since it is a direct call to the trampoline, all we need to do is make sure the trampoline is declared pure. It does however mean that static_call() inherits all the dangers and pit-falls of function pointers with some extra on top. It will be impossible to validate this stuff. That is, you can static_call_update() with a pointer to a !pure function and you get to keep the pieces.