From patchwork Fri Apr 29 08:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 568413 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 7C2C2C433F5 for ; Fri, 29 Apr 2022 08:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355713AbiD2IeJ (ORCPT ); Fri, 29 Apr 2022 04:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355606AbiD2IeH (ORCPT ); Fri, 29 Apr 2022 04:34:07 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7582DD45 for ; Fri, 29 Apr 2022 01:30:49 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id u26-20020adfb21a000000b0020ac48a9aa4so2802162wra.5 for ; Fri, 29 Apr 2022 01:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Rk2iiGqfUOFpCBmrs7zJdywSY+FPn3ERCMZZoVxLcPE=; b=GpMOzAkFJqRf4FLHBMv6LpR75/N9HNi3lX+DoG9LqOtewHwTgxGylO05gVwXdhv3cd BsNj5PZF6HDVgBs2EFHwf+xrWaMalACP0HKOO2gPcwWGAHVqd4lErEAhDmgahZwzYYGz fsEQNNqhW3cAd1OLA9z5UsuRkRHySmQySEQXY/dtp3rEVotqRVygMLz1KK7oGkRssmCq g+XnIs5Jf1w58jHvb34VUT1YZso+bw31Xn7y+bsLV5A0WVMh/p8m6EZDMjGEHXTvBTGp TF6LXmLaUBKci0rGMpLu+1ggwRw8pzeu1PkYM9g09dQCj0veku0CzdpblCRfQ2+fdOor qibQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Rk2iiGqfUOFpCBmrs7zJdywSY+FPn3ERCMZZoVxLcPE=; b=qztIzxIRleLVkuKirgJLHB7FueltDpAZ1CaO1HFwhwet2q5BDSBgGxgwTD8qTXTLTW thPqdZEYE1XybzD9V+xvdy26eAVzzcLvR51YrH6soQj2TXATdv9oSpyHGoXJXJKVAReV f4I7bV1Rb4ZgSTQywZRKeWZgS05T/TIIVqf3SZ4h6DCDcll9oB9Hovv6zF8S6XuRg6I3 v5oAuKmG2RTir8c9KECylRy1PpfPNln0zlPW230eiMRktxkS3a1nhRdr8xjmPO6kQrci 1JOVlzK0Bc6wCjE0iJxbaU3L43uEglNUEELp2AkJfFd2UroY8qdgmeq/wyrIy+nbfjMf KonQ== X-Gm-Message-State: AOAM532w+2qZRNd4MGMbpGFL6Zm7s6ws91j9/zKevRvlZ47X8fccJOG3 PhRQJPGJtBun5j59N1ovLY4hMxnGi+Lo05pY09A= X-Google-Smtp-Source: ABdhPJxx0pMSMn7MJly4lWRl1/NGHzIjNSTXQ19Ch6yh9mbjcM2+Vxl1ntguE4TbscdUKjpPEuEyjlMPUauvrxMD77Y= X-Received: from sene.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:27c4]) (user=sebastianene job=sendgmr) by 2002:a1c:7414:0:b0:394:1d5d:27f2 with SMTP id p20-20020a1c7414000000b003941d5d27f2mr2163995wmc.37.1651221047576; Fri, 29 Apr 2022 01:30:47 -0700 (PDT) Date: Fri, 29 Apr 2022 08:30:29 +0000 Message-Id: <20220429083030.3241640-1-sebastianene@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 0/2] Detect stalls on guest vCPUS From: Sebastian Ene To: Rob Herring , Greg Kroah-Hartman , Arnd Bergmann , Dragan Cvetic Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, maz@kernel.org, will@kernel.org, qperret@google.com, Guenter Roeck , Sebastian Ene Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This adds a mechanism to detect stalls on the guest vCPUS by creating a per CPU hrtimer which periodically 'pets' the host backend driver. 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 basis. This device driver acts as a soft lockup detector by relying on the host backend driver to measure the elapesed time between subsequent 'pet' events. If the elapsed time doesn't match an expected value, the backend driver decides that the guest vCPU is locked and resets the guest. The host backend driver takes into account the time that the guest is not running. The communication with the backend driver is done through MMIO and the register layout of the virtual watchdog is described as part of the backend driver changes. The host backend driver is implemented as part of: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817 Changelog v4: - rename the source from vm-wdt.c -> vm-watchdog.c - convert all the error logging calls from pr_* to dev_* calls - rename the DTS node "clock" to "clock-frequency" Changelog v3: - cosmetic fixes, remove pr_info and version information - improve description in the commit messag - improve description in the Kconfig help section Sebastian Ene (2): dt-bindings: vm-wdt: Add qemu,vm-watchdog compatible misc: Add a mechanism to detect stalls on guest vCPUs .../devicetree/bindings/misc/vm-watchdog.yaml | 45 ++++ drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/vm-watchdog.c | 206 ++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/vm-watchdog.yaml create mode 100644 drivers/misc/vm-watchdog.c