Message ID | 20231122221814.139916-2-deller@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1537148rwn; Wed, 22 Nov 2023 14:18:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHw8dtrz3NPdPXx58mFFGnvWyOdwtHll4UwXFX92Pmnk2hXnwMPZSvjjMJAUattrtTbwnpi X-Received: by 2002:a17:902:c94d:b0:1cc:5258:845c with SMTP id i13-20020a170902c94d00b001cc5258845cmr4074070pla.57.1700691526968; Wed, 22 Nov 2023 14:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700691526; cv=none; d=google.com; s=arc-20160816; b=v6+lOPS+89oftPQBypMqlGeDdiOXYpfNlv4ZSxDZ3I5lCsU8FY/TYB6oLUvLts/4dm Nz818GteLuziXOu6SEXg8PdswZBdNjtp2ipA1AqmgpySF1BtMt1Vc7F2YR4CNXokL4ke DH+l+15cu3YnM6/la2v7kudezsyvuzLfty4TVH+ZHaAQbAzM1/7GGs249oCs/0tEnQe1 rFsAAm93Yde9li78nHuZVjEFqXVyQoKVRY7op86m2zFAJktn4PIZyduA0twz0fQuX53T v1upSfSUbVjngSfx+g8/yXkTW/P3DsAnK2gVg38lH6/TXedpR0MeA3wQ29ZlOyFVf6+p wbhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VITu87Pl3VKgeOzJVXV4EdGm4xnooqaitfGti+g61fk=; fh=p1Qf4H5TYe6x87oeu/ZwD97uWE3f/aSmdhLxEgeh+tk=; b=hVSTSmjUMKvowaUM5hRP/jZ2y5aJjmX1VU4wciry+AtFU/dMMNMyTmHrdnCFTAvjzo BUXmKxyFDoXQSKHzAnqqkR5lFczN4UFBslcTSmTYtxFefuOta9VWLY/CtaE2N7d7TkaR LvXWgkhEtP/BLurkwro0z87grAojhtLlpViw+vmzszy0zahkHAsRUZEY0zDecpozvp9j WuYjbko3gh+EDoE1n8EXC40YjlBMgRSM1kV3pKmM5ENfu4u4HnTqbgS1Zo0Lb6xwMRIf PG6kbeR6a95uDGmZAQyQ5o3zVFUtiQGkZ9EsbhRDDJelEfz5B/oXsalvn9rVsKMUGA2Y U07Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m2h70Ph0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p9-20020a170902bd0900b001cc23d2bb92si285853pls.650.2023.11.22.14.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 14:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m2h70Ph0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6CE7F825B4A9; Wed, 22 Nov 2023 14:18:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344678AbjKVWS3 (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Wed, 22 Nov 2023 17:18:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344659AbjKVWSY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Nov 2023 17:18:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA60BD49 for <linux-kernel@vger.kernel.org>; Wed, 22 Nov 2023 14:18:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08242C433CA; Wed, 22 Nov 2023 22:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700691500; bh=xbM7UwIkiSdSjSS3CBuDr633BLrw+vGBgZ7TQFhbsLY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m2h70Ph0oAZb/KX4nmAIJIgAmgEZEAHewd+1aGGUOhZc0ygMNSOWeUiEp1Yg2WYgy vN3jz96ggTWzf1Bzay6hfnIGbpcm6KWoXWDKgTCPKRFBnwnJo53wEurBHbmta/5y+F MtE0afBV1dJSy4Js5ujpLxMDxY+lmy3oDFmunIGryqALbZSCSERfm4NW6NBKDd/cZY Vrb7l60r4giYrU3WZ2eflFchwcLkYBTML9vieiuIqzr3zvsWKZRmMvmalsDisaSBhM S79EOfk01xMSaLSuK1QPOMEwM4smNWNix8Jo/Kdp4fF7Ulk7r0ZUUllRLeCLj4URPW hAYOhMY02eQkA== From: deller@kernel.org To: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>, Arnd Bergmann <arnd@arndb.de>, linux-modules@vger.kernel.org, linux-arch@vger.kernel.org, Luis Chamberlain <mcgrof@kernel.org> Subject: [PATCH 1/4] linux/export: Fix alignment for 64-bit ksymtab entries Date: Wed, 22 Nov 2023 23:18:11 +0100 Message-ID: <20231122221814.139916-2-deller@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231122221814.139916-1-deller@kernel.org> References: <20231122221814.139916-1-deller@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 14:18:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783304318623414526 X-GMAIL-MSGID: 1783304318623414526 |
Series |
[1/4] linux/export: Fix alignment for 64-bit ksymtab entries
|
|
Commit Message
Helge Deller
Nov. 22, 2023, 10:18 p.m. UTC
From: Helge Deller <deller@gmx.de> An alignment of 4 bytes is wrong for 64-bit platforms which don't define CONFIG_HAVE_ARCH_PREL32_RELOCATIONS (which then store 64-bit pointers). Fix their alignment to 8 bytes. Signed-off-by: Helge Deller <deller@gmx.de> --- include/linux/export-internal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On Thu, Nov 23, 2023 at 7:18 AM <deller@kernel.org> wrote: > > From: Helge Deller <deller@gmx.de> > > An alignment of 4 bytes is wrong for 64-bit platforms which don't define > CONFIG_HAVE_ARCH_PREL32_RELOCATIONS (which then store 64-bit pointers). > Fix their alignment to 8 bytes. > > Signed-off-by: Helge Deller <deller@gmx.de> This is correct. Acked-by: Masahiro Yamada <masahiroy@kernel.org> Please add Fixes: ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") > --- > include/linux/export-internal.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/export-internal.h b/include/linux/export-internal.h > index 69501e0ec239..cd253eb51d6c 100644 > --- a/include/linux/export-internal.h > +++ b/include/linux/export-internal.h > @@ -16,10 +16,13 @@ > * and eliminates the need for absolute relocations that require runtime > * processing on relocatable kernels. > */ > +#define __KSYM_ALIGN ".balign 4" > #define __KSYM_REF(sym) ".long " #sym "- ." > #elif defined(CONFIG_64BIT) > +#define __KSYM_ALIGN ".balign 8" > #define __KSYM_REF(sym) ".quad " #sym > #else > +#define __KSYM_ALIGN ".balign 4" > #define __KSYM_REF(sym) ".long " #sym > #endif > > @@ -42,7 +45,7 @@ > " .asciz \"" ns "\"" "\n" \ > " .previous" "\n" \ > " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ > - " .balign 4" "\n" \ > + __KSYM_ALIGN "\n" \ > "__ksymtab_" #name ":" "\n" \ > __KSYM_REF(sym) "\n" \ > __KSYM_REF(__kstrtab_ ##name) "\n" \ > -- > 2.41.0 >
On Thu, Dec 21, 2023 at 7:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Thu, Nov 23, 2023 at 7:18 AM <deller@kernel.org> wrote: > > > > From: Helge Deller <deller@gmx.de> > > > > An alignment of 4 bytes is wrong for 64-bit platforms which don't define > > CONFIG_HAVE_ARCH_PREL32_RELOCATIONS (which then store 64-bit pointers). > > Fix their alignment to 8 bytes. > > > > Signed-off-by: Helge Deller <deller@gmx.de> > > > This is correct. > > Acked-by: Masahiro Yamada <masahiroy@kernel.org> > > Please add > > > Fixes: ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") > > If there is no objection, I will pick this up to linux-kbuild/fixes. Thanks.
On Fri, Dec 22, 2023 at 01:01:23AM +0900, Masahiro Yamada wrote: > On Thu, Dec 21, 2023 at 7:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > On Thu, Nov 23, 2023 at 7:18 AM <deller@kernel.org> wrote: > > > > > > From: Helge Deller <deller@gmx.de> > > > > > > An alignment of 4 bytes is wrong for 64-bit platforms which don't define > > > CONFIG_HAVE_ARCH_PREL32_RELOCATIONS (which then store 64-bit pointers). > > > Fix their alignment to 8 bytes. > > > > > > Signed-off-by: Helge Deller <deller@gmx.de> > > > > > > This is correct. > > > > Acked-by: Masahiro Yamada <masahiroy@kernel.org> > > > > Please add > > > > > > Fixes: ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") > > > > > > > If there is no objection, I will pick this up > to linux-kbuild/fixes. The new selftests I've suggested should help get perf data to cover both modules and built-in kernel symbols given find_symbol() will first hit built-in symbols first before modules with one caveat: we'd want to extend the selftest with a part which builds a module built-in with also tons of other symbols. So I'm all for you taking this but I don't think we need to rush for the same reasons I mentioned in my reply to Helge. I think it would be nice to get real perf data with perf stat as I suggested, and include that in the commit logs. I think it would also be useful to include a description about the fact that there is no real fix and that the performance hit is all that happens as the architecture just emulates the aligment. In the worst case, if exception handlers are broken we could crash but that is rare although it does happen. If we want to go bananas we could even get a graph of size of modules Vs cost on misaligment as a relationship with time. Without this, frankly cost on "performance" is artificial. Thoughts? Luis
On Thu, Dec 21, 2023 at 10:07:13PM -0800, Luis Chamberlain wrote: > > If we want to go bananas we could even get a graph of size of modules Sorry I meant size of number of symbols Vs cost. Luis
On Fri, Dec 22, 2023 at 3:08 PM Luis Chamberlain <mcgrof@kernel.org> wrote: > > On Thu, Dec 21, 2023 at 10:07:13PM -0800, Luis Chamberlain wrote: > > > > If we want to go bananas we could even get a graph of size of modules > > Sorry I meant size of number of symbols Vs cost. > > Luis But, 1/4 is really a bug-fix, isn't it? ksymtab was previously 8-byte aligned for CONFIG_64BIT, but now is only 4-byte aligned. $ git show ddb5cdbafaaa^:include/linux/export.h | head -n66 | tail -n5 struct kernel_symbol { unsigned long value; const char *name; const char *namespace; }; $ git show ddb5cdbafaaa^:include/asm-generic/export.h | head -23 | tail -8 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS #define KSYM_ALIGN 4 #elif defined(CONFIG_64BIT) #define KSYM_ALIGN 8 #else #define KSYM_ALIGN 4 #endif In the old behavior, <linux/export.h> used C code for producing ksymtab, hence it was naturally aligned by the compiler. (unsigned long and pointer require 8-byte alignment for CONFIG_64BIT) <asm-generic/export.h> explicitly required 8-byte alignment for CONFIG_64BIT. In the current behavior, <linux/export-internal.h> produces all ksymtab by using inline assembler, but it hard-codes ".balign 4".
On Fri, Dec 22, 2023 at 04:01:30PM +0900, Masahiro Yamada wrote: > On Fri, Dec 22, 2023 at 3:08 PM Luis Chamberlain <mcgrof@kernel.org> wrote: > > > > On Thu, Dec 21, 2023 at 10:07:13PM -0800, Luis Chamberlain wrote: > > > > > > If we want to go bananas we could even get a graph of size of modules > > > > Sorry I meant size of number of symbols Vs cost. > > > > Luis > > > > But, 1/4 is really a bug-fix, isn't it? Ah you mean a regression fix, yeah sure, thanks I see ! Luis
On Sat, Dec 23, 2023 at 5:11 AM Luis Chamberlain <mcgrof@kernel.org> wrote: > > On Fri, Dec 22, 2023 at 04:01:30PM +0900, Masahiro Yamada wrote: > > On Fri, Dec 22, 2023 at 3:08 PM Luis Chamberlain <mcgrof@kernel.org> wrote: > > > > > > On Thu, Dec 21, 2023 at 10:07:13PM -0800, Luis Chamberlain wrote: > > > > > > > > If we want to go bananas we could even get a graph of size of modules > > > > > > Sorry I meant size of number of symbols Vs cost. > > > > > > Luis > > > > > > > > But, 1/4 is really a bug-fix, isn't it? > > Ah you mean a regression fix, yeah sure, thanks I see ! > > Luis Now, I applied 1/4 to linux-kbuild/fixes. Thanks.
diff --git a/include/linux/export-internal.h b/include/linux/export-internal.h index 69501e0ec239..cd253eb51d6c 100644 --- a/include/linux/export-internal.h +++ b/include/linux/export-internal.h @@ -16,10 +16,13 @@ * and eliminates the need for absolute relocations that require runtime * processing on relocatable kernels. */ +#define __KSYM_ALIGN ".balign 4" #define __KSYM_REF(sym) ".long " #sym "- ." #elif defined(CONFIG_64BIT) +#define __KSYM_ALIGN ".balign 8" #define __KSYM_REF(sym) ".quad " #sym #else +#define __KSYM_ALIGN ".balign 4" #define __KSYM_REF(sym) ".long " #sym #endif @@ -42,7 +45,7 @@ " .asciz \"" ns "\"" "\n" \ " .previous" "\n" \ " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ - " .balign 4" "\n" \ + __KSYM_ALIGN "\n" \ "__ksymtab_" #name ":" "\n" \ __KSYM_REF(sym) "\n" \ __KSYM_REF(__kstrtab_ ##name) "\n" \