devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Ene <sebastianene@google.com>
To: Will Deacon <will@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Dragan Cvetic <dragan.cvetic@xilinx.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	maz@kernel.org, vdonnefort@google.com,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH v10 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Date: Fri, 8 Jul 2022 08:18:59 +0000	[thread overview]
Message-ID: <Ysfoc2YhQCLge1iY@google.com> (raw)
In-Reply-To: <20220707182737.GE4852@willie-the-truck>

On Thu, Jul 07, 2022 at 07:27:38PM +0100, Will Deacon wrote:
> Hi Sebastian,
> 
> On Thu, Jul 07, 2022 at 03:42:27PM +0000, Sebastian Ene wrote:

Hi Will,

> > 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 is
> > an emulated MMIO device which is part of the KVM virtual machine
> > monitor and this part accounts for lost time by looking at the
> > /proc/{}/task/{}/stat entries.
> > 
> > Signed-off-by: Sebastian Ene <sebastianene@google.com>
> > ---
> >  drivers/misc/Kconfig               |  14 ++
> >  drivers/misc/Makefile              |   1 +
> >  drivers/misc/vcpu_stall_detector.c | 209 +++++++++++++++++++++++++++++
> >  3 files changed, 224 insertions(+)
> >  create mode 100644 drivers/misc/vcpu_stall_detector.c
> 
> Thanks for addressing all of my feedback on v9 so promptly:
> 
> Reviewed-by: Will Deacon <will@kernel.org>
> 
> Just one question on this part:
> 
> > +static enum hrtimer_restart
> > +vcpu_stall_detect_timer_fn(struct hrtimer *hrtimer)
> > +{
> > +	u32 ticks, ping_timeout_ms;
> > +
> > +	/* Reload the stall detector counter register every
> > +	 * `ping_timeout_ms` to prevent the virtual device
> > +	 * from decrementing it to 0. The virtual device decrements this
> > +	 * register at 'clock_freq_hz' frequency.
> > +	 */
> > +	ticks = vcpu_stall_config.clock_freq_hz *
> > +		vcpu_stall_config.stall_timeout_sec;
> 
> It would be quite easy for this to overflow 32 bits, so perhaps it would
> be best to check the values from the DT during probe and fallback to the
> defaults (with a warning) if the result of the multiplication is out
> of range for the 32-bit register.
> 
> What do you think? My review stands in any case, as this shouldn't happen
> in practice with sensible values.
> 

Good point ! I think falling back to defaults in case the values from the
DT exceed a limit is a good approach. I will do that in the next
version.

> Will

Thanks,
Seb

      reply	other threads:[~2022-07-08  8:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 15:42 [PATCH v10 0/2] Detect stalls on guest vCPUS Sebastian Ene
2022-07-07 15:42 ` [PATCH v10 1/2] dt-bindings: vcpu_stall_detector: Add qemu,vcpu-stall-detector compatible Sebastian Ene
2022-07-07 15:42 ` [PATCH v10 2/2] misc: Add a mechanism to detect stalls on guest vCPUs Sebastian Ene
2022-07-07 18:27   ` Will Deacon
2022-07-08  8:18     ` Sebastian Ene [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ysfoc2YhQCLge1iY@google.com \
    --to=sebastianene@google.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dragan.cvetic@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maz@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vdonnefort@google.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).