Message ID | 20230514152739.962109-15-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6379430vqo; Sun, 14 May 2023 08:56:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5C84PqlCuuYKQ12hpxjewV6M5lP+uqTMUhqXxjcUtPSxZMaezPiCPzS3uou9uXbnTVyR16 X-Received: by 2002:a05:6a00:989:b0:62d:d045:392 with SMTP id u9-20020a056a00098900b0062dd0450392mr46278008pfg.32.1684079777278; Sun, 14 May 2023 08:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684079777; cv=none; d=google.com; s=arc-20160816; b=ZSEvoURg4+ba2LaKh6D/ST1ByiwpnLqFA6k4vBYozIvU7yhgUulctxCt3Ezl+DM/Eb WloJQySFQQ8jLpwU8AJXHoiXbcnHA3sdqNbjOglmt8xpS540+2r768yYVyy1NITzhX83 rDc+gS2F/t0H7dPXWtFtvNLS0JW0VBxATHliOXuc/Bpe2ORVBXERXTMbN1R2qFH+8KG3 vQiRnwd+7GcPJT0OrZx8oZPY+WGC6vkN20d/ewBGgBUfS30QZTXXr8fpfRdWRihV385N pRROXZ8SRQH2NjHwVflYCZOd6burjrv3TgAIvl4H9eE6H8ZUTVyL47kBM7yPUvdDpu42 Lomg== 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:cc:to:from :dkim-signature; bh=QfOqWEE3jyvqavfInbKMGMLB8k1jI5jGxdLE7uFuz+4=; b=Z7f+mEjQaayzlwfzmPdlrigoClQ1L79IfLJsco6Ab0I4g5t/6v3gr50+3iw23oVAa8 yMxzqoAC4hiucsZHT/PY/yLt1CF/lTNW2jYrApsUsz3iBfe0kLN5vQD/af2ekQZZOVI2 7/4ldu7qXSbPPkJw0Yqg9j4HLmDP0zJxfr0UdFhfG8vjHQq9P7P1NcMZNpUMZBsFlqyk TfH9jUj8N10bx9dZTKUL7+1o88HbnsMmSkt8klcV9allNy1NJ6K9HJ4iWFHT4XZJS+rT EBB9LcVoi6evWxNX4wTCTrMtx8HpOrA7pTkT0JhOclzdC+7xmiN5VQ4Z/yjie9zFo72K ay1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lpUtzLuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x21-20020aa78f15000000b00622ae306420si14844433pfr.279.2023.05.14.08.56.02; Sun, 14 May 2023 08:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lpUtzLuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238124AbjENPaW (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Sun, 14 May 2023 11:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238037AbjENP36 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 14 May 2023 11:29:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C29C03C27; Sun, 14 May 2023 08:29:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C17CC6181D; Sun, 14 May 2023 15:28:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88579C433D2; Sun, 14 May 2023 15:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684078097; bh=TjK5vRQ4AG9lfNTTEX4WG1cFCBfFWQ69ySiU2xVg33I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpUtzLukxKl9IfHjnbn7g+E9RDy351uv6gDpCfdBYL3LaEHi9jTEgbQMJvXVwZfSF VvxH83aQ43TqdBXIGWDWmnadtx0UdS7+HSYqEXl3Ln8AKIMUa0QTRbsfagMy49fJxq xAmuKiLnwdH5SWl17rG5yIYKwnbXgni1/qLFHR8Mi5ZqK2hFgRjmJXX7KzI0WDq/P+ c7+bnBZ43c29UZvkNvnojWP8Mpm4Vuyf8pk6FDR8X7Z8kANCkeXfskVySLmzFQq6jI O82+7bp4JIuNTLsrkAtqL0NrX7eKPAPQIXvkGvRygpajgjvS7B+x0cWdXgju/c6gOp PL90KJ9tscB4A== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Pitre <npitre@baylibre.com>, Nicolas Schier <nicolas@fjasle.eu>, Masahiro Yamada <masahiroy@kernel.org> Subject: [PATCH v5 14/21] modpost: remove is_shndx_special() check from section_rel(a) Date: Mon, 15 May 2023 00:27:32 +0900 Message-Id: <20230514152739.962109-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230514152739.962109-1-masahiroy@kernel.org> References: <20230514152739.962109-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765885636219644214?= X-GMAIL-MSGID: =?utf-8?q?1765885636219644214?= |
Series |
Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS
|
|
Commit Message
Masahiro Yamada
May 14, 2023, 3:27 p.m. UTC
This check is unneeded. Without it, sec_name() will returns the null
string "", then section_mismatch() will return immediately.
Anyway, special section indices do not appear quite often in these
loops.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/modpost.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
Comments
On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > This check is unneeded. Without it, sec_name() will returns the null > string "", then section_mismatch() will return immediately. > > Anyway, special section indices do not appear quite often in these > loops. > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Could almost eliminate is_shndx_special after this. I think there's only one callsite after this? (I should check with the series applied; this patch fails to apply on mainline if that's relevant for potential merge conflicts). Does doing that additional work speed things up though? > --- > > scripts/mod/modpost.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 0ef9d6964b6a..28db215ecc71 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -1370,7 +1370,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) > static void section_rela(const char *modname, struct elf_info *elf, > Elf_Shdr *sechdr) > { > - Elf_Sym *sym; > Elf_Rela *rela; > Elf_Rela r; > unsigned int r_sym; > @@ -1413,11 +1412,8 @@ static void section_rela(const char *modname, struct elf_info *elf, > continue; > break; > } > - sym = elf->symtab_start + r_sym; > - /* Skip special sections */ > - if (is_shndx_special(sym->st_shndx)) > - continue; > - check_section_mismatch(modname, elf, sym, > + > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > fsecndx, fromsec, r.r_offset, r.r_addend); > } > } > @@ -1425,7 +1421,6 @@ static void section_rela(const char *modname, struct elf_info *elf, > static void section_rel(const char *modname, struct elf_info *elf, > Elf_Shdr *sechdr) > { > - Elf_Sym *sym; > Elf_Rel *rel; > Elf_Rela r; > unsigned int r_sym; > @@ -1472,11 +1467,8 @@ static void section_rel(const char *modname, struct elf_info *elf, > default: > fatal("Please add code to calculate addend for this architecture\n"); > } > - sym = elf->symtab_start + r_sym; > - /* Skip special sections */ > - if (is_shndx_special(sym->st_shndx)) > - continue; > - check_section_mismatch(modname, elf, sym, > + > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > fsecndx, fromsec, r.r_offset, r.r_addend); > } > } > -- > 2.39.2 >
On Wed, May 17, 2023 at 2:23 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > This check is unneeded. Without it, sec_name() will returns the null > > string "", then section_mismatch() will return immediately. > > > > Anyway, special section indices do not appear quite often in these > > loops. > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > Could almost eliminate is_shndx_special after this. I think there's > only one callsite after this? (I should check with the series applied; > this patch fails to apply on mainline if that's relevant for potential > merge conflicts). > > Does doing that additional work speed things up though? Either way, Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > --- > > > > scripts/mod/modpost.c | 16 ++++------------ > > 1 file changed, 4 insertions(+), 12 deletions(-) > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > index 0ef9d6964b6a..28db215ecc71 100644 > > --- a/scripts/mod/modpost.c > > +++ b/scripts/mod/modpost.c > > @@ -1370,7 +1370,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) > > static void section_rela(const char *modname, struct elf_info *elf, > > Elf_Shdr *sechdr) > > { > > - Elf_Sym *sym; > > Elf_Rela *rela; > > Elf_Rela r; > > unsigned int r_sym; > > @@ -1413,11 +1412,8 @@ static void section_rela(const char *modname, struct elf_info *elf, > > continue; > > break; > > } > > - sym = elf->symtab_start + r_sym; > > - /* Skip special sections */ > > - if (is_shndx_special(sym->st_shndx)) > > - continue; > > - check_section_mismatch(modname, elf, sym, > > + > > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > > fsecndx, fromsec, r.r_offset, r.r_addend); > > } > > } > > @@ -1425,7 +1421,6 @@ static void section_rela(const char *modname, struct elf_info *elf, > > static void section_rel(const char *modname, struct elf_info *elf, > > Elf_Shdr *sechdr) > > { > > - Elf_Sym *sym; > > Elf_Rel *rel; > > Elf_Rela r; > > unsigned int r_sym; > > @@ -1472,11 +1467,8 @@ static void section_rel(const char *modname, struct elf_info *elf, > > default: > > fatal("Please add code to calculate addend for this architecture\n"); > > } > > - sym = elf->symtab_start + r_sym; > > - /* Skip special sections */ > > - if (is_shndx_special(sym->st_shndx)) > > - continue; > > - check_section_mismatch(modname, elf, sym, > > + > > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > > fsecndx, fromsec, r.r_offset, r.r_addend); > > } > > } > > -- > > 2.39.2 > > > > > -- > Thanks, > ~Nick Desaulniers
On Thu, May 18, 2023 at 6:23 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > This check is unneeded. Without it, sec_name() will returns the null > > string "", then section_mismatch() will return immediately. > > > > Anyway, special section indices do not appear quite often in these > > loops. > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > Could almost eliminate is_shndx_special after this. I think there's > only one callsite after this? There will be no callsite of is_shndx_special(). I will remove the definition as well. (I should check with the series applied; > this patch fails to apply on mainline if that's relevant for potential > merge conflicts). > > Does doing that additional work speed things up though? I do not know. As I wrote in the comment, special indices rarely appear in the relocation. I do not believe "let's bail out earlier" does not buy us. > > > --- > > > > scripts/mod/modpost.c | 16 ++++------------ > > 1 file changed, 4 insertions(+), 12 deletions(-) > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > index 0ef9d6964b6a..28db215ecc71 100644 > > --- a/scripts/mod/modpost.c > > +++ b/scripts/mod/modpost.c > > @@ -1370,7 +1370,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) > > static void section_rela(const char *modname, struct elf_info *elf, > > Elf_Shdr *sechdr) > > { > > - Elf_Sym *sym; > > Elf_Rela *rela; > > Elf_Rela r; > > unsigned int r_sym; > > @@ -1413,11 +1412,8 @@ static void section_rela(const char *modname, struct elf_info *elf, > > continue; > > break; > > } > > - sym = elf->symtab_start + r_sym; > > - /* Skip special sections */ > > - if (is_shndx_special(sym->st_shndx)) > > - continue; > > - check_section_mismatch(modname, elf, sym, > > + > > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > > fsecndx, fromsec, r.r_offset, r.r_addend); > > } > > } > > @@ -1425,7 +1421,6 @@ static void section_rela(const char *modname, struct elf_info *elf, > > static void section_rel(const char *modname, struct elf_info *elf, > > Elf_Shdr *sechdr) > > { > > - Elf_Sym *sym; > > Elf_Rel *rel; > > Elf_Rela r; > > unsigned int r_sym; > > @@ -1472,11 +1467,8 @@ static void section_rel(const char *modname, struct elf_info *elf, > > default: > > fatal("Please add code to calculate addend for this architecture\n"); > > } > > - sym = elf->symtab_start + r_sym; > > - /* Skip special sections */ > > - if (is_shndx_special(sym->st_shndx)) > > - continue; > > - check_section_mismatch(modname, elf, sym, > > + > > + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, > > fsecndx, fromsec, r.r_offset, r.r_addend); > > } > > } > > -- > > 2.39.2 > > > > > -- > Thanks, > ~Nick Desaulniers
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0ef9d6964b6a..28db215ecc71 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1370,7 +1370,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) static void section_rela(const char *modname, struct elf_info *elf, Elf_Shdr *sechdr) { - Elf_Sym *sym; Elf_Rela *rela; Elf_Rela r; unsigned int r_sym; @@ -1413,11 +1412,8 @@ static void section_rela(const char *modname, struct elf_info *elf, continue; break; } - sym = elf->symtab_start + r_sym; - /* Skip special sections */ - if (is_shndx_special(sym->st_shndx)) - continue; - check_section_mismatch(modname, elf, sym, + + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, fsecndx, fromsec, r.r_offset, r.r_addend); } } @@ -1425,7 +1421,6 @@ static void section_rela(const char *modname, struct elf_info *elf, static void section_rel(const char *modname, struct elf_info *elf, Elf_Shdr *sechdr) { - Elf_Sym *sym; Elf_Rel *rel; Elf_Rela r; unsigned int r_sym; @@ -1472,11 +1467,8 @@ static void section_rel(const char *modname, struct elf_info *elf, default: fatal("Please add code to calculate addend for this architecture\n"); } - sym = elf->symtab_start + r_sym; - /* Skip special sections */ - if (is_shndx_special(sym->st_shndx)) - continue; - check_section_mismatch(modname, elf, sym, + + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, fsecndx, fromsec, r.r_offset, r.r_addend); } }