Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3644496iog; Tue, 21 Jun 2022 03:03:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIqNc/jVHjBmj33klSJfFf5khwnX43f304qyzkCWAht65anJzC3150GFabm/NyUItqArL+ X-Received: by 2002:a05:6402:4414:b0:434:f58c:ee2e with SMTP id y20-20020a056402441400b00434f58cee2emr34203485eda.362.1655805789713; Tue, 21 Jun 2022 03:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655805789; cv=none; d=google.com; s=arc-20160816; b=ADE2cYujZ3BTJmnWsSX1hWczEQ4qL8Kk/Hh3fn2gkYHYIFP4mcTbaKyIJNUwEd81C+ MYroZH+QaCbQn2uCA2wa8ExQUkD8iZTwGM7fe0VSSvfJFtq4nY6xgrmPk5BPEcyI/4Tq gih+48CUO1GkbxAa903+w+LssIm4R/jA8vvkOnrbmad7SuV+3ivqFNGggLi9Gk+hz4fg uz9jKAVFVdxXXWfptZcJTAMr7LwXJ4PGkGOiCbzkZr6t0UiLIP0eAG/1Iswphor1qtcM gDBWVuNvoO9HRHer5LeOCgWkE2DQNZBmA/nIhVAbvVtVyS675dCBwrY0aCPblG59Nj7J /8hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=9K7KamX5ZUIciTDmaCZI5CynlHMpZ08VTsHJPMxzBtw=; b=Waj6YBAurw+opq7TN3ueRJ6m7RWgJhFHkMPCVZusch9iRQP1yjTetnfbmSCWT9ZA8j cOndcT4zG5R1JajkfnXHq2bNE2dKiAWkubcKyNtkKXt1e2vJ0rkxugby3v3N5EhE+Exm SSw7MHx4oSgAOV13gD/NKpWWe+EPC3mHnvBgI0oPvBDNaIgOf62trb2FDRXLk6W9+UMA t1KPPBbzm107aXTB5CnGtty1yrCjuv6hnmOUQORWJQqts9bTxdd63T1Qmhv6vxYcx7XL FEnwHU/FR+jdGtgMXC5iA/fNdc/bPm+XpO4fOau1L83yXXazCETUE9PCP5GJK2JbMQZJ oBXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jAFHMdHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b00707e0e3cd7csi14635255ejc.359.2022.06.21.03.02.43; Tue, 21 Jun 2022 03:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jAFHMdHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348178AbiFUJYh (ORCPT + 99 others); Tue, 21 Jun 2022 05:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348164AbiFUJYf (ORCPT ); Tue, 21 Jun 2022 05:24:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6C823BF8; Tue, 21 Jun 2022 02:24:34 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A3E55615A1; Tue, 21 Jun 2022 09:24:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05274C3411C; Tue, 21 Jun 2022 09:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655803473; bh=MnADtLc+kcZeQgfJmiyARBu1dzFs4JkhpXcSR8Iu7KE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jAFHMdHAF9BVCckZHuy4rp1sjqvBeH+iq7gafdgw17EDNFmUvsmL/+WzvC+OQd1TK VMVwyyTXxVyCZ72Zjw1jfdjcgFjq2lXmJYeNtOKcifXW7BJeeeJHXJGJxuxtwhhiTa vzkbvMDnpsZE4vtscRWSqJFc1i+Gn7pmPFj9+6xxpwOSh48qa5qjJYSRt80096Qgl2 LN3atMC+z7+HleSSnpnAysK6zfjUPLV2JiAMuahd6sZyTcxsiijfUo+1yEdFFaqcGV r8sgeE4K666OW8QZ79QrDE1QAKEgRDjFjOpkotfkDgp3otOJygLgIYlaWxheoc6sJ1 3eLnzL+6suvPA== 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.95) (envelope-from ) id 1o3a7a-0020Me-TM; Tue, 21 Jun 2022 10:24:31 +0100 Date: Tue, 21 Jun 2022 10:24:30 +0100 Message-ID: <87r13i2wtt.wl-maz@kernel.org> From: Marc Zyngier To: Greg Kroah-Hartman Cc: Sebastian Ene , Rob Herring , Arnd Bergmann , Dragan Cvetic , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, will@kernel.org, vdonnefort@google.com, Guenter Roeck Subject: Re: [PATCH v7 2/2] misc: Add a mechanism to detect stalls on guest vCPUs In-Reply-To: References: <20220621080308.3952915-1-sebastianene@google.com> <20220621080308.3952915-3-sebastianene@google.com> <6b5bb5e69888f69fcfdcb8c9c2fd2660@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") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: gregkh@linuxfoundation.org, sebastianene@google.com, robh+dt@kernel.org, arnd@arndb.de, dragan.cvetic@xilinx.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, will@kernel.org, vdonnefort@google.com, linux@roeck-us.net X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Jun 2022 09:54:35 +0100, Greg Kroah-Hartman wrote: > > On Tue, Jun 21, 2022 at 09:44:35AM +0100, Marc Zyngier wrote: > > On 2022-06-21 09:27, Greg Kroah-Hartman wrote: > > > On Tue, Jun 21, 2022 at 08:03:09AM +0000, Sebastian Ene wrote: > > > > This driver creates per-cpu hrtimers which are required to do the > > > > periodic 'pet' operation. On a conventional watchdog-core driver, the > > > > userspace is responsible for delivering the 'pet' events by writing to > > > > the particular /dev/watchdogN node. In this case we require a strong > > > > thread affinity to be able to account for lost time on a per vCPU. > > > > > > > > This part of the driver is the 'frontend' which is reponsible for > > > > delivering the periodic 'pet' events, configuring the virtual > > > > peripheral > > > > and listening for cpu hotplug events. The other part of the driver > > > > handles the peripheral emulation and this part accounts for lost > > > > time by > > > > looking at the /proc/{}/task/{}/stat entries and is located here: > > > > https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817 > > > > > > > > Signed-off-by: Sebastian Ene > > > > --- > > > > drivers/misc/Kconfig | 12 ++ > > > > drivers/misc/Makefile | 1 + > > > > drivers/misc/vcpu_stall_detector.c | 222 > > > > +++++++++++++++++++++++++++++ > > > > 3 files changed, 235 insertions(+) > > > > create mode 100644 drivers/misc/vcpu_stall_detector.c > > > > > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > > > > index 41d2bb0ae23a..e15c85d74c4b 100644 > > > > --- a/drivers/misc/Kconfig > > > > +++ b/drivers/misc/Kconfig > > > > @@ -483,6 +483,18 @@ config OPEN_DICE > > > > > > > > If unsure, say N. > > > > > > > > +config VCPU_STALL_DETECTOR > > > > + tristate "VCPU stall detector" > > > > + select LOCKUP_DETECTOR > > > > + help > > > > + Detect CPU locks on a kvm virtual machine. This driver relies on > > > > + the hrtimers which are CPU-binded to do the 'pet' operation. > > > > When a > > > > + vCPU has to do a 'pet', it exits the guest through MMIO write and > > > > + the backend driver takes into account the lost ticks for this > > > > + particular CPU. > > > > + To compile this driver as a module, choose M here: the > > > > + module will be called vcpu_stall_detector. > > > > > > Should this depend on KVM_GUEST? > > > > Not all architectures have KVM_GUEST, and arm64 has no use for it. > > Ah, I thought this was a requirement (or created a better guest image) > for use under KVM. Nevermind then... It really depends whether an architecture relies on non-architectural extensions to support KVM guests. PPC does most of the time, x86 certainly works better with the knowledge that this is a KVM guest. KVM on arm64 implements the architecture itself, and hardly anything else (if something sucks in virt, it also likely sucks bare metal). The couple of KVM-specific options we support are definitely not worth a KVM_GUEST, as they only cover pretty esoteric stuff that nobody enables, such as PTP_1588_CLOCK_KVM. M. -- Without deviation from the norm, progress is not possible.