From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796126340; b=R2FGfJzaUChGkZ4qtvpQCeXfK1S2mIdf1q1fAfGIkzZ19PAwLqpN1rfoEwFr58Wd8EyP 4jVrKlJcYs5RGbkN114nYnHwLDwXPKbiO9UiHDeKcteCFdqU2/fGw7vqxxnRbHrd1sKuR zVJJNIruaq9lswC15phL2ThgTauIxvEDYoqlzl5kuADm6YZ7ltMy4HldL1ealh52Xlx7k 75y+L9WhMiR6niyBxFoNl9s52ID+x14Dr38eHib+Y/KyQ3MUuo8hjq6CZaizFFW5rg/bU iA2x5JFX1C+Ct3hfhxzBmLi5dckzOlxKNI2J+fSGxXVI5ATKFkrMOrk7c/kSYKjbdkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126340; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; bh=9m22XaIRZvN65Kw3fpqPJ0VbPLZOO/8BbynEc6IXq98=; b=n5i67w3qTIeppkX9KBtMj9D0I1y6py9+uoRJJW3JaKso7CudesEmJEUn+bYaLGVtAWIZ AS9yFhrUub+8xKdyHu8fFD9pjEdGozXXRa9n1zMbu+ANv2T5e+Zo4XWqcdWo4suFpbuhN XK5WMgMqrm7dmIDu2NEBi2Ka/DBbG0nFW2/w1Jb28xLv0hFulzJwpVDYLlxwK05VDBnsU EviojfInwlkdIwceke2kBA8gaPnhOvq0Lxudk5Cyl2tJXig9BhvllfLZLAC5BUstbtG32 bZdJvJrMk2Vs3cHYXHsC9JOoOhe7jJthA/HOucWwEXvtF6kpeAYMqVSZzUJ9WK69quQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=IeosE12e; arc=none smtp.remote-ip=113.46.200.225 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C278606A31A for ; Tue, 1 Dec 2026 11:58:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C278606A31A 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, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=IeosE12e dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=9m22XaIRZvN65Kw3fpqPJ0VbPLZOO/8BbynEc6IXq98=; b=IeosE12eV1D39TmxAQIZnJ+nIBCW4sVVNkb63Et24xTwUdZ6yPe/d9MB5HBN5yH0GHyYTrr30 6y8KUfcatJ+FhSbTVh+k4LVcraX8jUpW56IBw/slD7tO65dHa9ExYtRJd23P4rgaUJAAw75aNuV IuH13zP0ZOafxACB8vpvHy4= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4jdztV28RTz1K9Vq; Tue, 1 Dec 2026 19:58:26 +0800 (CST) Received: from kwepemo200010.china.huawei.com (unknown [7.202.195.178]) by mail.maildlp.com (Postfix) with ESMTPS id 0DCCF40578; Tue, 1 Dec 2026 19:58:48 +0800 (CST) Received: from [10.174.177.203] (10.174.177.203) by kwepemo200010.china.huawei.com (7.202.195.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 1 Dec 2026 19:58:47 +0800 Message-ID: <6de2f988-e6f5-4a25-a51e-d7c4a5e55248@huawei.com> Date: Tue, 1 Dec 2026 19:58:46 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 0/2] arm64: speed up __arch_copy_from_user() for large copies To: Catalin Marinas , Will Deacon CC: , , Mark Rutland , Ben Niu , Jinjiang Tu , , , Qi Xi References: <20261116072512.1323883-1-xiqi5703@163.com> Content-Language: en-GB From: Qi Xi In-Reply-To: <20261116072512.1323883-1-xiqi5703@163.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemo200010.china.huawei.com (7.202.195.178) 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 > > 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 >