From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54DD033375B for ; Thu, 27 Nov 2025 14:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764254680; cv=none; b=i3iatM0KTuvQ8ERKaURP06A+Hb3+X/wg/eH8bFFfqxkvjuaYzZdEBhuBbbwsBcHgcAEfHagVx5heawCLFNLSh3PWmtCUN2B97W1aZU6PZPU7dq3RFBMwDtU03Q13QsM3SL3uwVvxdwBGB+TwxvGmlb/WeUWn9R+bZXXMWnJ7DPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764254680; c=relaxed/simple; bh=t9mHAquP9UN0+D7qYWzH0TtkKPuYoI+DoHNUKwOpEcQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sxXr+8MiXT6CClMeErv/fIXgnoGpksiqplCFzVd13+ufinR6YOHuVfTdo7Qp1iSXJ3W8Kj4R5Q9Q1hWoLerHEin4Quqg/rHGqJBlbftPFloOuYdeA80kmm9v0+nOsFLfGQiO+L2HQm9g2Z9tvrAEBS/BiQw4QearGIKXZvIQhpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 84F6472C8CC; Thu, 27 Nov 2025 17:35:57 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 7A6CC7CCB3A; Thu, 27 Nov 2025 16:35:57 +0200 (IST) Date: Thu, 27 Nov 2025 16:35:57 +0200 From: "Dmitry V. Levin" To: Jinjie Ruan Cc: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, chris@zankel.net, jcmvbkbc@gmail.com, akpm@linux-foundation.org, macro@orcam.me.uk, charlie@rivosinc.com, deller@gmx.de, rostedt@goodmis.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] arm64: Avoid memcpy() for syscall_get_arguments() Message-ID: <20251127143557.GA2591@strace.io> References: <20251127123630.4149828-1-ruanjinjie@huawei.com> <20251127123630.4149828-3-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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251127123630.4149828-3-ruanjinjie@huawei.com> On Thu, Nov 27, 2025 at 08:36:30PM +0800, Jinjie Ruan wrote: > Do not use memcpy() to extract syscall arguments from struct pt_regs > but rather just perform direct assignments. > > The performance benchmarks with Generic Entry patch[1] with audit on > from perf bench basic syscall on kunpeng920 gives roughly a 1% > performance uplift and also aligns the implementation with > x86 and RISC-V. > > | Metric | W/O this patch | With this patch | Change | > | ---------- | -------------- | --------------- | --------- | > | Total time | 2.241 [sec] | 2.211 [sec] | ↓1.36% | > | usecs/op | 0.224157 | 0.221146 | ↓1.36% | > | ops/sec | 4,461,157 | 4,501,409 | ↑0.9% | > > 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> > > [1]: https://lore.kernel.org/all/20251126071446.3234218-1-ruanjinjie@huawei.com/ > Signed-off-by: Jinjie Ruan > --- > arch/arm64/include/asm/syscall.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h > index f3853047c28e..f3564ba97f7e 100644 > --- a/arch/arm64/include/asm/syscall.h > +++ b/arch/arm64/include/asm/syscall.h > @@ -82,9 +82,11 @@ static inline void syscall_get_arguments(struct task_struct *task, > unsigned long *args) > { > args[0] = regs->orig_x0; > - args++; > - > - memcpy(args, ®s->regs[1], 5 * sizeof(args[0])); > + args[1] = regs->regs[1]; > + args[2] = regs->regs[2]; > + args[3] = regs->regs[3]; > + args[4] = regs->regs[4]; > + args[5] = regs->regs[5]; > } > > static inline void syscall_set_arguments(struct task_struct *task, Please keep syscall_get_arguments() and syscall_set_arguments() in sync: if you replace memset() with direct assignments in one of these functions, please mirror the change in another. -- ldv