Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1331779pxb; Sat, 23 Apr 2022 03:55:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9pqzLZN9Mgcr1DthfrliVZl5loZVjTS79kr5nxsf+72ufX9try6hCGG7zdWtr9GHarPVU X-Received: by 2002:a63:f04b:0:b0:3aa:354b:6e3e with SMTP id s11-20020a63f04b000000b003aa354b6e3emr7439840pgj.396.1650711347299; Sat, 23 Apr 2022 03:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650711347; cv=none; d=google.com; s=arc-20160816; b=FQATnAystv2b9MdWmEPshUZlcmrAacDsmIAd6yJOuEphkFXmW2+qtEmFk5rTGld+ZB 6Ttnyc/iqzi7T+QJ++riX8prbo+jjd2SrHEOOn/peNFYpAqq5ozZC8CN61RwhPWgnhoT pWHOJsNd+i/gNq0wTiia+LGAO7PLUWlLEk5CgJ363FpnkXT47ANZKvQzOKvaphE2GxYy tsA/nKNwG6MqIa/88HfdjiiKJNLU6uVhgBkphJHQXngtRsItwfOW2qNX9VoDRDkYa5x/ aF0i3f4bpNMIDPhB+L03L8/+nVSXOdud+E+7BAHsY6WKHKOnFcISWhYD8P64BuAStkY8 5GHw== 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=l9GiO+JTBstyipJTtca0kHHsb17FGQMqHQg4tzHOg9Y=; b=sbqUqugXcUGEcZVjhQz5c/8YEm5Bxk3M3KK6725iH5/fLSmHuezdQEecNbxzAGbL+x CxOpUnKFDA6+E/IhEVZFXRAV6lDJTvQ7l8aMgA2b2aH5t5MrEVqKT8uXZFQM1Zk/wYNX ixJL+X/aNyKRa2+AmX+it9X9oOAdOAMiItBB+uH2rFEvrXE9eIusJoEX+jhB4AqZW3g8 Xkkt7nJithxN5iOxQu5ixypSq6BUObXLEE+1EMg35nvlKYodT0EsdkW//CD8BFj3KolN Sisu6ZvQX/qp3HG70Ajxl4MZdFhgICaPqh4FEIdmxMflpow4eWNlcLWivgJtr2sfmb89 dsKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=I6x1fhOQ; 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 c2-20020aa781c2000000b004fb142acb57si9143576pfn.160.2022.04.23.03.55.33; Sat, 23 Apr 2022 03:55:47 -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=I6x1fhOQ; 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 S234346AbiDWJR5 (ORCPT + 99 others); Sat, 23 Apr 2022 05:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbiDWJRz (ORCPT ); Sat, 23 Apr 2022 05:17:55 -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 7746C644FF for ; Sat, 23 Apr 2022 02:14:57 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id x18so14173392wrc.0 for ; Sat, 23 Apr 2022 02:14:57 -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=l9GiO+JTBstyipJTtca0kHHsb17FGQMqHQg4tzHOg9Y=; b=I6x1fhOQq1UOP7bEu54Th8XDxGR1vBQJDOvvHuuwxERrZjFYO0PwH5eIEtW1R4tvGe jbJCQ/ypJHxEnBIvcz4uvYD5Q3t64g6wEapHnkTFq0Dgk2EWKDSEuJHhenRSXWsT4xM6 uCin1qtu4zjQ8/WV9w3JOTANdTYEmDAYxYEu0fEkcY/00IkaEYxJpP61vYL41+OYtIrG ilQD0tNxY1oB7vvrrU6fIqsf7gLM/4MR8ufOnqGjzIIqKQl6g6uvhckGYzWyD54zhXSJ wq0oPZ7EDOIW/GVW1j95hBiEvWSS96jYQdPOdYfvw8jk0QGVvMVIbbxBN3T5+2YmAGcL jJsg== 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=l9GiO+JTBstyipJTtca0kHHsb17FGQMqHQg4tzHOg9Y=; b=3WccSzQP860GV0dmTLwg8W0kl7JYzpfTkCKCN+mFIlFklwGsWK4qnluQ6eH1GEVjRf /86UUy0/vFysx5vdwZd5WhRAGiXGbNf/MfcPJTuSn8fjFivhPUpH9JVgnE+Y4iwfGuct IqB9X4kYl+d2GmgK4MteoNGWQLTWKLo0/W+JbIeAr0vR1/MFGCk+RGRjd85e7m2aHVxc opo2mo+uJHXWC1K8e9UTdIgQVDlyw30wAngC+dRm695pts2teHdTXagcZasKf8nPD16o HtARa0yyhb5yhGgfEjWXYGsbL+r2k94A+8LxIG1RRE/EvZplHj9FPzObL8/Rm2HoJSPR msxg== X-Gm-Message-State: AOAM533yPhqDDJi00Ekg6JYcr1pm55ZL2/vgDiwP5BGf13tSA4NWvKrH yJi+EueAej/x2bs9Je56dAZC7w== X-Received: by 2002:adf:fe47:0:b0:20a:c899:829f with SMTP id m7-20020adffe47000000b0020ac899829fmr6102700wrs.165.1650705295840; Sat, 23 Apr 2022 02:14:55 -0700 (PDT) Received: from google.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id p7-20020a5d4e07000000b002079a418430sm3597982wrt.85.2022.04.23.02.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 02:14:55 -0700 (PDT) Date: Sat, 23 Apr 2022 09:14:53 +0000 From: Sebastian Ene To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Rob Herring , devicetree@vger.kernel.org, qperret@google.com, will@kernel.org, maz@kernel.org Subject: Re: [PATCH v2 2/2] misc: Add a mechanism to detect stalls on guest vCPUs Message-ID: References: <20220422141949.3456505-1-sebastianene@google.com> <20220422141949.3456505-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, 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 Sat, Apr 23, 2022 at 08:50:03AM +0200, Greg Kroah-Hartman wrote: > On Fri, Apr 22, 2022 at 02:19:50PM +0000, Sebastian Ene wrote: Hello Greg, > > This patch adds support for a virtual watchdog which relies on the > > per-cpu hrtimers to pet at regular intervals. > > > > Signed-off-by: Sebastian Ene > > --- > > drivers/misc/Kconfig | 8 ++ > > drivers/misc/Makefile | 1 + > > drivers/misc/vm-wdt.c | 215 ++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 224 insertions(+) > > create mode 100644 drivers/misc/vm-wdt.c > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > > index 2b9572a6d114..0e710149ff95 100644 > > --- a/drivers/misc/Kconfig > > +++ b/drivers/misc/Kconfig > > @@ -493,6 +493,14 @@ 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. > > + To compile this driver as a module, choose M here: the > > + module will be called vm-wdt. > > + > > source "drivers/misc/c2port/Kconfig" > > source "drivers/misc/eeprom/Kconfig" > > source "drivers/misc/cb710/Kconfig" > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile > > index 2ec634354cf5..868e28d01b75 100644 > > --- a/drivers/misc/Makefile > > +++ b/drivers/misc/Makefile > > @@ -59,3 +59,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o > > obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o > > obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o > > obj-$(CONFIG_OPEN_DICE) += open-dice.o > > +obj-$(CONFIG_VM_WATCHDOG) += vm-wdt.o > > No tab? > I will add one. > > \ No newline at end of file > > diff --git a/drivers/misc/vm-wdt.c b/drivers/misc/vm-wdt.c > > new file mode 100644 > > index 000000000000..ea4351754645 > > --- /dev/null > > +++ b/drivers/misc/vm-wdt.c > > @@ -0,0 +1,215 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > I have to ask, do you really mean "+" here as this is not the overall > license of the kernel. It's not a normal license for your employer to > pick, so as long as you have legal approval, it's fine, but if not, you > need to get that. > Thanks for letting me know, I think this should be : SPDX-License-Identifier: GPL-2.0 without "+". > > +// > > +// Virtual watchdog driver. > > +// Copyright (C) Google, 2022 > > + > > +#define pr_fmt(fmt) "vm-watchdog: " fmt > > It's a driver, you shouldn't need any pr_* calls. > I will remove those. > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define DRV_NAME "vm_wdt" > > KBUILD_MODNAME? > > > +#define DRV_VERSION "1.0" > > "versions" mean nothing once the code is in the kernel, please drop > this. > I will drop this. > But why isn't this in the normal watchdog subdirectory? Why is this a > special driver? > > > + > > +#define VMWDT_REG_STATUS (0x00) > > +#define VMWDT_REG_LOAD_CNT (0x04) > > +#define VMWDT_REG_CURRENT_CNT (0x08) > > +#define VMWDT_REG_CLOCK_FREQ_HZ (0x0C) > > +#define VMWDT_REG_LEN (0x10) > > + > > +#define VMWDT_DEFAULT_CLOCK_HZ (10) > > +#define VMWDT_DEFAULT_TIMEOT_SEC (8) > > + > > +struct vm_wdt_s { > > + void __iomem *membase; > > + u32 clock_freq; > > + u32 expiration_sec; > > + u32 ping_timeout_ms; > > + struct hrtimer per_cpu_hrtimer; > > + struct platform_device *dev; > > +}; > > + > > +#define vmwdt_reg_write(wdt, reg, value) \ > > + iowrite32((value), (wdt)->membase + (reg)) > > +#define vmwdt_reg_read(wdt, reg) \ > > + io32read((wdt)->membase + (reg)) > > + > > +static struct platform_device *virt_dev; > > + > > +static enum hrtimer_restart vmwdt_timer_fn(struct hrtimer *hrtimer) > > +{ > > + struct vm_wdt_s *cpu_wdt; > > + u32 ticks; > > + > > + cpu_wdt = container_of(hrtimer, struct vm_wdt_s, per_cpu_hrtimer); > > + ticks = cpu_wdt->clock_freq * cpu_wdt->expiration_sec; > > + vmwdt_reg_write(cpu_wdt, VMWDT_REG_LOAD_CNT, ticks); > > + hrtimer_forward_now(hrtimer, ms_to_ktime(cpu_wdt->ping_timeout_ms)); > > + > > + return HRTIMER_RESTART; > > +} > > + > > +static void vmwdt_start(void *arg) > > +{ > > + u32 ticks; > > + int cpu = smp_processor_id(); > > + struct vm_wdt_s *cpu_wdt = arg; > > + struct hrtimer *hrtimer = &cpu_wdt->per_cpu_hrtimer; > > + > > + pr_info("cpu %u vmwdt start\n", cpu); > > When drivers work properly, they are quiet. > I will drop this. > Again, why not have this in drivers/watchdog/ and use the apis there > instead of creating a custom one for no reason? > I submitted this patch to the drivers/watchdog and I received some feedback on it stating that this type of driver is not intended to be used with watchdog core, because the drivers don't have a notion of CPU. Moreover, we need to keep track of the elapsed time on a per-cpu basis and the core watchdog framework doesn't provide this functionality. > thanks, > > greg k-h Thanks, Sebastian