mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qi Xi <xiqi2@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ben Niu <benniu@meta.com>,
	Jinjiang Tu <tujinjiang@huawei.com>, <wangkefeng.wang@huawei.com>,
	<sunnanyong@huawei.com>, Qi Xi <xiqi5703@163.com>
Subject: Re: [PATCH v4 0/2] arm64: speed up __arch_copy_from_user() for large copies
Date: Tue, 1 Dec 2026 19:58:46 +0800	[thread overview]
Message-ID: <6de2f988-e6f5-4a25-a51e-d7c4a5e55248@huawei.com> (raw)
In-Reply-To: <20261116072512.1323883-1-xiqi5703@163.com>

Kindly ping.  v4 has been up for two weeks now -
any suggestions?

Qi

On 16/11/2026 15:25, Qi Xi wrote:
> From: Qi Xi <xiqi2@huawei.com>
>
> Based on Ben Niu's "Faster Arm64 __arch_copy_from_user and
> __arch_copy_to_user" work [1], this series continues the optimization
> for __arch_copy_from_user() only, following Catalin's review of v3 [2].
>
> For copies of 4096 bytes or more, __arch_copy_from_user() uses
> privileged LDP instead of LDTR and toggles PSTATE.PAN for the duration
> of the copy, together with an offset-addressed 64-byte loop added to
> copy_template.S.  Smaller copies keep the original code.
>
> copy_to_user() is deliberately left alone.  Clearing PAN and using
> privileged STP there puts the PAN update in the middle of the user
> store stream, which breaks hardware write streaming; on Kunpeng 920
> the resulting regression outweighs the gain from paired stores.
>
> Performance improvements measured on Kunpeng 920:
>
> The ku_copy microbenchmark [3] (a kernel module that measures
> copy_from_user throughput across various sizes by copying 1GB of
> data in each test):
> copy_from_user throughput change (positive = improvement):
> 8B-2048B: ~0% (not covered by this optimization, no regression)
> 4KB: +2.0%   8KB: +19.1%  16KB: +29.8%  32KB: +36.5%
> 64KB: +38.0%  128KB: +57.9%  256KB: +71.2%
>
> Real-world workloads:
> - iperf3 over virtio-net/tap in a two-level PVM stack
> (L1 send to KVM L2 guest):
> Throughput improved from 38.5 to 50.1 Gbps (+30%).
> copy_from_user hotspot in the QEMU main-loop thread reduced
> from 68% to 55%.
> - meshproxy:
> 256KB request latency reduced from 0.91 ms to 0.78 ms (-14%)
> at 16 connections / 16k QPS.
>
> Changes since v3:
>   - No global PAN disabling.  PAN is toggled only around the
>     new fast path, so LDTR/STTR remain the default for every
>     other copy and keep protecting against user-controlled kernel
>     accesses, as Catalin pointed out.
>   - Fault semantics fixed: every load in the 64-byte loop has its own
>     exception table entry, and the fixup advances dst by the number of
>     16-byte blocks that were actually stored.  A fault in the middle of
>     the loop now returns the number of bytes really not copied instead.
>   - A 4096-byte threshold is added; from there on the new path is
>     used, since toggling PAN also has a cost.
>   - copy_to_user() is deliberately left alone.
>
> [1] https://lore.kernel.org/all/20251018052237.1368504-2-benniu@meta.com/
> [2] https://lore.kernel.org/all/20260316123100.82932-1-xiqi2@huawei.com/
> [3] https://github.com/mcfi/benchmark/tree/main/ku_copy
>
> Qi Xi (2):
>    arm64: copy_template: add an offset-addressed 64-byte loop
>    arm64: copy_from_user: use privileged LDP/STP for large copies
>
>   arch/arm64/lib/Makefile             |   2 +-
>   arch/arm64/lib/copy_from_user.S     |   8 ++
>   arch/arm64/lib/copy_from_user_opt.S | 114 ++++++++++++++++++++++++++++
>   arch/arm64/lib/copy_template.S      |  35 +++++++++
>   4 files changed, 158 insertions(+), 1 deletion(-)
>   create mode 100644 arch/arm64/lib/copy_from_user_opt.S
>

      parent reply	other threads:[~2026-12-01 11:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  7:25 Qi Xi
2026-11-16  7:25 ` [PATCH v4 1/2] arm64: copy_template: add an offset-addressed 64-byte loop Qi Xi
2026-11-16  7:25 ` [PATCH v4 2/2] arm64: copy_from_user: use privileged LDP/STP for large copies Qi Xi
2026-12-01 11:58 ` Qi Xi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6de2f988-e6f5-4a25-a51e-d7c4a5e55248@huawei.com \
    --to=xiqi2@huawei.com \
    --cc=benniu@meta.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=sunnanyong@huawei.com \
    --cc=tujinjiang@huawei.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=xiqi5703@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®