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 C208BEB64D8 for ; Thu, 15 Jun 2023 01:24:55 +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: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:In-Reply-To:References: List-Owner; bh=fGYuYrA48uSkcD4DhqDbz25EAKZnyaJLEF5An8knR2U=; b=RO0HD+R4xa+BD7 Yz4hzdrsAyrh0A9jDA81qi9DJAhIVoRGhkxqNK8dHk8XC+Yot65pSywbYga3NF1UF3MqrwqudhDmG S2tBTGYA8Tt2UkIbdN16HeYeyg7fadZNN46HIw2n2a2DI9tEGHurlHF5/swq7Q9tb1yfRl7FVkSCu hy1tkkZRir6ZTtCh2O0b1JrUA737fDH8yrPTRhccl/n4VERtO/gT90BIFulyXA9lYwID0Ph3+gna7 xxenHf5cFYoWcrMzNWw3eA4AUyw9egiM+SeM9IEVRukJKNS4k/6nk8jwGMC/c5zC+IRjD7B+q6ivB GO/ZLJGxGlgqQhxE7LLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9biv-00DEbw-26; Thu, 15 Jun 2023 01:24:29 +0000 Received: from smtpbguseast3.qq.com ([54.243.244.52]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9bir-00DEYG-20 for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 01:24:28 +0000 X-QQ-mid: bizesmtp66t1686792198twp0ap2p Received: from localhost.localdomain ( [113.200.76.118]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 15 Jun 2023 09:23:15 +0800 (CST) X-QQ-SSF: 01400000000000D0H000000A0000020 X-QQ-FEAT: c42nD1GNGylbr/4PlIPgkuMmtrv1jTm9UyLvydT9BUB2vjOS9pnhH4Z0CbRgf uP/DgKRb/IxQJSVNcHkHP9db4sY5NdOnYo1iYCQnX5JTGFcbpMiDXUBnzIXlHCEVDVKz+56 NbIi7gbNYtejvVKTlpH+t3E5gwbVaN4hbhDqXpOoauz7jZlc3eBCd1F3x8PDnpfV6PvSCbd 8INPgkVLWyY2oC1IDVJ9RbHwlVB4durBUesuvvU29cnAABN8sVmaXHhmBF66LdUxgBApYQB VPTLRwyCZwGqovtWo0ML6SLhxNdo6Sz0jTZ2GE0Eau5pN9RuMkciWOxVZJIFOC2WYYcBWbC e3zaE5GJpn22swEodTN+qv5p0LRKtW73BBEHu5kvYn26NJu2Jz2YaYKGR0aag== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 17385603460462801352 From: Guo Hui To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, broonie@kernel.org Cc: kuba@kernel.org, yury.norov@gmail.com, Jason@zx2c4.com, wangxiaohua@uniontech.com, Guo Hui Subject: [RFC] arm64: syscall: add syscall inline Date: Thu, 15 Jun 2023 09:23:12 +0800 Message-Id: <20230615012312.20895-1-guohui@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybglogicsvrsz:qybglogicsvrsz4a-0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_182426_135692_5E60436D X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org I will introduce the advantages of syscall inline from the following four points: 1. Performance: syscall inline can improve syscall performance by about 2%. 2. Historical commit: f37099b6992a0b81 ("arm64: convert syscall trace logic to C") The purpose of this commit is to facilitate the operation of trace flags, so increasing the function call level is not the purpose. 3. The size of the kernel vmlinux file increases: 1408B, about 1K, which can be ignored. 4. Instruction layout and jumps: reduced jumps, more conducive to CPU cache, and should be more beneficial to scenarios where system calls are frequently used. Current instruction layout: the base address of el0_svc_common is smaller than the base address of el0_svc_handler, so it needs to jump backward every time in el0_svc_handler --------------------- | el0_svc_common | --------------------- | el0_svc_handler | --------------------- Instruction layout after syscall inline: el0_svc_handler contains el0_svc_common, so all instructions are executed in order, reducing jumps --------------------- | el0_svc_handler | --------------------- | el0_svc_common | --------------------- If only the function el0_svc_common is inlined, but not the function invoke_syscall, the instruction layout will become as follows, and the function invoke_syscall still needs to jump, so both the function el0_svc_common and the function invoke_syscall need to be inlined --------------------- | invoke_syscall | --------------------- | el0_svc_handler | --------------------- Based on the above analysis, I think syscall inline should be better, but I am not sure if I have considered it thoroughly. Please give me some suggestions, thank you very much. Signed-off-by: Guo Hui --- arch/arm64/kernel/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index da84cf855c44..1403cfb83b84 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -38,7 +38,7 @@ static long __invoke_syscall(struct pt_regs *regs, syscall_fn_t syscall_fn) return syscall_fn(regs); } -static void invoke_syscall(struct pt_regs *regs, unsigned int scno, +static __always_inline void invoke_syscall(struct pt_regs *regs, unsigned int scno, unsigned int sc_nr, const syscall_fn_t syscall_table[]) { @@ -78,7 +78,7 @@ static inline bool has_syscall_work(unsigned long flags) int syscall_trace_enter(struct pt_regs *regs); void syscall_trace_exit(struct pt_regs *regs); -static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, +static __always_inline void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, const syscall_fn_t syscall_table[]) { unsigned long flags = read_thread_flags(); -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel