Tentitive (untested) ISA DMA space allocation fix.

Matthew Dillon dillon at apollo.backplane.com
Sun Sep 14 10:51:02 PDT 2003


    Scrap the old patch, it was still allocating low memory first
    in some cases and I improperly reversed the loop.  Here is a new,
    better one.

    I don't know if this will solve David's issue with twe.  If not
    then hopefully I will be able to track it down when I get my TWE
    card in about two weeks.  I'll also take a quick look at the TWE
    code to see if there is something obvious.

					-Matt

Index: vm/vm_page.c
===================================================================
RCS file: /cvs/src/sys/vm/vm_page.c,v
retrieving revision 1.9
diff -u -r1.9 vm_page.c
--- vm/vm_page.c	27 Aug 2003 01:43:08 -0000	1.9
+++ vm/vm_page.c	14 Sep 2003 17:44:50 -0000
@@ -150,13 +150,18 @@
 /*
  *	vm_add_new_page:
  *
- *	Add a new page to the freelist for use by the system.
+ *	Add a new page to the freelist for use by the system.  New pages
+ *	are added to both the head and tail of the associated free page
+ *	queue in a bottom-up fashion, so both zero'd and non-zero'd page
+ *	requests pull 'recent' adds (higher physical addresses) first.
+ *
  *	Must be called at splhigh().
  */
 vm_page_t
 vm_add_new_page(vm_offset_t pa)
 {
 	vm_page_t m;
+	struct vpgqueues *vpq;
 
 	++vmstats.v_page_count;
 	++vmstats.v_free_count;
@@ -165,7 +170,12 @@
 	m->flags = 0;
 	m->pc = (pa >> PAGE_SHIFT) & PQ_L2_MASK;
 	m->queue = m->pc + PQ_FREE;
-	TAILQ_INSERT_HEAD(&vm_page_queues[m->queue].pl, m, pageq);
+	vpq = &vm_page_queues[m->queue];
+	if (vpq->flipflop)
+		TAILQ_INSERT_TAIL(&vpq->pl, m, pageq);
+	else
+		TAILQ_INSERT_HEAD(&vpq->pl, m, pageq);
+	vpq->flipflop = 1 - vpq->flipflop;
 	vm_page_queues[m->queue].lcnt++;
 	return (m);
 }
@@ -304,7 +314,7 @@
 	vm_page_array_size = page_range;
 
 	/*
-	 * Construct the free queue(s) in descending order (by physical
+	 * Construct the free queue(s) in ascending order (by physical
 	 * address) so that the first 16MB of physical memory is allocated
 	 * last rather than first.  On large-memory machines, this avoids
 	 * the exhaustion of low physical memory before isa_dmainit has run.
Index: vm/vm_page.h
===================================================================
RCS file: /cvs/src/sys/vm/vm_page.h,v
retrieving revision 1.5
diff -u -r1.5 vm_page.h
--- vm/vm_page.h	26 Jul 2003 22:10:02 -0000	1.5
+++ vm/vm_page.h	14 Sep 2003 17:39:04 -0000
@@ -215,6 +215,7 @@
 	struct pglist pl;
 	int	*cnt;
 	int	lcnt;
+	int	flipflop;	/* probably not the best place */
 };
 
 extern struct vpgqueues vm_page_queues[PQ_COUNT];





More information about the Kernel mailing list