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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5A0D9C433B4 for ; Mon, 12 Apr 2021 13:50:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 F22CB611AD for ; Mon, 12 Apr 2021 13:50:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F22CB611AD 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=desiato.20200630; 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=G0gYzPJhnKFfOKogCFjdmkHLBmGDvPjQ6ZE0U5QkhQg=; b=XOi/MB37c1+HZXJ1i3Q01Ew77 tzJd+Sys6ogd3NPOM0373wZTkxlYvJYK4a2UhE3HAPKLChEgrUQZr/2IvWhsotAKQgkPi2lZDfHT7 1b5xSt9vsdMgEkhwmmIc6MPGB4/m3tXNfeMDzjlI55haHCY7KWY9JcTxuRrv9RJDxTOK4+TBaE5Zj 619HlSzu5XYrogwpzgVnKbnxwLvKhFs49oaB8onejAf/9yjaxN2wbqOQg0gH8ULtZn9KQ5uHqgUtB liQ1YoROiEmzehCs+capdiUUScXcZvg8m/1C8RXz7zpReHl0gfZ5O2LXMLnqjtFWIkA7lKj7Kj6Fc CVXhU/zVQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVwvx-006t94-A1; Mon, 12 Apr 2021 13:48:57 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVwvt-006t8R-H5 for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 13:48:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nsBjdzyKX+5L/H3GTMvoYtY5B6giX0F0xHhqQ5e9utk=; b=xCixtogr2oxmjaKl4tXjvD/E6x X268wI3T373vxm1KZAFwr/xPzlSK7PWNzmt1RUKdLvc+G5dctkpmYHQ+8FV3D6PNdRKJsnXNH86+k ljJSLb31MEj/ER8mbKBs9sYrXCiwGXsEpvirpgt+rfigt3AbCfMjuhcNWild+dfYc/OddB90gPSit wJPBbdq9sXQSDQztGcXH7B8YINPH4CWoJ+X35xZzrYHh+7/tH+At3jMYh2OuCVFon9mMotUB89KZ6 Ftuoh/m/erWxibAorqbnLkuSgARYUvLVSmKphLTK/kGIgzCK73Dyfixk/oiIL27ZCV6vkBfW4Pb3e 3v8Wq89w==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVwvq-006HMC-UB for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 13:48:52 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 6DD4E611AD; Mon, 12 Apr 2021 13:48:50 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] 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) (envelope-from ) id 1lVwvn-0071bC-T4; Mon, 12 Apr 2021 14:48:48 +0100 Date: Mon, 12 Apr 2021 14:48:47 +0100 Message-ID: <877dl7obpc.wl-maz@kernel.org> From: Marc Zyngier To: Catalin Marinas Cc: yangwendong , Will Deacon , Mark Rutland , Martin Weidmann , linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com, Zenghui Yu , "wangjingyi (D)" Subject: Re: ARM WFET application scenario consultation In-Reply-To: <20210412131520.GF2060@arm.com> References: <26f50e86-dc68-0aca-f29f-19ef2f884c5d@huawei.com> <20210412124637.GE2060@arm.com> <878s5nodjd.wl-maz@kernel.org> <20210412131520.GF2060@arm.com> 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: 62.31.163.78 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, yangwendong@huawei.com, will@kernel.org, mark.rutland@arm.com, Martin.Weidmann@arm.com, linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com, yuzenghui@huawei.com, wangjingyi11@huawei.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-20210412_064851_037872_C7E95D1E X-CRM114-Status: GOOD ( 42.22 ) 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 Mon, 12 Apr 2021 14:15:21 +0100, Catalin Marinas wrote: > > On Mon, Apr 12, 2021 at 02:09:10PM +0100, Marc Zyngier wrote: > > On Mon, 12 Apr 2021 13:46:37 +0100, > > Catalin Marinas wrote: > > > > > > On Mon, Apr 12, 2021 at 08:08:23PM +0800, yangwendong wrote: > > > > Recently, a new feature of WFE with timeouts has been added to ARMv8. > > > > I have some doubts about the application scenarios of this feature. > > > > > > > > 1) Arm spec said that WFE or WFET can be used in spinlock. Since the > > > > thread using spinlock can't be sleep, if we use the wfet instruction, we > > > > can do nothing but wait when timeout, so what's the difference between > > > > the two instructions in this scenario? > > > > > > Not much point in using it it in a classic spinlock, unless you have > > > some specific implementation that's supposed to time out. > > > > > > Note that we already enabled the event stream in Linux so that an event > > > is generated at 100KHz waking up any WFE. One reason we had for this was > > > some hardware errata where events between clusters were not generated. > > > Another was some small delays required in in certain user programs > > > without going through a kernel syscall, though not sure anyone's > > > actually using it. > > > > > > > 2) Are there any other special scenarios where using wfet instructions > > > > can be beneficial ? > > > > > > In the kernel we could replace our udelay loop with WFIT for example > > > (not WFET because of the event stream). As for user, we can expose a > > > HWCAP but it's up to user libraries to make use of it. > > > > Note that since c219bc4e9205K ("arm64: Trap WFI executed in > > userspace"), we actively prevent WFI from being used in userspace, and > > I would expect WFIT to be given the same treatment. It otherwise is a > > precise tool for userspace to synchronise against kernel events. > > I agree. I only thought about using it in the kernel as a simpler > udelay(). The user should not attempt WFI/WFIT. That's my position as well. I'll post a patch dealing with that shortly. > Now, if KVM traps WFI/WFIT as well, maybe we should not bother with > udelay() in the kernel either. "It depends". As long as there is no direct injection of interrupts (GICv4+), WFI is always trapped. This saves us IPI-ing the physical CPU to force an IRQ state reload. However, when the vcpu can be targeted by directly injected interrupts *and* that it is the only thread in the CPU's run queue, we stop trapping WFI so that direct injection has a chance of doing its thing. Of course, the number of systems implementing direct injection is so far extremely close to zero, so I don't think it is worth basing udelay() on that just yet. KVM needs a bit of work to honour the timeout on trap as well, as currently, a trapped WFIT without any interrupt being injected would result in a guest that never make forward progress. I'll put that on my list of things to look at. 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