From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBE93C433EF for ; Wed, 20 Apr 2022 18:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OOrWJgJ+vXe54VDtQKpOaKnOFcG1398mJybCWTJqU1k=; b=vXLn8Wx3yfXITG C4n4iaS9YpWh9k7bdskoPQNxWCefG26yE7AHBgOqAAn64dlpyOl+Wy+XR3lzISgPYxaflio3TLNUT 6/1+9p2lSlvVh/IITVm5hR9v8afGhaE6ZR2HDrRhiZZtVXm+mJ25RM2iDCg5cUJIqwc38mhqJ8hr/ BbboDkusXlPdSr5BxYM4hXsRDiE9yV2wK/cF2Bk6cYX9jDk179QXPaBBmYv4oTn/IVbinZ8QVSNlh WorGYoXfrEGfrEOlIGMBO2vDFa+47eRjyZoDQhmN32fa8JnyhlssYXY3YI0K2xLB2M+aaXWAwYzIw 9YpjaXlQVJpsGazB4wWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhFBH-00A3j9-2i; Wed, 20 Apr 2022 18:35:59 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhFBE-00A3iK-Cf for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2022 18:35:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2DC08B8214A; Wed, 20 Apr 2022 18:35:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF9AC385A1; Wed, 20 Apr 2022 18:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650479752; bh=u2r4w9p5uaRArdJXLzwYtVdEK/zUbS5atk2CBlOmQHk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BL1pdHfwF5AkfaKZyaKrJJk9wXofzCPhiAzNX4vKoQDqn1G3YIPdXUfNKvj/gTg03 aNmI5bNkuLyBfLXrhPDcE07bQRkhl3y0HoTDNvjQ+cVY6hZmqvsp41dHMehnGArlmc rMDxH8FpUDH0FuQHjAFeC0whl/38FhDffNrUX0oPJuwj0g6/v9P9C5/qoiN8C+SYax 1OFJBTPjWXUYhAupgH5ezm4jYBpgIUZjkj9F27O13bqdKZIswuGswq8zdN53KJhgO4 b6rIdR3sBqYtITFX/X3+VHrDxd2XlMwDZ29usiKCAOEoYYFecVRD9SPBLj80zrpf03 oTK5zMYopLgjA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nhFB8-005hRS-6O; Wed, 20 Apr 2022 19:35:50 +0100 Date: Wed, 20 Apr 2022 19:35:49 +0100 Message-ID: <87levza9h6.wl-maz@kernel.org> From: Marc Zyngier To: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Will Deacon , Mark Rutland , James Morse , Suzuki K Poulose , Alexandru Elisei , Joey Gouly , kernel-team@android.com Subject: Re: [PATCH v2 10/10] arm64: Use WFxT for __delay() when possible In-Reply-To: References: <20220419182755.601427-1-maz@kernel.org> <20220419182755.601427-11-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, joey.gouly@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_113556_761110_2A433994 X-CRM114-Status: GOOD ( 30.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 On Wed, 20 Apr 2022 18:44:00 +0100, Catalin Marinas wrote: > > On Tue, Apr 19, 2022 at 07:27:55PM +0100, Marc Zyngier wrote: > > Marginally optimise __delay() by using a WFIT/WFET sequence. > > It probably is a win if no interrupt fires during the delay. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/lib/delay.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/lib/delay.c b/arch/arm64/lib/delay.c > > index 1688af0a4c97..5b7890139bc2 100644 > > --- a/arch/arm64/lib/delay.c > > +++ b/arch/arm64/lib/delay.c > > @@ -27,7 +27,17 @@ void __delay(unsigned long cycles) > > { > > cycles_t start = get_cycles(); > > > > - if (arch_timer_evtstrm_available()) { > > + if (cpus_have_const_cap(ARM64_HAS_WFXT)) { > > + u64 end = start + cycles; > > + > > + /* > > + * Start with WFIT. If an interrupt makes us resume > > + * early, use a WFET loop to complete the delay. > > + */ > > + wfit(end); > > + while ((get_cycles() - start) < cycles) > > + wfet(end); > > Do you use WFET here as a pending interrupt would cause WFIT to complete > immediately? Yes, that's the idea. Even if a pending interrupt is not immediately present, it could come halfway through, shortening the delay, and making WFIT useless until the interrupt is acknowledged. I would have loved for WFIT to return a status indicating whether the wakeup was for a pending interrupt or for another reason (such as reaching the timeout), but apparently it was too much to ask... Maybe in ARMv11! ;-) > > > + } else if (arch_timer_evtstrm_available()) { > > Nit: two spaces between else and if ;). I'll make sure to fix this! ;-) > > Acked-by: Catalin Marinas > Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel