mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: hansg@kernel.org, arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>,
	stable <stable@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] virt: vboxguest: send the heartbeat at the interval
Date: Tue, 27 Oct 2026 17:34:59 +0100	[thread overview]
Message-ID: <2026102758-grime-danger-9fb4@gregkh> (raw)

From: Josef Bacik <josef@toxicpanda.com>

The host tells the guest how often it expects a heartbeat.
vbg_heartbeat_timer() re-arms its timer with

  mod_timer(&gdev->heartbeat_timer, msecs_to_jiffies(interval));

But the second argument of mod_timer() is a point in time, not a delay.
An interval, taken as a point in time, lies in the past, so the timer
expires again on the next tick.  Whatever the host has asked for, the
guest sends a heartbeat 100 to 1000 times a second, depending on HZ, and
each of them is a request to the host, that is a VM exit from the timer
softirq.

On 32 bit, where jiffies starts five minutes before it wraps around,
these small values lie in the future at first.  That also goes for the 0
with which vbg_heartbeat_init() means to start the timer at once: if the
driver is loaded during boot, the first heartbeat is only sent five
minutes after boot.

Add jiffies in both places.  Every VirtualBox guest now sends its
heartbeat at the interval which the host has asked for.

Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
Cc: stable <stable@kernel.org>
Cc: Hans de Goede <hansg@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/virt/vboxguest/vboxguest_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c
index b5dc0d01facd..be6a8cc4e712 100644
--- a/drivers/virt/vboxguest/vboxguest_core.c
+++ b/drivers/virt/vboxguest/vboxguest_core.c
@@ -422,7 +422,7 @@ static void vbg_heartbeat_timer(struct timer_list *t)
 
 	vbg_req_perform(gdev, gdev->guest_heartbeat_req);
 	mod_timer(&gdev->heartbeat_timer,
-		  msecs_to_jiffies(gdev->heartbeat_interval_ms));
+		  jiffies + msecs_to_jiffies(gdev->heartbeat_interval_ms));
 }
 
 /**
@@ -482,7 +482,7 @@ static int vbg_heartbeat_init(struct vbg_dev *gdev)
 
 	vbg_info("%s: Setting up heartbeat to trigger every %d milliseconds\n",
 		 __func__, gdev->heartbeat_interval_ms);
-	mod_timer(&gdev->heartbeat_timer, 0);
+	mod_timer(&gdev->heartbeat_timer, jiffies);
 
 	return 0;
 }
-- 
2.56.0


             reply	other threads:[~2026-10-27 16:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 16:34 Greg Kroah-Hartman [this message]
2026-10-27 16:41 ` Hans de Goede

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=2026102758-grime-danger-9fb4@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=hansg@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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

all inboxes | Powered by JetHome®