Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp624012pxb; Thu, 25 Feb 2021 10:42:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4NFgKs0eMgejZNX44Pm1/+tVvM6dkKEDjH+T3TERHM+0Ukeu74IkBo3EiR3sHDBSkF0ky X-Received: by 2002:a05:6402:3121:: with SMTP id dd1mr4479532edb.387.1614278534365; Thu, 25 Feb 2021 10:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614278534; cv=none; d=google.com; s=arc-20160816; b=0vBEdq/t2ErUw3KFRWIVLxProq4LUc5nPU/XZCP1rIgtzPmzI/7JDBDyd7fpUt4kB/ ggdE+QS5M/a0GP1HMmCESrm7hsTzNZ0rY4LMtzzIv25falQaIhi+DUrWBVrMczWY4fvY jlsEdmlKQhNx6E9bk/kXCWF10lHAgasGNZWNI4vL9glu7glMTB94s8pgyaLXeC4QlzWm McPHAhtV2399aeoOUMtbbOUyt4PgohBPBXBtfgAmxqBVEb83N2zmpW139rPrH6lOxvF7 ReD/g5orIITCAjANtImPCod0IgFiuazkxWljCZxuyYRcw979XRG37pbbw6t3Kb4BrzK/ arSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=Z8+kqUseSqK3HMya4Ci/I24by2e0cUeHUUPO5SCqTSk=; b=JcBUHA9WAMG2J5O8ceqJHUHkoc11QpVybjWU6HCHqorZzDKnRS00SD2wewmqL2ATmz IAHxJSEZKshmxkcrgXIthHXTs64coYO5+7JNLk5cIyrHe5hCixbTc9f/67OcbAJE3wSz YhP1TF5oAgMdv3xbKnB75N1TuYPtusriSQBZvNqWTvUcqWxTwt7divS2UChwKgECfRZe Sr37mPJknE5YoolFvlMKxcB/o+ULL1LtAR4Lxqx5ZoZBoT0LWxRrKPWkIfLMIfXLUiwM 90MPXMZGMZ8Ngu2I29YuxtlWWZOZTlt6LMatSLaZ+PIK5il6Tpz1IQmTcZ3hcWSdogyH knog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xu0mkMB1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si3749824eje.118.2021.02.25.10.41.50; Thu, 25 Feb 2021 10:42:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xu0mkMB1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233662AbhBYSku (ORCPT + 99 others); Thu, 25 Feb 2021 13:40:50 -0500 Received: from conssluserg-05.nifty.com ([210.131.2.90]:55149 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbhBYSj2 (ORCPT ); Thu, 25 Feb 2021 13:39:28 -0500 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (authenticated) by conssluserg-05.nifty.com with ESMTP id 11PIc4Jv028517 for ; Fri, 26 Feb 2021 03:38:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 11PIc4Jv028517 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1614278285; bh=Z8+kqUseSqK3HMya4Ci/I24by2e0cUeHUUPO5SCqTSk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=xu0mkMB1L98ZYI8HPHpra+xQjSZMMALM2zMY2EM+TBEZ8oUU0t/0HFYjOqYtUu3Qb 4LYRN2wk2SCZTVhgpvGupFywdeG80Oav5eKb5ZKOFLGcPBHYs/j3fnTJA8y2OEVIuX gQMBdRCi7OxekdNhCcnPh9bq2y+V2wPpd20wEtez1qg8RRG1+JftWhVv5j1kARLUwM zeQGsRB4x9scgAe9tzkSBPpSIzi7Npf+9Ov21vAQFW4U87c0qhu5iWvfsh5N4krKp3 yIe7Bj3njusLBa5DDnv/wqYwY3HvpBf3/FbwiTSQYrSd1ZfbkB42wqRM5HXG20EvED f5VXjwW+lawBQ== X-Nifty-SrcIP: [209.85.216.47] Received: by mail-pj1-f47.google.com with SMTP id o6so4074508pjf.5 for ; Thu, 25 Feb 2021 10:38:04 -0800 (PST) X-Gm-Message-State: AOAM530mIpsI25exhyYB+IyRqNELErjBLcgYW2LWLoo1/3fozn6sWSQu quH79HdJHa54T2qgxbaCbPw+luqps2g3eVmSZYw= X-Received: by 2002:a17:90a:5510:: with SMTP id b16mr4584900pji.87.1614278284075; Thu, 25 Feb 2021 10:38:04 -0800 (PST) MIME-Version: 1.0 References: <20210223200130.GA8059@lst.de> In-Reply-To: From: Masahiro Yamada Date: Fri, 26 Feb 2021 03:37:26 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] Modules updates for v5.12 To: Rasmus Villemoes Cc: Jessica Yu , Linus Torvalds , Christoph Hellwig , Linux Kernel Mailing List , =?UTF-8?Q?=EF=BF=BCMiroslav_Benes?= , Emil Velikov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 26, 2021 at 1:19 AM Rasmus Villemoes wrote: > > On 25/02/2021 16.49, Masahiro Yamada wrote: > > On Thu, Feb 25, 2021 at 4:36 AM Rasmus Villemoes > > wrote: > >> > >> On 24/02/2021 15.40, Masahiro Yamada wrote: > > > > > > Good insight. > > Actually, I came up with the same idea last night, and had started > > the implementation background. > > I needed sleep before completing the patch set, but > > now it is working as far as I tested. > > > > BTW, > > KEEP(*(SORT(___ksymtab+foo ___ksymtab+bar ___ksymtab+baz)) > > is a syntax error. > > > > ah, ok, didn't test anything, just threw it out there in case somebody > wanted to see if it was doable. > > Is that a limitation of SORT? The ld docs say > > There are two ways to include more than one section: > *(.text .rdata) > *(.text) *(.rdata) > The difference between these is the order in which the '.text' and > '.rdata' input sections will appear in the output section. > > so there shouldn't be a problem mentioning more than one section name? KEEP(*(foo bar)) and SORT(*(foo bar)) are both syntax error. I think having multiple entries in KEEP() / SORT() is sensible, but unfortunately the linker rejects this form. > >> If LD_DEAD_CODE_DATA_ELIMINATION was more widely supported (and I was > >> surprised to see that it's not even available on arm or x86) one could > >> also play another game, dropping the KEEP()s and instead create a linker > >> script snippet containing EXTERN(__ksymtab_foo __ksymtab_bar ...), > >> referencing the "struct kernel_symbol" elements themselves rather than > >> the singleton sections they reside in. > > > > Do you mean LD_DEAD_CODE_DATA_ELIMINATION must be enabled by default > > to do this? > > > > No, but without LD_DEAD_CODE_DATA_ELIMINATION, I don't see much point of > the TRIM_UNUSED_KSYMS. Yes, the export_symbol metadata itself vanishes, > but the actual functions remain in the image. Conversely, with modules > enabled, LD_DEAD_CODE_DATA_ELIMINATION can't do much when almost all of > the kernel can be built modular so almost extern interface is an > EXPORT_SYMBOL. At least, that's what I see for a ppc target with a > somewhat trimmed-down .config, combining the two gives much more space > saving than the sum of what each option does: > > $ size vmlinux.{vanilla,trim,dead,trim-dead} > text data bss dec hex filename > 6197380 1159488 121732 7478600 721d48 vmlinux.vanilla > 6045906 1159440 121732 7327078 6fcd66 vmlinux.trim > 6087316 1137284 120476 7345076 7013b4 vmlinux.dead > 5675370 1101964 115180 6892514 692be2 vmlinux.trim-dead > > Anyway, that was just an aside, probably the above ___ksymtab+foo thing > will work just fine. > > Rasmus Make sense. The combination of LD_DEAD_CODE_DATA_ELIMINATION and TRIM_UNUSED_KSYMS is more powerful than the stand-alone use of TRIM_UNUSED_KSYMS. I just expected the combination of LTO and TRIM_UNUSED_KSYMS would be even more powerful... Unfortunately, Clang LTO which lands in this MW cannot trim any code. So, it is useless for the purpose of eliminating unreachable code. -- Best Regards Masahiro Yamada