Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2656331iob; Fri, 6 May 2022 07:41:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXhnXGa/pkCliBoP+5+bu1JC+K6pvWGZnKA9H0D6gzDg3Y1Li79FFQBPKzhtDIKh6faw15 X-Received: by 2002:a63:68c6:0:b0:380:3fbc:dfb6 with SMTP id d189-20020a6368c6000000b003803fbcdfb6mr3030305pgc.326.1651848091121; Fri, 06 May 2022 07:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651848091; cv=none; d=google.com; s=arc-20160816; b=qgCcMs+99lP0j0OvqnkNVCoZuPSYP7j8qf8T9qHlznGVMALKxW0BbjRg5ybIg1gi1P 0ljnM8rTtkSD5jTa0rtLjyxIFjA8tMWuvXfN/TLZ7ILgJpFuS78ufhWasIb6JG1k+egD vHA97dlm9he7TCTytMtcDRxVzV0Tvdl7sSWXvrKFYmstwvqgzaWoUPCn1DdaIqIf2DLy HJ7Vs4WnlGwyRJut1YN7HyD1gr48mXoktDfz+sSrhyi+sX84yAlnwJS8li762B7zJW0K Y9PlBl9iz4xPP9pHP4mAgIvL9zG85Lt+Fdsi8meyr/+9SVoEvnPtlmRn/Bm/q4NuLX/A lNPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8VA4FHvbsRw2CxenU94ej339VkaiHmNkpMn++qhKZkY=; b=L2dC6+oWpp99lv+svMmuo1jmaeOubyCfrVYtmsO60GQ/cw4UfomXyOvvZO3bugvmXN JZo35t4+3vf3SbFYWBAbkGUSilFTfXPuNV8uerURr3CB0PmivU5RFUULeIMJE1lTKGJ4 ClQB6M3PyDSMuSLh2bti8dm4QHqt6luWqiPPwFAAAvymqtj33Hgh5dVy9Ml1MXcDRQXW yNOLlFujovbG5BmedwPB1dxwVX9KEURGlcQd4vNIXD5qcX2NyZqpUnd2+rW0Ir8B9x/4 p6C15x/0MKyHGq7ND05UTzZHp8qGYLgqVLbs9S5qiUDnLn4dGATMPgc7DL44tobXuKJE 1TOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BLaR8Qxg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c141-20020a621c93000000b005103f14fc5dsi4363434pfc.46.2022.05.06.07.41.12; Fri, 06 May 2022 07:41:31 -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=@google.com header.s=20210112 header.b=BLaR8Qxg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345428AbiEDHdP (ORCPT + 99 others); Wed, 4 May 2022 03:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345475AbiEDHdG (ORCPT ); Wed, 4 May 2022 03:33:06 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE4F237F3 for ; Wed, 4 May 2022 00:29:26 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id b19so746975wrh.11 for ; Wed, 04 May 2022 00:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8VA4FHvbsRw2CxenU94ej339VkaiHmNkpMn++qhKZkY=; b=BLaR8QxgOE15hRZ0jpFOV1OHP0eKmguetIqvw2yRUPitWzmBSDrDOloiPvkrZHsCP4 d9CeK4r2v43mVUEcDlfsQW5fE7iw7ahIYOIl7PZ8hKFS0fHsWwZNGAn2O3a8frn90nQf c70B+1GEnqp8nJD/Oc/MCig+1DnCaJ5SS2uOXPCnDDbNLlXhkMTz8XO2THpfut2HFsdW y2Fb0G3PK3GJH7imqh2sWXOBFixa7+BJUdvkda2IcsR1DPRfd8stpJIkCd0WtmYCey0S STIJJPmdoOzn7gndEbiXnrZbt6rWUqqyXPtlZPDZj0owD8fg3XzJ70ZOClqayDmE5yl0 jUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8VA4FHvbsRw2CxenU94ej339VkaiHmNkpMn++qhKZkY=; b=AXcEFqIIE8QGjVARRfe1gqm/r8Nzevj4jFmy3ByEXRXI13JsMFI0NOU8zjov6IynZF DuzQptpgRUcRq5xGU0yxRLyVUTJ95cxwbVgkSO4wl2reIO/utIKyg7gIylMAEP/xuBkp zeQny+py7kw3cTJF2GYJxTdMpoEWGO/FwplgnDpUrII2it3jX3Q5EfOXXvhzk/Si6qlo Qa1A4kFC/Dpvy1GC7KS+r8JC4rYhSO4XlJAo2hZ0G53oLyCF4KHdBmJWtqzvyX1O8M7w 22esX3ZiaSXeoDx0/rebUQJLFt8zYyQIwQtKNNsPEfvya6Q5jeT5OCyCK7HIQP22F4Qm Tu7Q== X-Gm-Message-State: AOAM533h/gamerFX4vMM15pkEABJ4m2MbfTdni+Sm+cSW5jkPcm8FxgC dnGzidUG8ij85zP48JCq/WDxYw== X-Received: by 2002:a5d:6208:0:b0:203:dde4:c76e with SMTP id y8-20020a5d6208000000b00203dde4c76emr15234569wru.273.1651649365011; Wed, 04 May 2022 00:29:25 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id h7-20020adfa4c7000000b0020c5253d907sm11000665wrb.83.2022.05.04.00.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 00:29:24 -0700 (PDT) Date: Wed, 4 May 2022 07:29:23 +0000 From: Sebastian Ene To: Rob Herring Cc: linux-kernel@vger.kernel.org, Derek Kiernan , Dragan Cvetic , Arnd Bergmann , devicetree@vger.kernel.org, qperret@google.com, will@kernel.org, maz@kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH v4 2/2] misc: Add a mechanism to detect stalls on guest vCPUs Message-ID: References: <20220429083030.3241640-1-sebastianene@google.com> <20220429083030.3241640-3-sebastianene@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Fri, Apr 29, 2022 at 04:03:45PM -0500, Rob Herring wrote: > On Fri, Apr 29, 2022 at 11:38:52AM +0200, Greg Kroah-Hartman wrote: > > On Fri, Apr 29, 2022 at 09:26:26AM +0000, Sebastian Ene wrote: > > > On Fri, Apr 29, 2022 at 10:51:14AM +0200, Greg Kroah-Hartman wrote: > > > > On Fri, Apr 29, 2022 at 08:30:33AM +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/vm-watchdog.c | 206 +++++++++++++++++++++++++++++++++++++ > > > > > 3 files changed, 219 insertions(+) > > > > > create mode 100644 drivers/misc/vm-watchdog.c > > > > > > > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > > > > > index 2b9572a6d114..26c3a99e269c 100644 > > > > > --- a/drivers/misc/Kconfig > > > > > +++ b/drivers/misc/Kconfig > > > > > @@ -493,6 +493,18 @@ config OPEN_DICE > > > > > > > > > > If unsure, say N. > > > > > > > > > > +config VM_WATCHDOG > > > > > + tristate "Virtual Machine Watchdog" > > > > > + select LOCKUP_DETECTOR > > > > > + help > > > > > + Detect CPU locks on the 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. > > > > > > Hi, > > > > > > > > > > > There's nothing to keep this tied to a virtual machine at all, right? > > > > You are just relying on some iomem address to be updated, so it should > > > > be a "generic_iomem_watchdog" driver as there's nothing specific to vms > > > > at all from what I can tell. > > > > > > > > thanks, > > > > > > > > greg k-h > > > > > > That's right although I might think of using the term "generic lockup detector" > > > instead of watchdog. The only reason why I would keep "virtual machine" > > > word in, is that there is no actual hardware for this. > > > > That doesn't really matter, it's just a memory location in device tree > > that you are needing, odds are some hardware device could use it just > > like this. Hi, > > Such as a shared on-chip memory that both a system control processor and > the main processors can access. Of course, those also typically already > have a comnunication channel. > > But for a VM-hypervisor interface, why isn't one of the existing > communications interfaces being used? One that is discoverable would be > better than using DT. > In a protected VM we don't trust the host to present and control the loaded peripherals. We rely on another entity to generate a trusted device tree for us. I hope this clarifies the need for DT and I think this information should also be added in the changelog. > Rob Thanks, Seb