virt: vboxguest: send the heartbeat at the interval
Greg Kroah-Hartman
maintainerPATCH 1/1 virt: vboxguest: send the heartbeat at the interval
From: Josef Bacik <[email protected]>
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.
--- drivers/virt/vboxguest/vboxguest_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virt/vboxguest/vboxguest_core.c +2 -2
@@ -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 ; }
Signature · 1 line
2.56.0
Hi,
Quoted 23 lines · Greg Kroah-Hartman
From: Josef Bacik <[email protected]>
The host tells the guest how often it expects a heartbeat.
vbg_heartbeat_timer()re-arms its timer withmod_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.
Quoted 6 lines
Fixes 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")Cc stable <[email protected]>Cc Hans de Goede <[email protected]>Cc Arnd Bergmann <[email protected]>Signed-off-by Josef Bacik <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Thanks, patch looks good to me:
Regards,
Hans
Quoted 26 lines
--- drivers/virt/vboxguest/vboxguest_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/virt/vboxguest/vboxguest_core.c +2
-2@@ -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 ; }