Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Fix start_hint in "simple" alloc (fencepost error).
details: https://anonhg.NetBSD.org/src/rev/5fc06cf3daa2
branches: trunk
changeset: 761338:5fc06cf3daa2
user: matt <matt%NetBSD.org@localhost>
date: Mon Jan 24 19:13:55 2011 +0000
description:
Fix start_hint in "simple" alloc (fencepost error).
When restarting the loop, make sure end is not above current limit.
Do a quick test to see if the physseg is within the range of desired addresses.
diffstat:
sys/uvm/uvm_pglist.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diffs (84 lines):
diff -r d7790c643d5a -r 5fc06cf3daa2 sys/uvm/uvm_pglist.c
--- a/sys/uvm/uvm_pglist.c Mon Jan 24 17:52:07 2011 +0000
+++ b/sys/uvm/uvm_pglist.c Mon Jan 24 19:13:55 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_pglist.c,v 1.56 2011/01/23 21:29:52 he Exp $ */
+/* $NetBSD: uvm_pglist.c,v 1.57 2011/01/24 19:13:55 matt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.56 2011/01/23 21:29:52 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.57 2011/01/24 19:13:55 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -130,8 +130,7 @@
int cidx = 0; /* XXX: GCC */
#endif
#ifdef PGALLOC_VERBOSE
- printf("pgalloc: contig %d pgs from psi %ld\n", num,
- (long)(ps - vm_physmem));
+ printf("pgalloc: contig %d pgs from psi %zd\n", num, ps - vm_physmem);
#endif
KASSERT(mutex_owned(&uvm_fpageqlock));
@@ -141,6 +140,12 @@
alignment = atop(alignment);
/*
+ * Make sure that physseg falls within with range to be allocated from.
+ */
+ if (high <= ps->avail_start || low >= ps->avail_end)
+ return 0;
+
+ /*
* We start our search at the just after where the last allocation
* succeeded.
*/
@@ -169,7 +174,7 @@
*/
second_pass = true;
try = roundup2(max(low, ps->avail_start), alignment);
- limit = min(high, ps->avail_start + ps->start_hint);
+ limit = min(limit, ps->avail_start + ps->start_hint);
skip = 0;
continue;
}
@@ -362,8 +367,7 @@
struct vm_page *pg;
bool second_pass;
#ifdef PGALLOC_VERBOSE
- printf("pgalloc: simple %d pgs from psi %ld\n", num,
- (long)(ps - vm_physmem));
+ printf("pgalloc: simple %d pgs from psi %zd\n", num, ps - vm_physmem);
#endif
KASSERT(mutex_owned(&uvm_fpageqlock));
@@ -380,13 +384,21 @@
pg = &ps->pgs[try - ps->start];
second_pass = false;
+ /*
+ * Make sure that physseg falls within with range to be allocated from.
+ */
+ if (high <= ps->avail_start || low >= ps->avail_end)
+ return 0;
+
for (;; try++, pg++) {
if (try >= limit) {
- if (ps->start_hint == 0 || second_pass)
+ if (ps->start_hint == 0 || second_pass) {
+ try = limit - 1;
break;
+ }
second_pass = true;
try = max(low, ps->avail_start);
- limit = min(high, ps->avail_start + ps->start_hint);
+ limit = min(limit, ps->avail_start + ps->start_hint);
pg = &ps->pgs[try - ps->start];
continue;
}
Home |
Main Index |
Thread Index |
Old Index