Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4959854ybi; Tue, 30 Jul 2019 11:10:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxusiCdRXe9Yfah9hf1WG0Hhf4pMW6M9Yto0WG9E+PPSMfPAw2wiWgLgmjDnxWfdie4Ba/+ X-Received: by 2002:a63:d301:: with SMTP id b1mr102115661pgg.379.1564510242250; Tue, 30 Jul 2019 11:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564510242; cv=none; d=google.com; s=arc-20160816; b=h/6gBl2bdNmxqBmmFCld9sVZ7r6mYndFsjRuHE2bx1NzfMwqGJk71A9od+gEyJr/PI RkgjB81b73HgO3E3mge3AGepQJuDocsQ4zUIWxkFUrTY51G62it+5nX0/D4aAYmkyK61 cWYyyHlUJ5SY5CYf7Tq5fz/mQlg2zMDI0lvjnniMwxMXSVF1DvdXV5Kv3eN6uN7fnBMT Nv8SFqyrPQXIUDKAJ3Q14pkn/xRDJHCwTVc95sH1W+71sMAZ57BG/xFwg8eB2F81Hzex lxIK/7ytju7+yPHYXFTUmsuk9j4uqXl8qz5URBx6XicUcqv6GUb38hDgMKo2Gd8BJwzp YVCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=Vqhm/EITINFOuWf1dLL2W5rIciZKR5IQ8djNbAIk8l8=; b=qDW7N4g7SPSlbQF/oS2friS1P4kojdOMVZXt1WHO67CT8Mb68Ql76F+0FQPuGbJhP2 jc0O5juW/g3v59w47XvpwU9S0/epDcvbi/FigRYD+wU0FDgvOYQYAJdiUA1arKN069s9 GKmirwG2P/Hy85BtFwK/ctlUQHbprvXbMbvKPPGcZhuWD2llSax8OtICscqdoiwr2Hzu HcWBxFbrH7wfunMiUeqAKAC5Cbsg/dBFOXkyDNXV6YfSl3T2iBVJvaqMJ3M6IIteUTay U0qsv9EeaLtSJR/ojdt9WsKs/g8H/AgOB9VdHP+f3ZMIyaeY8btT4AerHzgh8dnRdJRV 0tFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Pl2jE7GB; 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 k32si27295718pjb.11.2019.07.30.11.10.27; Tue, 30 Jul 2019 11:10:42 -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=pass header.i=@nifty.com header.s=dec2015msa header.b=Pl2jE7GB; 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 S1730652AbfG3RWh (ORCPT + 99 others); Tue, 30 Jul 2019 13:22:37 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:36781 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbfG3RWh (ORCPT ); Tue, 30 Jul 2019 13:22:37 -0400 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (authenticated) by conssluserg-02.nifty.com with ESMTP id x6UHMNKY020045; Wed, 31 Jul 2019 02:22:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com x6UHMNKY020045 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1564507344; bh=Vqhm/EITINFOuWf1dLL2W5rIciZKR5IQ8djNbAIk8l8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Pl2jE7GBagAabKrLbkzMbY+ibYE8KzcXaQCbgrTVOGPadBcYxVRWeiIdEpNBqIZkY ++JX/YvtutxD+ZajE6BFbS8+UQWPF3TGIOtXo06hJDAGtGKt4Hsm1stRmNFMeRMspt V3vRpB+trdLqZuRh4ld+3BzztEFD+vWGFAEPx0zkm9c6vICZyx2JplO3zJ2v8o24Zj D3ey0N+/nH9ddHSlOXNMcKTKYLhFVJvrVrkSrt/sjFFo26scD7tG8QaZboa88lR0X3 g2uskjOLXlkzzrA+Fkty0aITU5/0BIr1JbfYSx0Ko/g4xV1DqwQYEQmfnkh1cKILeJ ETqVKnZnnMj/g== X-Nifty-SrcIP: [209.85.222.52] Received: by mail-ua1-f52.google.com with SMTP id 34so25763419uar.8; Tue, 30 Jul 2019 10:22:24 -0700 (PDT) X-Gm-Message-State: APjAAAU/42OeKrPpC4Q4JmHGr+8KfE17eqJORwQyTYnDRbDLMUdCHkZI E75Xzt+QmhSWFeb032VhEKv8AJgMMD5nHMW+wWQ= X-Received: by 2002:a9f:2265:: with SMTP id 92mr59702366uad.121.1564507342867; Tue, 30 Jul 2019 10:22:22 -0700 (PDT) MIME-Version: 1.0 References: <20190714152817.24693-1-efremov@linux.com> <20190729141801.31333-1-efremov@linux.com> <20190730082618.5bb5edf3@canb.auug.org.au> <1b6f749c-2a25-219a-3eb3-0f2c7a542426@linux.com> In-Reply-To: From: Masahiro Yamada Date: Wed, 31 Jul 2019 02:21:46 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] modpost: check for static EXPORT_SYMBOL* functions To: Denis Efremov Cc: Stephen Rothwell , Michal Marek , Emil Velikov , Linux Kbuild mailing list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 1:44 AM Denis Efremov wrote: > > On 30.07.2019 19:29, Masahiro Yamada wrote: > > I prefer this, but why do you need to check type? > > > > Doesn't this work? > > > > for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { > > unsigned char bind = ELF_ST_BIND(sym->st_info); > > > > struct symbol *s = find_symbol(remove_dot(info.strtab + > > sym->st_name)); > > > > if (s && (bind == STB_GLOBAL || bind == STB_WEAK)) > > s->is_static = 0; > > } > > This works. However, I thought it will be too costly to call find_symbol > on each symbol. Hence, 'type == STT_OBJECT || type == STT_FUNC || type > == STT_NOTYPE' is a small performance optimization because we need to > check only variables and functions. Is it worth to remove it in v4? > > Denis I checked the symbol table for ppc64_defconfig. The following is the number of entries for each combination of type and bind. [1] type: STT_NOTYPE, bind: STB_LOCAL -> 39502 entries [2] type: STT_NOTYPE, bind: STB_GLOBAL -> 30161 entries [3] type: STT_NOTYPE, bind: STB_WEAK -> 5 entries [4] type: STT_OBJECT, bind: STB_LOCAL -> 60326 entries [5] type: STT_OBJECT, bind: STB_GLOBAL -> 4126 entries [6] type: STT_OBJECT, bind: STB_WEAK -> 11 entries [7] type: STT_FUNC, bind: STB_LOCAL -> 38816 entries [8] type: STT_FUNC, bind: STB_GLOBAL -> 56196 entries [9] type: STT_FUNC, bind: STB_WEAK -> 350 entries [10] type: STT_SECTION, bind: STB_LOCAL -> 9027 entries [11] type: STT_FILE, bind: STB_LOCAL -> 2918 entries Checking 'type' beforehand saves only 11945 look-ups ( [10] + [11]). You can check 'bind' before the look-up, not after. If bind == STB_LOCAL, you do not need to lookup the hash-table, since you do not do anything. This saves [1], [4], [7], [10], [11]. I think the following is simpler, and works more efficiently. for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { unsigned char bind = ELF_ST_BIND(sym->st_info); if (bind == STB_GLOBAL || bind == STB_WEAK) { struct symbol *s = find_symbol(remove_dot(info.strtab + sym->st_name)); if (s) s->is_static = 0; } } -- Best Regards Masahiro Yamada