Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 May 2011 03:40:17 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221827 - head/sys/dev/xen/balloon
Message-ID:  <201105130340.p4D3eHuk058709@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri May 13 03:40:16 2011
New Revision: 221827
URL: http://svn.freebsd.org/changeset/base/221827

Log:
  Fix msleep() usage in Xen balloon driver to not wake up on every HZ tick.

Modified:
  head/sys/dev/xen/balloon/balloon.c

Modified: head/sys/dev/xen/balloon/balloon.c
==============================================================================
--- head/sys/dev/xen/balloon/balloon.c	Thu May 12 23:26:53 2011	(r221826)
+++ head/sys/dev/xen/balloon/balloon.c	Fri May 13 03:40:16 2011	(r221827)
@@ -147,12 +147,6 @@ balloon_retrieve(void)
 	return page;
 }
 
-static void 
-balloon_alarm(void *unused)
-{
-	wakeup(balloon_process);
-}
-
 static unsigned long 
 current_target(void)
 {
@@ -378,6 +372,8 @@ balloon_process(void *unused)
 	
 	mtx_lock(&balloon_mutex);
 	for (;;) {
+		int sleep_time;
+
 		do {
 			credit = current_target() - bs.current_pages;
 			if (credit > 0)
@@ -389,9 +385,12 @@ balloon_process(void *unused)
 		
 		/* Schedule more work if there is some still to be done. */
 		if (current_target() != bs.current_pages)
-			timeout(balloon_alarm, NULL, ticks + hz);
+			sleep_time = hz;
+		else
+			sleep_time = 0;
 
-		msleep(balloon_process, &balloon_mutex, 0, "balloon", -1);
+		msleep(balloon_process, &balloon_mutex, 0, "balloon",
+		       sleep_time);
 	}
 	mtx_unlock(&balloon_mutex);
 }
@@ -474,9 +473,6 @@ balloon_init(void *arg)
 	bs.hard_limit    = ~0UL;
 
 	kproc_create(balloon_process, NULL, NULL, 0, 0, "balloon");
-//	init_timer(&balloon_timer);
-//	balloon_timer.data = 0;
-//	balloon_timer.function = balloon_alarm;
     
 #ifndef XENHVM
 	/* Initialise the balloon with excess memory space. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105130340.p4D3eHuk058709>