Gmane
From: John Tobey <jtobey <at> john-edwin-tobey.org>
Subject: Bug#185094: Patch consider_lmm_collect: Test always true
Newsgroups: gmane.os.hurd.bugs
Date: 2003-03-17 00:39:16 GMT (6 years, 47 weeks, 1 day, 14 hours and 3 minutes ago)
Package: gnumach
Version: CVS 20030316

In gnumach/oskit/osenv_mem.c, consider_lmm_collect() looks as if it
can stop short of transfering the optimal number of pages from VM to
LMM due to an oversight.  The variable `i' is decremented to 0 before
it is compared to `batch'.  Since `batch' is always positive there,
the test will always come out true, and the loop will exit too early.

The following patch should fix this.

-John

Index: oskit/osenv_mem.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/oskit/osenv_mem.c,v
retrieving revision 1.2
diff -u -r1.2 osenv_mem.c
--- oskit/osenv_mem.c	27 May 2002 23:01:57 -0000	1.2
+++ oskit/osenv_mem.c	16 Mar 2003 23:47:40 -0000
@@ -402,10 +402,11 @@
 	  unsigned int batch = need > PAGE_BATCH ? PAGE_BATCH : need;
 	  void *pages[PAGE_BATCH];
 	  unsigned int i;
+	  vm_page_t mem = VM_PAGE_NULL;

 	  for (i = 0; i < batch; ++i)
 	    {
-	      vm_page_t mem = vm_page_grab (FALSE);
+	      mem = vm_page_grab (FALSE);
 	      if (mem == VM_PAGE_NULL)
 		break;
 	      pages[i] = (void *) mem->phys_addr;
@@ -424,7 +425,7 @@
 	  simple_unlock (&phys_lmm_lock);
 	  splx (s);

-	  if (i < batch)
+	  if (mem == VM_PAGE_NULL)
 	    break;
 	  need -= batch;
 	}