mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] virt: vboxguest: send the heartbeat at the interval
@ 2026-10-27 16:34 Greg Kroah-Hartman
  2026-10-27 16:41 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-27 16:34 UTC (permalink / raw)
  To: hansg, arnd; +Cc: linux-kernel, Josef Bacik, stable, Greg Kroah-Hartman

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 16:34 [PATCH] virt: vboxguest: send the heartbeat at the interval Greg Kroah-Hartman
2026-10-27 16:41 ` Hans de Goede

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®