Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94D7FC433E2 for ; Mon, 14 Sep 2020 15:36:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1802E20E65 for ; Mon, 14 Sep 2020 15:36:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BqY2uRn4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Z/KaTiwU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1802E20E65 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=l4AM2exiILGaTMyXqWzGe+yVScI/Q8gWqPMB9emYhek=; b=BqY2uRn4YqqKYUCvfxDz9kW0pi rNVpYyW9jOuWKjA0RZIYhAcrQ39ltitGutIoYDRW2tL/U6MuU40t6qDk4Zh3KX/PiEEqDa8RhcOs+ 95RLjXKoBQrTIKm2eqcVZowsx4WkGUSONBBxfb2E1E8qf1+wV5i64GpcagL6qqkNP+7vCcJr+rUKJ Pd9/ZaZ+jIwM/nrn2+OLRFMnbQ/bjgRQAnTlmMoswUQNK8c/X9o9De3nq3ORH/uQt8DLgE1Ww0eK2 CGbRetEuRNdd7mdXi0LEm5R4n4DfdGJZPDxJG9aeLfyMOjUlhu9S7Hn11ECKreitndx7kJqW+BN6a glnycugA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqV2-0002an-GM; Mon, 14 Sep 2020 15:34:36 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqUS-0002IO-Vc for linux-arm-kernel@merlin.infradead.org; Mon, 14 Sep 2020 15:34:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OGAT7Kmwqh/FgdK+EJ+dw/U041XDmC4PG8ibqYGjbJ8=; b=Z/KaTiwUoZZk8Pb8qzn4qerIZ4 TeGMm9wXmrOAQw3g8qJtoYBkYKKZMbZa2teXBLRTFM3I9TjZavNeORfHcvnLytYUPuZHzXJSnbtym 17ep56D4XN3ttEfpTAdjN8FwOsiqtP5K/diAYReA6gLUWG01zhlgPz5ijpQgzr06dXikF6QPPgbjb CtMXQM0tbUyKpE2O16TIye+/NCU9/MjtCbsPnGehrtVHMcywzi2sx5caqbPIBpd+EYvkEeSTQZf/u aPthOQSgF/w07VjMFxiffmcCfNR/1k2OdwRLL5lSrejDQaGrf6btJ4bsSGycz2ePNPLz2bVIaIIDe SqgOpJ0Q==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqFN-0003rb-7i for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 15:18:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D86401396; Mon, 14 Sep 2020 08:18:22 -0700 (PDT) Received: from seattle-bionic.arm.com.Home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 081983F718; Mon, 14 Sep 2020 08:18:21 -0700 (PDT) From: Oliver Swede To: catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v5 14/14] arm64: usercopy: Reduce overhead in fixup Date: Mon, 14 Sep 2020 15:18:00 +0000 Message-Id: <20200914151800.2270-15-oli.swede@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914151800.2270-1-oli.swede@arm.com> References: <20200914151800.2270-1-oli.swede@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_161825_494576_C21681FF X-CRM114-Status: GOOD ( 10.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 In the usercopy fixups the intermediate in-order copy step could create an overhead for a fault that occurs a large number of bytes ahead in the buffer. On inspection of the copy routine, it appears possible to leverage the property where all bytes lower than the fault address minus N bytes (128 for this algorithm) have already been copied at the point of a fault . This adds a preprocessor directive for defining the value that should be subtracted from the intermediate fault address by the first-stage fixup routine. This is the only dependency on the copy routine and this change should be re-evaluated when importing new optimized copy routines to determine if the property still holds, or e.g. if N needs to be increased, to ensure the fixup remains precise. Signed-off-by: Oliver Swede --- arch/arm64/lib/copy_user_fixup.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/lib/copy_user_fixup.S b/arch/arm64/lib/copy_user_fixup.S index 4858edd55994..970370b5b0a5 100644 --- a/arch/arm64/lib/copy_user_fixup.S +++ b/arch/arm64/lib/copy_user_fixup.S @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#define FIXUP_GRANULE 128 + addr .req x15 .section .fixup,"ax" .align 2 @@ -36,6 +38,13 @@ L(src_fault): mov x4, x0 // x4: initial target store address add x5, x1, x2 // x5: srcend + subs x3, x15, FIXUP_GRANULE + ccmp x3, x1, #0, pl + csel x3, x3, x1, ge // x3: initial target (user) load address + sub x4, x3, x1 + add x4, x0, x4 // x4: initial target store address + add x5, x1, x2 // x5: srcend + L(src_buf_scan): ldrb2_post w6, x3, #1 strb2_post w6, x4, #1 @@ -52,6 +61,13 @@ L(dst_fault): mov x4, x1 // x4: initial target load address add x5, x0, x2 // x5: dstend + subs x3, x15, FIXUP_GRANULE + ccmp x3, x0, #0, pl + csel x3, x3, x0, ge // x3: initial target (user) store address + sub x4, x3, x0 + add x4, x1, x4 // x4: initial target load address + add x5, x0, x2 // x5: dstend + L(dst_buf_scan): ldrb2_post w6, x4, #1 strb2_post w6, x3, #1 -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel