diff options
-rw-r--r-- | sys/uvm/uvm_pmemrange.c | 25 | ||||
-rw-r--r-- | sys/uvm/uvm_pmemrange.h | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c index 76f75803576..3ea1d7b41c7 100644 --- a/sys/uvm/uvm_pmemrange.c +++ b/sys/uvm/uvm_pmemrange.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmemrange.c,v 1.6 2009/06/14 02:04:15 deraadt Exp $ */ +/* $OpenBSD: uvm_pmemrange.c,v 1.7 2009/06/14 02:20:23 deraadt Exp $ */ /* * Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl> @@ -619,8 +619,17 @@ ReTryDesperate: */ if (count <= maxseg && align == 1 && boundary == 0 && (flags & UVM_PLA_TRY_CONTIG) == 0) { - fcount += uvm_pmr_get1page(count - fcount, memtype, result, - start, end); + if (!desperate) { + KASSERT(fcount == 0); + fcount += uvm_pmr_get1page(count, memtype, result, + start, end); + } else { + for (memtype = 0; memtype < UVM_PMR_MEMTYPE_MAX && + fcount < count; memtype++) { + fcount += uvm_pmr_get1page(count - fcount, + memtype, result, start, end); + } + } if (fcount == count) goto Out; @@ -688,7 +697,6 @@ DrainFound: goto ReScan; } -Fail: /* * Not enough memory of the requested type available. Fall back to * less good memory that we'll clean up better later. @@ -699,13 +707,12 @@ Fail: */ if (!desperate) { desperate = 1; -#if UVM_PMR_MEMTYPE_MAX != 2 -#error Too many memtypes, need to become smarter! -#endif - memtype = UVM_PMR_MEMTYPE_MAX - 1 - memtype; + memtype = 0; + goto ReTryDesperate; + } else if (++memtype < UVM_PMR_MEMTYPE_MAX) goto ReTryDesperate; - } +Fail: /* * Allocation failed. */ diff --git a/sys/uvm/uvm_pmemrange.h b/sys/uvm/uvm_pmemrange.h index 38f7cc1c2c3..493961f1f9c 100644 --- a/sys/uvm/uvm_pmemrange.h +++ b/sys/uvm/uvm_pmemrange.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmemrange.h,v 1.2 2009/06/10 20:36:40 ariane Exp $ */ +/* $OpenBSD: uvm_pmemrange.h,v 1.3 2009/06/14 02:20:23 deraadt Exp $ */ /* * Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl> @@ -34,7 +34,7 @@ RB_HEAD(uvm_pmr_size, vm_page); * - DIRTY: this page may contain random data. * - ZERO: this page has been zeroed. */ -#define UVM_PMR_MEMTYPE_DIRTY 0 +#define UVM_PMR_MEMTYPE_DIRTY 1 #define UVM_PMR_MEMTYPE_ZERO 1 #define UVM_PMR_MEMTYPE_MAX 2 |