Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp39513lqk; Fri, 8 Mar 2024 22:57:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVVX4yYnc8zNEDkpFAX5GlLislf7m9qbhZvaPiIv08FL1ijwAR/7wvyiCpXhYwK5YB0NQrJxqxEvzG0heAJpOCWofROdxH5TjrZeOdJ9A== X-Google-Smtp-Source: AGHT+IEVJIflSmfCt0BO4hsIXq84nkaAtPs9WU0KZsd4yAoUNTxFowHf1sBsPP2G7JxsAPjW6tb8 X-Received: by 2002:a17:906:99ce:b0:a45:20e3:688e with SMTP id s14-20020a17090699ce00b00a4520e3688emr504577ejn.56.1709967425172; Fri, 08 Mar 2024 22:57:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709967425; cv=pass; d=google.com; s=arc-20160816; b=LetxQs3dOhtQIpFEl2pPNItzaU8sbL8U137/VlCv8uwOCUkSc4dWPCu/EAP9e9Rdiq 8cgedpBaTv2KUGrmiGrc8zooC/f8+UHlZZgLRyEkRA76AwILBzRyqfsb143/jj2zk4c6 RLx2uk1Ts+RL7Z2JMu7QGRfb65yc1WSuRmHukee1S7sjzOs8cBi/I4xpgaw2wOnkMsXF ZFuIQS7M2/aAVhXf2DCjAuvtPVYhshGVhaH63u5RIUQkJJe+M3Z/nP7G+WjcE3581ZBq EB1CFFjAKvdPNVKWxy+me6J+9E+JVIMwHnE2NNk4f7xsHwQJmU1wO6mObKppMw2d4pFZ VAQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=roOLoXUMwlg99HjQIL7OyjG6G1hlceg1OaBpdD491Tc=; fh=2WQUlt3YPZMuSuIqHQ+jU+2KEMF7JuiPlQVlvGKPwww=; b=Ky9F1s5g4Sfu/RaDMivF9khkdxfwj6Xpn3PPGoamdL90KcDc+0nhMxZNNbmQDYC/4/ DVDrvT3OqDdG+AweOmt+macrGiKG50SUddts0UqmWAEqiPtE/AjWaSrwZwk1BTH3iKBg Zg6SurtcYwrIqpsLW4boAWcOnzI9NWRU4turaI/YWD2LwolHVeK6CiRFk29lV38imiLw FVJkydA8alXB99Qk2UnOx7FmAaxaAABM5TaXO42ejGa0laHlNWxOE7L6Mlag8dBahDXY TPIuri03qxxfpmwMjdAA9y9h8Ckj1l0Ak/EgH6AL2I2ZD2CWxXH1+yImjPpTb5O7X88i HinQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-97790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l23-20020a170906a41700b00a44f6a86f9asi520647ejz.147.2024.03.08.22.57.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 22:57:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-97790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D162E1F2188F for ; Sat, 9 Mar 2024 06:57:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 536FE364A9; Sat, 9 Mar 2024 06:56:58 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5661D1D558 for ; Sat, 9 Mar 2024 06:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709967417; cv=none; b=SrU3oTBtEZSo5EgYOsmXSac8Hju2l7jfNQEytLJM8/jv9wMCUAjRYHBvcK6AvROn5r5CIpnYQDpg7538R7CdO5K6NcW51sRCfBtm7+bNl3ZxK4dpaCXbXrpvas3TAU9bb62qBDRbUuXQdgFw1g/LUGe0J4ZcmUS9sk9vzlSlaDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709967417; c=relaxed/simple; bh=1qsQHg57H1LKQe3m/sT4lhmQzJvIZGKeFT5OHy8I0tM=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=LMgK1autTOkRZd3s1rrHf95YODA0RiH4sHvB+zwbZozIwZbodG0cO25DFfEFgkdxSlboVH2wblqjxS3xq4ht6qZ6Pq52ubnIS+GptliHEsanwrSK1pOZGfoznQZM/vnTwiBSYmH84xn+Vuhfmk/vkCUV4MSpvG2vJA+9l1JBrlE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TsDKq3tgmz2BfPp; Sat, 9 Mar 2024 14:54:23 +0800 (CST) Received: from dggpemd100004.china.huawei.com (unknown [7.185.36.20]) by mail.maildlp.com (Postfix) with ESMTPS id 2F95C1A016C; Sat, 9 Mar 2024 14:56:47 +0800 (CST) Received: from [10.67.109.211] (10.67.109.211) by dggpemd100004.china.huawei.com (7.185.36.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Sat, 9 Mar 2024 14:56:46 +0800 Message-ID: Date: Sat, 9 Mar 2024 14:56:46 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH-next v2] arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Content-Language: en-US To: Ard Biesheuvel , Arnd Bergmann CC: , , Fangrui Song , Russell King , Andrew Davis , Andrew Morton , "Kirill A. Shutemov" , Geert Uytterhoeven , Jonathan Corbet , Mike Rapoport , Rob Herring , Thomas Gleixner , Linus Walleij , References: <20240307151231.654025-1-liuyuntao12@huawei.com> <58cc1053-7208-4b22-99cb-210fdf700569@app.fastmail.com> From: "liuyuntao (F)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemd100004.china.huawei.com (7.185.36.20) On 2024/3/8 22:27, Ard Biesheuvel wrote: > On Fri, 8 Mar 2024 at 14:16, Arnd Bergmann wrote: >> >> On Thu, Mar 7, 2024, at 16:12, Yuntao Liu wrote: >>> The current arm32 architecture does not yet support the >>> HAVE_LD_DEAD_CODE_DATA_ELIMINATION feature. arm32 is widely used in >>> embedded scenarios, and enabling this feature would be beneficial for >>> reducing the size of the kernel image. >>> >>> In order to make this work, we keep the necessary tables by annotating >>> them with KEEP, also it requires further changes to linker script to KEEP >>> some tables and wildcard compiler generated sections into the right place. >>> >>> It boots normally with defconfig, vexpress_defconfig and tinyconfig. >>> >>> The size comparison of zImage is as follows: >>> defconfig vexpress_defconfig tinyconfig >>> 5137712 5138024 424192 no dce >>> 5032560 4997824 298384 dce >>> 2.0% 2.7% 29.7% shrink >>> >>> When using smaller config file, there is a significant reduction in the >>> size of the zImage. >>> >>> We also tested this patch on a commercially available single-board >>> computer, and the comparison is as follows: >>> a15eb_config >>> 2161384 no dce >>> 2092240 dce >>> 3.2% shrink >>> >>> The zImage size has been reduced by approximately 3.2%, which is 70KB on >>> 2.1M. >>> >>> Signed-off-by: Yuntao Liu >> >> I've retested with both gcc-13 and clang-18, and so no >> more build issues. Your previous version already worked >> fine for me. >> >> I did some tests combining this with CONFIG_TRIM_UNUSED_KSYMS, >> which showed a significant improvement as expected. I also >> tried combining it with an experimental CONFIG_LTO_CLANG >> patch, but that did not show any further improvements. >> >> Tested-by: Arnd Bergmann >> Reviewed-by: Arnd Bergmann >> >> Adding Ard Biesheuvel and Fangrui Song to Cc, so they can comment >> on the ARM_VECTORS_TEXT workaround. I don't understand enough of >> the details of what is going on here. >> > > Thanks for the cc > >> Full quote of the patch below so they can see the whole thing. >> >> If they are also happy with the patch, I think you can send it >> into Russell's patch tracker at >> https://www.armlinux.org.uk/developer/patches/info.php >> > > No, not happy at all :-) > > The resulting kernel does not boot (built with GCC or Clang). And the > patch is buggy (see below) > After applying .reloc .text, R_ARM_NONE, ., the resulting kernel boots well in QEMU. I tested it with the latest linux-next master branch and the mainline master branch. By the way, I used vexpress_defconfig for testing, it worked.