From patchwork Tue May 23 16:54:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13252679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6AA7C77B75 for ; Tue, 23 May 2023 17:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7I+xffHZN8SUDyp9NdcB6cdpGUJtaeYYlgj62VcSCKA=; b=X4YhsYXnicIo2h 6B+6Mblj0wa9qcrtKUc92mqTyEzJpGw8W6ZzoTCjVUaC/esdAE0XQiEMiFHUHs3mm3A1Eh2Qpggqo PwQssYkefgIQfYI+jhdpob0w5RsS9dV3qqAB42vDL8dnlhIx3Mb92wjFKbz0J16pZntNyY+eovQz4 cJRcrbKnYmwMqqi0cUX/436lS4ejTw3+kjsVVhMn04GF5r36yr2STxmAlKUclkKmleWgoUQ6B8N0s NNifAtjvdwogcmU5ZaNBk2eno3bEp2xayOXu9E3NXy2z10Mpgcv9AucLWz6I595E2ePXX7K7j/J3o SSWlzREe+huJQjzm9ufA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSm-00Atre-24; Tue, 23 May 2023 17:06:20 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSj-00Atpz-1c for linux-riscv@lists.infradead.org; Tue, 23 May 2023 17:06:18 +0000 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 99102634DA; Tue, 23 May 2023 17:06:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AD21C433EF; Tue, 23 May 2023 17:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684861576; bh=SFEBsgS/NuRbYn+gTRqLbgprOTjrzQzmKyN1/QnzNYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XenmqGcNT+t9qREdaU2ysYcIrUHpRMEc/ixHRS0pmUd7QY0KabDK/R6NircioTAuJ C7x3Ylv1KgugarEwJ9GU+bPjhCS1Q8UUOZTWKb/IRnmSFQ0vx3TnAKOGE5gGFxeUH/ vuWaDnQabyFUby68WbawVbE8Y5nty4ufPSLiMoFvszoD5j5aMGQ9/8nhVE3TyfkvFS lT6/qHnfvJ04hCUxy2jjo+k1GMEMfplP3blZT10wvxktFFVxpu3/1obmI737YIeLx1 fTecEVciQvmOw8zTVMuK7C1wUprgRIeJWue9u3DsoEPzJwqaNovFNNa/mz45MRTXna ujbRbtZMYMyWQ== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH v2 1/4] riscv: move options to keep entries sorted Date: Wed, 24 May 2023 00:54:59 +0800 Message-Id: <20230523165502.2592-2-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230523165502.2592-1-jszhang@kernel.org> References: <20230523165502.2592-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_100617_574527_E9504E1E X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Recently, some commits break the entries order. Properly move their locations to keep entries sorted. Signed-off-by: Jisheng Zhang Reviewed-by: Conor Dooley Acked-by: Guo Ren --- arch/riscv/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 348c0fa1fc8c..8f55aa4aae34 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -101,6 +101,11 @@ config RISCV select HAVE_CONTEXT_TRACKING_USER select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS if MMU + select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE) + select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE + select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL + select HAVE_FUNCTION_GRAPH_TRACER + select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION select HAVE_EBPF_JIT if MMU select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ERROR_INJECTION @@ -110,7 +115,6 @@ config RISCV select HAVE_KPROBES if !XIP_KERNEL select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL select HAVE_KRETPROBES if !XIP_KERNEL - select HAVE_RETHOOK if !XIP_KERNEL select HAVE_MOVE_PMD select HAVE_MOVE_PUD select HAVE_PCI @@ -119,6 +123,7 @@ config RISCV select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_REGS_AND_STACK_ACCESS_API + select HAVE_RETHOOK if !XIP_KERNEL select HAVE_RSEQ select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS @@ -142,11 +147,6 @@ config RISCV select TRACE_IRQFLAGS_SUPPORT select UACCESS_MEMCPY if !MMU select ZONE_DMA32 if 64BIT - select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE) - select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE - select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL - select HAVE_FUNCTION_GRAPH_TRACER - select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION config CLANG_SUPPORTS_DYNAMIC_FTRACE def_bool CC_IS_CLANG From patchwork Tue May 23 16:55:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13252683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24A5DC7EE23 for ; Tue, 23 May 2023 17:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YODRhcXmrNjXrCDfVhKYqNsTByFTDPEOfKOZao+u+EI=; b=36o8B4kTNES7lY va4UmF79fCrftv4bxjLHTz8Yq9hDSo15jznqmFqQC4r5Xlh+4RZrATE/yD+Logi6FrOFzUEiO/2j6 PIzMmbokLy9HbdJGHf/CWnNN7Vf3fbs+vs73ScvWJfMHK4PG//qaLHMmEiaHDXvLEbrYNK10zpRoa U785Dlq8JRNMivwNeSVpkSJwkKPMdHXL4WgmXqHchzgzrFEDSjz1mQcJOKWLAfmA1mifd+EiWVF8B iqdG3ZFwkN+UXztFsDDeXEZgvDKQbcfyc1WmmVsf+NxSHMYUC0+vnQzS/6jKSAEkX1MeaqPmtrJhl w0mpcoH4kGOeGT5fC/zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSp-00Atse-0q; Tue, 23 May 2023 17:06:23 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSl-00Atr5-0x for linux-riscv@lists.infradead.org; Tue, 23 May 2023 17:06:20 +0000 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 E20EA634C3; Tue, 23 May 2023 17:06:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7886FC4339B; Tue, 23 May 2023 17:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684861578; bh=S1v3epwjKPZhhmwrrwdqziIQP7+cuuUHEgza9tY/ky4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VroAEK5OljQLhXtHf6feHA8/FP9OXYl6sjuMlhJsY8l8KPby6JgzKKo6wcnYW31kk 7699dMhJ4mj/3Sez4d4jeyXrd9ERwFEGrqRI4zLewef48JVaieRPxC68pFZq3gnrG0 QwLsevTvH5HQg2BMVx3o/K6NDABDbh/+eAmtHw4GRUCBfZkUonc6oKYSTltVEvG2ei wGp8bjpvxifPQIq+Vr3n/eYYBZuKYC77OR2xuYa91Vrd6O0cZDX3KKmKqEfPF3jLBK OXdEs3T9UefBk5W3LeStb3eKkp+/XzUWYJ/awKpJCTvSoEsiEa17E2YSrtqZ4j32yM 2VuLUKy8tPE7Q== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Conor Dooley Subject: [PATCH v2 2/4] riscv: vmlinux-xip.lds.S: remove .alternative section Date: Wed, 24 May 2023 00:55:00 +0800 Message-Id: <20230523165502.2592-3-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230523165502.2592-1-jszhang@kernel.org> References: <20230523165502.2592-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_100619_370885_B447A625 X-CRM114-Status: UNSURE ( 8.92 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ALTERNATIVE mechanism can't work on XIP, and this is also reflected by below Kconfig dependency: RISCV_ALTERNATIVE ... depends on !XIP_KERNEL ... So there's no .alternative section at all for XIP case, remove it. Signed-off-by: Jisheng Zhang Reviewed-by: Conor Dooley Reviewed-by: Guo Ren --- arch/riscv/kernel/vmlinux-xip.lds.S | 6 ------ 1 files changed, 6 deletions(-) diff --git a/arch/riscv/kernel/vmlinux-xip.lds.S b/arch/riscv/kernel/vmlinux-xip.lds.S index eab9edc3b631..50767647fbc6 100644 --- a/arch/riscv/kernel/vmlinux-xip.lds.S +++ b/arch/riscv/kernel/vmlinux-xip.lds.S @@ -98,12 +98,6 @@ SECTIONS __soc_builtin_dtb_table_end = .; } - . = ALIGN(8); - .alternative : { - __alt_start = .; - *(.alternative) - __alt_end = .; - } __init_end = .; . = ALIGN(16); From patchwork Tue May 23 16:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13252680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED5E2C7EE31 for ; Tue, 23 May 2023 17:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xve3aSYVASxQmW4GwuuoBNOc96C62kSjvZUPVa+S7a0=; b=ISLhRwSqaI83Oa JBS3CX1Oje60LvWVw0YVIAlFpF0c7hrHjWjLYtQdadZKalchOdDvdU1Vs/OTIR+JiA6uJ2ni4+n65 q8xfUFrv2RJ1ezgThs5DXAPK6ExGmuKpSaAS5ULJQm3+0NY/WeR7RF+c/eVWQHnESIfxtl1hZuztQ erPwzF6TfIHt1vJv61qElNcSIbVBXcPAVx/aTJeCBQkJPUGpsvcFPXt9paxlbFsJ1Zu5t7nWCWEth i4EUJhNIkGSc5ec8fjIEf+yu2dpIIcnEsb2dN2/IUgd8FM0iBar1Bw7BLLEcWwhQXIuF15fV7ymIn EjnDySQADcdhXlfvvKtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSp-00AttA-2c; Tue, 23 May 2023 17:06:23 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSn-00Ats4-1M for linux-riscv@lists.infradead.org; Tue, 23 May 2023 17:06:22 +0000 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 0D0C6634D4; Tue, 23 May 2023 17:06:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2DAFC4339C; Tue, 23 May 2023 17:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684861580; bh=XDpfU4QGkxHCk0PcVXqfWjLiQT8efnUkxx2g6qxryQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekUkv+8Udgo0rQGikUzgVt1U+8VG4DYIqET6gmM4S7k9goJGn3cE6EIVMWx3nHzXX yBXZL/2rbnb2TMN2LJSbanLZck5wX+V8ygTKDIsZ+gxcaADr23j0vJlC2BY2vnfTDZ TZU8C+c9+M24vwOjravcJ8o3dk+YCUMk+Sqf7N+Bud9SE7IPtJrIoGHtUIbgtb3dwS 1BIos3/riAF8xW30yQ+SBN3Twvf4DDzykyhu6HoyL3/zpF90sp/6cCdeXI5ZG0/8DQ 1NI+5pZPAcfFAOsHiy2qs0k0ZFXtXkbymsvFmGP9I6UTbPYChQmMEc/Ep1tRlqv4MD xC48ZkFtW+JUg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH v2 3/4] vmlinux.lds.h: use correct .init.data.* section name Date: Wed, 24 May 2023 00:55:01 +0800 Message-Id: <20230523165502.2592-4-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230523165502.2592-1-jszhang@kernel.org> References: <20230523165502.2592-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_100621_494194_C9DFA596 X-CRM114-Status: GOOD ( 11.77 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org If building with -fdata-sections on riscv, LD_ORPHAN_WARN will warn similar as below: riscv64-linux-gnu-ld: warning: orphan section `.init.data.efi_loglevel' from `./drivers/firmware/efi/libstub/printk.stub.o' being placed in section `.init.data.efi_loglevel' I believe this is caused by a a typo: init.data.* should be .init.data.* Signed-off-by: Jisheng Zhang Reviewed-by: Kefeng Wang --- include/asm-generic/vmlinux.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index d1f57e4868ed..371026ca7221 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -688,7 +688,7 @@ /* init and exit section handling */ #define INIT_DATA \ KEEP(*(SORT(___kentry+*))) \ - *(.init.data init.data.*) \ + *(.init.data .init.data.*) \ MEM_DISCARD(init.data*) \ KERNEL_CTORS() \ MCOUNT_REC() \ From patchwork Tue May 23 16:55:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13252682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5FE4C7EE23 for ; Tue, 23 May 2023 17:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m/NlQEA73ZOtUqus4UJ1aXKlJKuoN2FlbZex+EATjaQ=; b=DpB+xPyuDZUDJ0 dnC3Rzz8K2KRoe26EIbFGHarGDItKuTNNZbdhQfTyKzKFKHQeYBrKFk0WaQmsWEDNA2uqX/qTYmhO qhiWiJiz/iJmi+12d9ylWS9LsgurrX+Kg1+3MBtcRzlOExCjPF+ABIAHSs6rADjqDUtNqV49fKBNr xzW6veHx3rZTxbS7zxwXMB7rBmhQr7faenLDJxOhfJChpUfxes0dYHDoFsfrFobvU3+/IQ44w4zko G6BRlx7UO3LL14ujZEk9yVnO6hOUb76yTeSws5ohajxDPU4quXU1POg1QEPvNGnsYHuW/Vr4uz6aL JkLjnnKwnj6Btlwm3bmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSt-00Atv3-1O; Tue, 23 May 2023 17:06:27 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1VSq-00AttT-0f for linux-riscv@lists.infradead.org; Tue, 23 May 2023 17:06:25 +0000 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 BC1E16186E; Tue, 23 May 2023 17:06:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4BE7C4339B; Tue, 23 May 2023 17:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684861583; bh=J4geLF9/wB/nci7eyTPzHGp1IQrIjTH306iCGvwIsQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tzqNIne/apjydPkehRRhk/0O0hkReo4pjcZtGnV4WX7abAD5K4e3kuBRAVahk8os8 NaRieZa7LqgDjJyjU1AXbv8j08bEFYKRnT2K5WaUoYsQG7u6dbZmYRa4w1lrVkLGKk AfNwCokEOjU34OHzwDt15ZOWzmY2EYcrAgK1lSiNg/G/2OrctV9LzlJcKjD0Xx2O5K 5QLRx+rWuzOuVStoft7q68LYRA02Ic6uHJtnWRJcDd5b682rKLWJKDIChj3ot3PNGU Oph96bKhybNTihKFHNrXw/h8maDWRzFbCZ2O4FrUuNE1nqNc9I2eedAOXS8Uji5dXA KoeOlvBux09Rg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Zhangjin Wu , Guo Ren , Bin Meng Subject: [PATCH v2 4/4] riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Date: Wed, 24 May 2023 00:55:02 +0800 Message-Id: <20230523165502.2592-5-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230523165502.2592-1-jszhang@kernel.org> References: <20230523165502.2592-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_100624_330286_C87A04A4 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Zhangjin Wu Select CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION for RISC-V, allowing the user to enable dead code elimination. In order for this to work, ensure that we keep the alternative table by annotating them with KEEP. This boots well on qemu with both rv32_defconfig & rv64 defconfig, but it only shrinks their builds by ~1%, a smaller config is thereforce customized to test this feature: | rv32 | rv64 --------|------------------------|--------------------- No DCE | 4460684 | 4893488 DCE | 3986716 | 4376400 Shrink | 473968 (~10.6%) | 517088 (~10.5%) The config used above only reserves necessary options to boot on qemu with serial console, more like the size-critical embedded scenes: - rv64 config: https://pastebin.com/crz82T0s - rv32 config: rv64 config + 32-bit.config Here is Jisheng's original commit-msg: When trying to run linux with various opensource riscv core on resource limited FPGA platforms, for example, those FPGAs with less than 16MB SDRAM, I want to save mem as much as possible. One of the major technologies is kernel size optimizations, I found that riscv does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which passes -fdata-sections, -ffunction-sections to CFLAGS and passes the --gc-sections flag to the linker. This not only benefits my case on FPGA but also benefits defconfigs. Here are some notable improvements from enabling this with defconfigs: nommu_k210_defconfig: text data bss dec hex 1112009 410288 59837 1582134 182436 before 962838 376656 51285 1390779 1538bb after rv32_defconfig: text data bss dec hex 8804455 2816544 290577 11911576 b5c198 before 8692295 2779872 288977 11761144 b375f8 after defconfig: text data bss dec hex 9438267 3391332 485333 13314932 cb2b74 before 9285914 3350052 483349 13119315 c82f53 after Signed-off-by: Zhangjin Wu Co-developed-by: Jisheng Zhang Signed-off-by: Jisheng Zhang Reviewed-by: Guo Ren Tested-by: Bin Meng Reviewed-by: Kefeng Wang --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/vmlinux.lds.S | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8f55aa4aae34..62e84fee2cfd 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -115,6 +115,7 @@ config RISCV select HAVE_KPROBES if !XIP_KERNEL select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL select HAVE_KRETPROBES if !XIP_KERNEL + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HAVE_MOVE_PMD select HAVE_MOVE_PUD select HAVE_PCI diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index e5f9f4677bbf..492dd4b8f3d6 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -85,11 +85,11 @@ SECTIONS INIT_DATA_SECTION(16) .init.pi : { - *(.init.pi*) + KEEP(*(.init.pi*)) } .init.bss : { - *(.init.bss) /* from the EFI stub */ + KEEP(*(.init.bss*)) /* from the EFI stub */ } .exit.data : { @@ -112,7 +112,7 @@ SECTIONS . = ALIGN(8); .alternative : { __alt_start = .; - *(.alternative) + KEEP(*(.alternative)) __alt_end = .; } __init_end = .;