From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbdISQCP (ORCPT ); Tue, 19 Sep 2017 12:02:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61232 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751353AbdISQCN (ORCPT ); Tue, 19 Sep 2017 12:02:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DA014883C1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jpoimboe@redhat.com Date: Tue, 19 Sep 2017 11:02:10 -0500 From: Josh Poimboeuf To: Linus Torvalds Cc: Andrey Ryabinin , the arch/x86 maintainers , Linux Kernel Mailing List , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Alexander Potapenko , Dmitriy Vyukov , Matthias Kaehlcke , Arnd Bergmann , Peter Zijlstra Subject: Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more clear and consistent Message-ID: <20170919160210.beip7uighuq7gqu3@treble> References: <20fac125eed15c916f684e27dfca753d524c6725.1504186968.git.jpoimboe@redhat.com> <20170831172542.k5qchwmgckdcnc6d@treble> <96dcfb0d-75b9-9707-67df-9bae33186b7d@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 19 Sep 2017 16:02:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: > And most code movement really seemed to be around inline asms, I > wonder if the gcc logic simply is something like "if the stack pointer > is visible as a register, don't move any inline asm across a frame > setup". After some testing, that seems to be exactly right. Making the stack pointer a global register variable seems to cause *all* inline asm to be treated like it has a call instruction. And setting the stack pointer as a constraint becomes a no-op. So basically if we just put register void *__asm_call_sp asm(_ASM_SP); in a globally visible header file (e.g., arch/x86/include/asm/asm.h), it will *always* make sure the frame pointer is set up before inserting *any* inline asm. The upside is that we don't have to manually annotate inline asm anymore with those awful "+r" (__sp) constraints. The downside is that this creates a very slight performance issue for leaf functions which use inline assembly without call instructions, because they're getting frame pointer setup when they don't need it. But based on the text size difference, the performance impact should be negligible. And it's only an issue for frame pointer-based kernels, which may soon no longer be the default anyway. And for non-frame-pointer-based kernels, it actually saves quite a bit of text. In GCC, here are the vmlinux .text size differences with the following configs: - defconfig - defconfig without frame pointers - Fedora distro config - Fedora distro config without frame pointers defconfig defconfig-nofp distro distro-nofp before 9796300 9466764 9076191 8789745 after 9796941 9462859 9076381 8785325 If there are no objections, I'll go forward with the patch. -- Josh