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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=no 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 AED4BC433DF for ; Mon, 29 Jun 2020 13:42:44 +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 81D2F23D67 for ; Mon, 29 Jun 2020 13:42:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NOTlvjBj"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="aKz8rJka" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81D2F23D67 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=3TuxaEEyUSbfsgmCpt/GApeePAzHtuykG+ZhQ8X/Z+A=; b=NOTlvjBj5bqkaau/zE2Klr1cuG WdjQGVkxTJaEXEv8HFJATQcTD/fkDNQwF2Ql/y0xygZf0uGoyqUt4Vj87h/QU0zSmyhk3Dtamnepe dvye1CxVy9/R64n/Bds2cXqSQ1hdcgHtTZqMLr2cxbUCSYZUJkmrNfmbDrePLu3W14pFMTUpHDRlM X8Wxq2MPVR9PlImfkqVEJzk45ukztQEbNj1vwB4/GJ69glg1EXaZsBcCWjFuRDlvp3+c49oWamWbF jh5WCJeOYRVzradA0rmKHx4+xNFKJptP7TZ85iLLOKN8ogrOLX+bsdEJAi+T75JxdHFRQNQo8A73N uGGw0ctg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpu1x-0000yT-Dc; Mon, 29 Jun 2020 13:41:05 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpu1t-0000yA-Gl for linux-arm-kernel@lists.infradead.org; Mon, 29 Jun 2020 13:41:03 +0000 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4438A23B06; Mon, 29 Jun 2020 13:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593438059; bh=ANxSnp5OITdmCE3xTaEsHWuSOXSrfxUxI22ZskXYXo0=; h=From:To:Cc:Subject:Date:From; b=aKz8rJka6BNpVS7oQ/fg57/2NiIpVNaOKwEHNFuHyRs7UY1Do01wlH+w8iMRsYyGP 9ion0TMwFTWMcl7IqMelWB/UDhfrZjT/ZgjJgFbl3670diKT8K7Nxoi3hhV9rG2gQp qMni1Umhk5e9H4qg03EVN/+YHS0nbLWQzPtopSjk= From: Mark Brown To: Catalin Marinas , Will Deacon Subject: [PATCH v3 0/8] arm64/sve: First steps towards optimizing syscalls Date: Mon, 29 Jun 2020 14:35:48 +0100 Message-Id: <20200629133556.39825-1-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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: Julien Grall , zhang.lei@jp.fujitsu.com, Mark Brown , Dave Martin , linux-arm-kernel@lists.infradead.org, Daniel Kiss 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 This is a first attempt to optimize the syscall path when the user application uses SVE. The patch series was originally written by Julien Grall but has been left for a long time, I've updated it to current kernels and tried to address the pending review feedback that I found (which was mostly documentation issues). I may have missed some things there, apologies if I did, and one thing I've not yet done is produced a diagram of the states the relevant TIF_ flags can have - I need to work out a sensible format for that. Per the syscall ABI, SVE registers will be unknown after a syscall. In practice, the kernel will disable SVE and the registers will be zeroed (except the first 128-bits of each vector) on the next SVE instruction. In a workload mixing SVE and syscalls, this will result to 2 entry/exit to the kernel per syscall as we trap on the first SVE access after the syscall. This series aims to avoid the second entry/exit by zeroing the SVE registers on syscall return with a twist when the task will get rescheduled. This implementation will have an impact on application using SVE only once. SVE will now be turned on until the application terminates (unless disabling it via ptrace). Cleverer strategies for choosing between SVE and FPSIMD context switching are possible (see fpu_counter for SH in mainline, or [1]), but it is difficult to assess the benefit right now. We could improve the behaviour in the future as a selection of mature hardware platforsm emerges that we can benchmark. It is also possible to optimize the case when the SVE vector-length is 128-bit (i.e the same size as the FPSIMD vectors). This could be explored in the future. Note that the last patch for the series is is not here to optimize syscall but SVE trap access by directly converting in hardware the FPSIMD state to SVE state. If there are an interest to have this optimization earlier, I can reshuffle the patches in the series. v3: - Rebased to current kernels. - Addressed review comments from v2, mostly around tweaks in the documentation. [1] https://git.sphere.ly/dtc/kernel_moto_falcon/commit/acc207616a91a413a50fdd8847a747c4a7324167 Julien Grall (8): arm64/fpsimd: Update documentation of do_sve_acc arm64/signal: Update the comment in preserve_sve_context arm64/fpsimdmacros: Allow the macro "for" to be used in more cases arm64/fpsimdmacros: Introduce a macro to update ZCR_EL1.LEN arm64/sve: Implement a helper to flush SVE registers arm64/sve: Implement a helper to load SVE registers from FPSIMD state arm64/sve: Don't disable SVE on syscalls return arm64/sve: Rework SVE trap access to use TIF_SVE_NEEDS_FLUSH arch/arm64/include/asm/fpsimd.h | 5 ++ arch/arm64/include/asm/fpsimdmacros.h | 48 +++++++++++++++---- arch/arm64/include/asm/thread_info.h | 5 +- arch/arm64/kernel/entry-fpsimd.S | 30 ++++++++++++ arch/arm64/kernel/fpsimd.c | 69 ++++++++++++++++++++++----- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 7 +++ arch/arm64/kernel/signal.c | 17 ++++++- arch/arm64/kernel/syscall.c | 13 ++--- 9 files changed, 162 insertions(+), 33 deletions(-) base-commit: 9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68 -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel