From nobody Mon Dec 1 21:30:46 2025 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 383EA3093AB for ; Mon, 1 Dec 2025 12:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764590818; cv=none; b=Cy3K7QyPjd89CSq4uj6+ahaZmPD8Fni8Q98unRl2QjaoQaCXMu+uBe7yKvRphH/QiiFpkLYHwo+ymGipgqSqNo9J8gsbwdpAoD6ZpO1HpYcnZJ0Uc9cjmjyPl4ShUNtpiHYHrCpVlBCMMR86CwgCXb35DHwJNtjDr8oBz2i884Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764590818; c=relaxed/simple; bh=9nhn89546O1lvm/XQH7lxWDiHGdRrQ+jMHUr7oL/qL0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GS/YlyUmn+zXuEKhGtNWapTVE3o6L/G2B4ZDyLT4V0y8Y3YRFqvDMd5hIYW7/XKK17MPK+YOoEF7bxMx4nK/PzAqhm1DjXDs964UIPpCGp8tLYHypz4cuyYlRZWGFoZ4hsh9fgbCDefOTuxTHcm607vrWrUzMtGRJhm8QhSj5ok= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=5fuseUdd; arc=none smtp.client-ip=113.46.200.226 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="5fuseUdd" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=QxUwcTasWefvx6WMBH8kfJ6j8Vy+jYr1BCP+24RtJxo=; b=5fuseUddg0mzdGN146s6tHbZhdSFutetc77lchrjUzNzDT2Q0nFwfVe15PVY5aeNr/XAAQX46 caVkmAd1/SC92RF+fXBgWqVUiL9h2t96W35Kpcq1b1eY0FdbhFTe8qlngiyIgIu/Gj1Pu2hCPIa Ef/JIC5NGKA7pRUslRtxuF4= Received: from mail.maildlp.com (unknown [172.19.163.17]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4dKjJR5lzszKm6D; Mon, 1 Dec 2025 20:04:55 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 710221A0188; Mon, 1 Dec 2025 20:06:47 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 1 Dec 2025 20:06:46 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH v2 1/2] syscall.h: Remove unused SYSCALL_MAX_ARGS Date: Mon, 1 Dec 2025 20:06:32 +0800 Message-ID: <20251201120633.1193122-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201120633.1193122-1-ruanjinjie@huawei.com> References: <20251201120633.1193122-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The "SYSCALL_MAX_ARGS" appears to have been unused since commit 32d92586629a ("syscalls: Remove start and number from syscall_set_arguments() args"), so remove it. Fixes: 32d92586629a ("syscalls: Remove start and number from syscall_set_ar= guments() args") Signed-off-by: Jinjie Ruan Reviewed-by: Russell King (Oracle) --- arch/arm/include/asm/syscall.h | 2 -- arch/arm64/include/asm/syscall.h | 2 -- arch/xtensa/include/asm/syscall.h | 1 - 3 files changed, 5 deletions(-) diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index 18b102a30741..574bbcc55382 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h @@ -92,8 +92,6 @@ static inline void syscall_set_nr(struct task_struct *tas= k, (nr & __NR_SYSCALL_MASK); } =20 -#define SYSCALL_MAX_ARGS 7 - static inline void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index 712daa90e643..f3853047c28e 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -77,8 +77,6 @@ static inline void syscall_set_nr(struct task_struct *tas= k, } } =20 -#define SYSCALL_MAX_ARGS 6 - static inline void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args) diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/sy= scall.h index 7db3b489c8ad..bab7cdd96cbe 100644 --- a/arch/xtensa/include/asm/syscall.h +++ b/arch/xtensa/include/asm/syscall.h @@ -61,7 +61,6 @@ static inline void syscall_set_return_value(struct task_s= truct *task, regs->areg[2] =3D (long) error ? error : val; } =20 -#define SYSCALL_MAX_ARGS 6 #define XTENSA_SYSCALL_ARGUMENT_REGS {6, 3, 4, 5, 8, 9} =20 static inline void syscall_get_arguments(struct task_struct *task, --=20 2.34.1 From nobody Mon Dec 1 21:30:46 2025 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 CA02D3090C6 for ; Mon, 1 Dec 2025 12:06:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764590813; cv=none; b=tzoMFWt9FrwBpPBiTxcUkxeBNJuMNKlo9Aia+Oyk0E4WX2XviSyL/o/xk3y5IoFNlBFJ/uFLwSEvhF36pLs2cZ/KTy+N+0iuacVUItbGq3u5H6mVDy80ot3MMRklVaROZG9iKN5zJPG3s0HL6QbXHIV8cTbbLa2BQ+7Cm5/IahQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764590813; c=relaxed/simple; bh=Hi1pQKm34DVOn5/rYusxYfYx8730gwZpeSXqMIMVcBM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i6zL/dKmq867bmK56fGIN+leV++tupjJeR3bbj98Zmq17xnBx83utFp2I9HTrAyTDe7FcqkgwY+9c8hhxNfmZ1eal+kmogDRd10+G/ARLf74kTyV0W96d4hZB9nLdkeB7rH0fwZKx9tBiSLg0BcW8vyGagBlsfRqDeYpOxPPacg= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=UMVO+8O/; arc=none smtp.client-ip=113.46.200.223 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="UMVO+8O/" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=EO2I2CgTkYzQR5rgGKdTPMwTkcFuwC49Z6d2zKMlEXE=; b=UMVO+8O/QfFb46tf9tN3Y06oaTvPWAjYlQ9CaazqyXFzP3mOa+yUaBsJ7BZN2uRN1vhNxpkXY jgAtjAM+lShds+57BjmG91MfwMgRMIWOXUR/+2kHRF94pw73tez0IxdI+biqzLvLkqlDAYYloUu EPn8i+C/92kteC7usJWx8Vc= Received: from mail.maildlp.com (unknown [172.19.88.214]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4dKjJT1SszzmV73; Mon, 1 Dec 2025 20:04:57 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 608CC1A016C; Mon, 1 Dec 2025 20:06:48 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 1 Dec 2025 20:06:47 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH v2 2/2] arm64: Avoid memcpy() for syscall_get_arguments() Date: Mon, 1 Dec 2025 20:06:33 +0800 Message-ID: <20251201120633.1193122-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201120633.1193122-1-ruanjinjie@huawei.com> References: <20251201120633.1193122-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) Do not use memcpy() to extract syscall arguments from struct pt_regs but rather just perform direct assignments. Update syscall_set_arguments() too to keep syscall_get_arguments() and syscall_set_arguments() in sync. With Generic Entry patch[1] and turn on audit, the performance benchmarks from perf bench basic syscall on kunpeng920 gives roughly a 1% performance uplift. | Metric | W/O this patch | With this patch | Change | | ---------- | -------------- | --------------- | --------- | | Total time | 2.241 [sec] | 2.211 [sec] | =E2=86=931.36% | | usecs/op | 0.224157 | 0.221146 | =E2=86=931.36% | | ops/sec | 4,461,157 | 4,501,409 | =E2=86=910.9% | Disassembly shows that using direct assignment causes syscall_set_arguments() to be inlined and cuts the instruction count by five or six compared to memcpy(). Because __audit_syscall_entry() only uses four syscall arguments, the compiler has also elided the copy of regs->regs[4] and regs->regs[5]. Before: : aa0103e2 mov x2, x1 91002003 add x3, x0, #0x8 f9408804 ldr x4, [x0, #272] f8008444 str x4, [x2], #8 a9409404 ldp x4, x5, [x0, #8] a9009424 stp x4, x5, [x1, #8] a9418400 ldp x0, x1, [x0, #24] a9010440 stp x0, x1, [x2, #16] f9401060 ldr x0, [x3, #32] f9001040 str x0, [x2, #32] d65f03c0 ret d503201f nop After: a9408e82 ldp x2, x3, [x20, #8] 2a1603e0 mov w0, w22 f9400e84 ldr x4, [x20, #24] f9408a81 ldr x1, [x20, #272] 9401c4ba bl ffff800080215ca8 <__audit_syscall_entry> This also aligns the implementation with x86 and RISC-V. [1]: https://lore.kernel.org/all/20251126071446.3234218-1-ruanjinjie@huawei= .com/ Signed-off-by: Jinjie Ruan --- v2: - Also update syscall_set_arguments(). - Udpate the commit message. --- arch/arm64/include/asm/syscall.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index f3853047c28e..5e4c7fc44f73 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -82,16 +82,24 @@ static inline void syscall_get_arguments(struct task_st= ruct *task, unsigned long *args) { args[0] =3D regs->orig_x0; - args++; - - memcpy(args, ®s->regs[1], 5 * sizeof(args[0])); + args[1] =3D regs->regs[1]; + args[2] =3D regs->regs[2]; + args[3] =3D regs->regs[3]; + args[4] =3D regs->regs[4]; + args[5] =3D regs->regs[5]; } =20 static inline void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, const unsigned long *args) { - memcpy(®s->regs[0], args, 6 * sizeof(args[0])); + regs->regs[0] =3D args[0]; + regs->regs[1] =3D args[1]; + regs->regs[2] =3D args[2]; + regs->regs[3] =3D args[3]; + regs->regs[4] =3D args[4]; + regs->regs[5] =3D args[5]; + /* * Also copy the first argument into orig_x0 * so that syscall_get_arguments() would return it --=20 2.34.1