Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932214AbbEULjY (ORCPT ); Thu, 21 May 2015 07:39:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55105 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932164AbbEULjW (ORCPT ); Thu, 21 May 2015 07:39:22 -0400 Message-ID: <555DC39C.8060502@redhat.com> Date: Thu, 21 May 2015 13:38:04 +0200 From: Denys Vlasenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Linus Torvalds , Ingo Molnar CC: Andy Lutomirski , Davidlohr Bueso , Peter Anvin , Linux Kernel Mailing List , Tim Chen , Borislav Petkov , Peter Zijlstra , "Chandramouleeswaran, Aswin" , Peter Zijlstra , Brian Gerst , Paul McKenney , Thomas Gleixner , Jason Low , "linux-tip-commits@vger.kernel.org" , Arjan van de Ven , Andrew Morton Subject: Re: [RFC PATCH] x86/64: Optimize the effective instruction cache footprint of kernel functions References: <20150410121808.GA19918@gmail.com> <20150517055551.GB17002@gmail.com> <20150519213820.GA31688@gmail.com> <555C7C57.1070608@redhat.com> In-Reply-To: <555C7C57.1070608@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1508 Lines: 44 On 05/20/2015 02:21 PM, Denys Vlasenko wrote: > So what we need is to put something like ".p2align 64,,7" > before every function. > > ( > Why 7? > > defconfig vmlinux (w/o FRAME_POINTER) has 42141 functions. > 6923 of them have 1st insn 5 or more bytes long, > 5841 of them have 1st insn 6 or more bytes long, > 5095 of them have 1st insn 7 or more bytes long, > 786 of them have 1st insn 8 or more bytes long, > 548 of them have 1st insn 9 or more bytes long, > 375 of them have 1st insn 10 or more bytes long, > 73 of them have 1st insn 11 or more bytes long, > one of them has 1st insn 12 bytes long: > this "heroic" instruction is in local_touch_nmi() > 65 48 c7 05 44 3c 00 7f 00 00 00 00 > movq $0x0,%gs:0x7f003c44(%rip) > > Thus ensuring that at least seven first bytes do not cross > 64-byte boundary would cover >98% of all functions. > ) > > gcc can't do that right now. With -falign-functions=N, > it emits ".p2align next_power_of_2(N),,N-1" > > We need to make it just a tiny bit smarter. > >> We'd need toolchain help to do saner alignment. > > Yep. > I'm going to create a gcc BZ with a feature request, > unless you disagree with my musings above. The BZ is here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66240 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/