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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id E668BC433F5 for ; Wed, 20 Apr 2022 17:44:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 845424B0FB; Wed, 20 Apr 2022 13:44:15 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S585OZi7HR40; Wed, 20 Apr 2022 13:44:11 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 77A094B17D; Wed, 20 Apr 2022 13:44:11 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B51E84B10C for ; Wed, 20 Apr 2022 13:44:09 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yzOoEW4rgqgY for ; Wed, 20 Apr 2022 13:44:08 -0400 (EDT) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 77DA34B0FB for ; Wed, 20 Apr 2022 13:44:08 -0400 (EDT) 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 CC6FAB81EB6; Wed, 20 Apr 2022 17:44:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797EBC385A0; Wed, 20 Apr 2022 17:44:03 +0000 (UTC) Date: Wed, 20 Apr 2022 18:44:00 +0100 From: Catalin Marinas To: Marc Zyngier Subject: Re: [PATCH v2 10/10] arm64: Use WFxT for __delay() when possible Message-ID: References: <20220419182755.601427-1-maz@kernel.org> <20220419182755.601427-11-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220419182755.601427-11-maz@kernel.org> Cc: kernel-team@android.com, kvm@vger.kernel.org, Joey Gouly , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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? > + } else if (arch_timer_evtstrm_available()) { Nit: two spaces between else and if ;). Acked-by: Catalin Marinas _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 6731FC433EF for ; Wed, 20 Apr 2022 17:45:13 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7Sb5LL52GPdvFrubyt0hD0fM8R45vKgFF5H37fxtCFo=; b=y0bKAVE+/9e3WX LbSs92euEP7Bh2/FVB2jZlXMq02m81ztXT/EKVFb5oOE+333fd5bSzpvQSVbO/d6fhWoQ0ueE2FW3 oezKSndZF+5kwBxLatpgOxk8+mkL3RiinfzHK87kocR7WBCmQ7wLbAsyn+wTnF5u1kSfXiK24nQ9i KLTSdtRtTj8Rw4shXnBTG/AlnzONAmeC+cYagah8n4czDP31iYyIV7uYTq91jqv3PmLeddnfvSIEv CwtZuycfRDZ0G715fBW1mIaOXpb52+JtLC35HEdmo62FZbOqRAvk7LQ/wZzDYAzh934F1boM1Ok09 zjlZgk32ANCkGK6+dhuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhENA-009y9l-7N; Wed, 20 Apr 2022 17:44:12 +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 1nhEN6-009y8Z-OM for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2022 17:44:10 +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 CC6FAB81EB6; Wed, 20 Apr 2022 17:44:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797EBC385A0; Wed, 20 Apr 2022 17:44:03 +0000 (UTC) Date: Wed, 20 Apr 2022 18:44:00 +0100 From: Catalin Marinas To: Marc Zyngier 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 Message-ID: References: <20220419182755.601427-1-maz@kernel.org> <20220419182755.601427-11-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220419182755.601427-11-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_104408_974523_DDDD97A1 X-CRM114-Status: GOOD ( 21.05 ) 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 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? > + } else if (arch_timer_evtstrm_available()) { Nit: two spaces between else and if ;). Acked-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512CDC433EF for ; Wed, 20 Apr 2022 17:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381278AbiDTRq4 (ORCPT ); Wed, 20 Apr 2022 13:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381268AbiDTRqy (ORCPT ); Wed, 20 Apr 2022 13:46:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B284473A0 for ; Wed, 20 Apr 2022 10:44:08 -0700 (PDT) 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 C3A58B82149 for ; Wed, 20 Apr 2022 17:44:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797EBC385A0; Wed, 20 Apr 2022 17:44:03 +0000 (UTC) Date: Wed, 20 Apr 2022 18:44:00 +0100 From: Catalin Marinas To: Marc Zyngier 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 Message-ID: References: <20220419182755.601427-1-maz@kernel.org> <20220419182755.601427-11-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220419182755.601427-11-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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? > + } else if (arch_timer_evtstrm_available()) { Nit: two spaces between else and if ;). Acked-by: Catalin Marinas