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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 48B47C433E0 for ; Tue, 9 Feb 2021 18:25:27 +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 D50B164E3F for ; Tue, 9 Feb 2021 18:25:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D50B164E3F 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-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QNKXx72UWrK2EFiM9PaUmRfNx3XlAtE7cWK1z+PoWX0=; b=I+rX0YRhKi2egL471iO3S+8Bw MOz2QsjMFKBodR2TwISUjDkwby4un744GELQ4t258zGJuizVda2UA+6Cj+rmXOWh1W8qOod7JOo7c EuCo2xtPKspl8bs+H52CqeGSsz7qNFIEOB/hPGHFEirh5a62MwIym0imbCKp2t89p1lcHBDSymtxI zl7UUf462j2lG8RS7fwmCsj8dHFaOzusHZhynTo0h+kT+u5SaiaKAB9jOmtP7pfuq3P0JZDW0oq+D W7K9kuPPmo7BhcK7zIqtR5VUNHjcnylTvVybsCZIj697d16Erb80mqZ6vYdv0ES8Cuj3TWUo1OJqU 3wbenqv8g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9Xg0-0006WX-F1; Tue, 09 Feb 2021 18:23:52 +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 1l9Xf6-00067S-RE for linux-arm-kernel@lists.infradead.org; Tue, 09 Feb 2021 18:23:05 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4E17C64E75; Tue, 9 Feb 2021 18:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612894974; bh=FYwDW7qaBDwKBh4nvLzBSt2CNMRN8Bp2t8dBM2/zG8c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FUIvlVhXf0ZrPd7BKNGRrgmsQ2hoopy3tBY/+ZwHmAe8hAU0kEHGDtIz+YH5PumvD HgRrcnz8nf8bslYGJfDxjtBiBrWLlj6pbX17sP6Q1zcieqRnjHE6h3UghWOWuFbjsX H0XjeIIDVBu/nH4MOSFGycAe6P7nMkGpwZB2orhfzcFsSn3Eha9V8qSjVyAG6VpJZq VpzvBtbF34Y8dHftk5O9FWQVeme8v0Yj2pNKLOAGaK2utZhVknFz+BZDugOGxkd38H YewhnxQKJzO+qF2RZ2LZQ+O90cDOkdeEHTKFjAl/8KDrpDH1LurfI88RzurZScWoaT 3W6STmtx8Emkw== Date: Tue, 9 Feb 2021 18:22:02 +0000 From: Mark Brown To: Dave Martin Subject: Re: [PATCH v7 0/2] arm64/sve: Improve performance when handling SVE access traps Message-ID: <20210209182202.GA4916@sirena.org.uk> References: <20210201122901.11331-1-broonie@kernel.org> <20210208172608.GF21837@arm.com> MIME-Version: 1.0 In-Reply-To: <20210208172608.GF21837@arm.com> X-Cookie: You will triumph over your enemy. User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210209_132257_120547_0755E8D7 X-CRM114-Status: GOOD ( 43.19 ) 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 , Julien Grall , Catalin Marinas , Zhang Lei , Will Deacon , linux-arm-kernel@lists.infradead.org, Daniel Kiss Content-Type: multipart/mixed; boundary="===============7178148739627428485==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============7178148739627428485== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cWoXeonUoKmBZSoM" Content-Disposition: inline --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 08, 2021 at 05:26:10PM +0000, Dave Martin wrote: > On Mon, Feb 01, 2021 at 12:28:59PM +0000, Mark Brown wrote: > > v7: > > - A few minor cosmetic updates and one bugfix for > > fpsimd_update_current_state(). > I see the following delta in this function: > @@ -1272,7 +1272,8 @@ void fpsimd_update_current_state(struct user_fpsimd_state const *state) > get_cpu_fpsimd_context(); > current->thread.uw.fpsimd_state = *state; > - clear_thread_flag(TIF_SVE_FULL_REGS); > + if (test_thread_flag(TIF_SVE_FULL_REGS)) > + fpsimd_to_sve(current); > task_fpsimd_load(); > fpsimd_bind_task_to_cpu(); > Can you elaborate on that? This restores the behaviour we have in mainline, I'd messed up the update here when going through doing the changes to split the flags. The function is called by the signal code to load both the SVE and FPSIMD state, it can enable SVE. > I think the implementation flow in this series is roughly: > a) Split TIF_SVE into two flags, but keep the flags in lockstep, and > don't pretend to handle cases where they are unequal (no functional > change). > b) Add handling for cases where the flags are unequal (the only > meaningful case being TIF_SVE_EXEC && !TIF_SVE_FULL_REGS) (purely > dead code addition; no functional change). > c) Add code that causes / resolves inequality of the flags in order to > achieve the goal of the series (functional change). > Does that sound about right? Patch 2 just does (c), broadly speaking, > I couldn't convince myself whether patch 1 is introducing functional > changes or not. Yes, that's roughly the idea. > The KVM parts of (b) could maybe benefit from their own commit message. > If (b) were all in a separate patch by itself, it would be > straightfoward to split the host and KVM changes up. > Maybe splitting patch 1 into two would help clarify the situation. I did start off splitting it up more but doing it in a way that doesn't result in messier changes due to needing to work with two flags and manages to preserve bisectability ended up pushing me towards the smaller set here. It'd be easy to add a bit more verbiage about KVM to the commit log though. > Second, TIF_SVE_EXEC is advertised as being a pure indication of whether > the task is to be allowed to use SVE in userspace. I find that this > jars a little with the fact that we leave TIF_SVE_EXEC set in the > !FULL_REGS case -- where we cannot enter userspace without doing some > additional work. This is not necessarily a problem, but it was one > extra thing to get my head around. Right. > There seems to be a preexisting convention that a set thread flag > implies a "dirtier" condition than when the flag is clear, though > obviously it works either way. TIF_SVE_FULL_REGS here is really a work- > not-needed flag (whereas TIF_FOREIGN_FPSTATE and various others are I have to say I was completely unaware of that convention, it didn't jump out at me from the code :/ . I suppose you could also say that it's saying that it's a work needed in that it means that the code has to work with the full register set rather than just the FPSIMD subset but it I guess it really just depends on which particular bit of code you're looking at at the specific moment - on the save paths _FULL_REGS means more work as you have to save all the SVE state rather than just the FPSIMD subset. As you say it doesn't *really* matter. > work-needed flags). This also is not necessarily a problem, but I find > it a bit confusing. Inverting the sense of TIF_SVE_FULL_REGS, or > a more explicit name such as TIF_SVE_FULL_REGS_VALID might make it > clearer that there is work to do in the "not valid" case and we cannot > blindly enter userspace or save the task state without taking any notice > of the flag. I'm not at all attached to the name, if people find _FULL_REGS_VALID or some other name clearer that works for me. > Ultimately, we want a decision point somewhere about whether to fall > back to FPSIMD-only mode for a task or not, even if the decision is > trivial for now. Where do you think that sits? I'd generally assumed > that it would go in fpsimd_save() since that's where we take the hit for > saving (and later restoring) the state. That function isn't preemptible > though, so it might also make sense to make the decision elsewhere if > there are suitable places to do it. To me fpsimd_save() is more of a "do the thing we already decided to do" function - it doesn't have enough context to make any decisions, and one of the areas where we can benefit is when we never need to save at all, for example when we take a SVE access trap and can initialize the SVE state from the FPSIMD state already in registers and return to userspace without saving to memory. We definitely should optimize fpsimd_save() here, it shouldn't need to set TIF_SVE_FULL_REGS or spill to the SVE state, but I wouldn't call it a *decision* exactly. > I say this because it is important for this series to make a foundation > that such a decision can be slotted naturally into -- that's part of the > motiviation of making these changes in the first place (IIUC, anyway). To me the goal was mainly about making the access trap case more efficient and potentially also enabling further work like having an equivalent to fpu_counter instead of disabling the SVE access trap on every syscall. The way I was thinking about this was more that the decision points were on kernel entry and exit. We need to generate the full register state any time it's observed by something outside the kernel and there are a set of defined kernel entry points where the SVE state can be discarded but these are all individual points where an individual thing happens. I'm therefore not 100% sure I'm fully understanding what you're thinking of here. It doesn't really seem like a single point thing to me but I've got a feeling that I'm not exactly talking about the same thing as you are. --cWoXeonUoKmBZSoM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmAi0skACgkQJNaLcl1U h9CR6gf/T2q6wF6VX4d2jd2TC5SYDElFSACNMFjAWqLx5SicnXiPqQXI/P8eX50D rAPk3C4sDeQ85VWTwQ1Rrrq+fyChq6SDjx+TIyAxGwiIcPexOSGZh56lqsqzwmY6 ZIRw0pxFpXOw2sCrNcxlk91hXkzrl6XViN/satEunCCR0IYoFqhA7NGlMtPvzHjn NRcgE6IZfqKivdDaZ1j3kw/0+C4AJMDp59KqqgiXW4p4Lj4CuU7/1K2PU8aOK8Ze +5KzxKJN/6oflQ03SqWJ7rsz9dyXI2T3R2D/77+nNdeBHe9pouoJpYxFkt7QZHRs c+XsHCTB8tf8KeBCwiaDdnZK+MaLhw== =maZ/ -----END PGP SIGNATURE----- --cWoXeonUoKmBZSoM-- --===============7178148739627428485== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============7178148739627428485==--