vm: NONCONTIGUOUS - try to make physical memory as maximally noncontiguous
This commit is contained in:
parent
f3ce085913
commit
8c925134f9
2 changed files with 31 additions and 3 deletions
|
@ -435,6 +435,17 @@ PRIVATE PUBLIC phys_bytes alloc_pages(int pages, int memflags, phys_bytes *len)
|
||||||
incr = 0;
|
incr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NONCONTIGUOUS
|
||||||
|
/* If NONCONTIGUOUS is on, allocate physical pages single
|
||||||
|
* pages at a time, accomplished by returning single pages
|
||||||
|
* if the caller can handle that (indicated by PAF_FIRSTBLOCK).
|
||||||
|
*/
|
||||||
|
if(memflags & PAF_FIRSTBLOCK) {
|
||||||
|
assert(!(memflags & PAF_CONTIG));
|
||||||
|
pages = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
while((pr = addr_get_iter(&iter))) {
|
while((pr = addr_get_iter(&iter))) {
|
||||||
SLABSANE(pr);
|
SLABSANE(pr);
|
||||||
assert(pr->size > 0);
|
assert(pr->size > 0);
|
||||||
|
@ -862,7 +873,7 @@ int usedpages_add_f(phys_bytes addr, phys_bytes len, char *file, int line)
|
||||||
struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
|
struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
|
||||||
{
|
{
|
||||||
phys_bytes rempages;
|
phys_bytes rempages;
|
||||||
struct memlist *head = NULL, *ml;
|
struct memlist *head = NULL, *tail = NULL;
|
||||||
|
|
||||||
assert(bytes > 0);
|
assert(bytes > 0);
|
||||||
assert(!(bytes % VM_PAGE_SIZE));
|
assert(!(bytes % VM_PAGE_SIZE));
|
||||||
|
@ -909,15 +920,29 @@ struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags)
|
||||||
USE(ml,
|
USE(ml,
|
||||||
ml->phys = CLICK2ABS(mem);
|
ml->phys = CLICK2ABS(mem);
|
||||||
ml->length = CLICK2ABS(gotpages);
|
ml->length = CLICK2ABS(gotpages);
|
||||||
ml->next = head;);
|
ml->next = NULL;);
|
||||||
head = ml;
|
if(tail)
|
||||||
|
tail->next = ml;
|
||||||
|
tail = ml;
|
||||||
|
if(!head)
|
||||||
|
head = ml;
|
||||||
rempages -= gotpages;
|
rempages -= gotpages;
|
||||||
} while(rempages > 0);
|
} while(rempages > 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
struct memlist *ml;
|
||||||
for(ml = head; ml; ml = ml->next) {
|
for(ml = head; ml; ml = ml->next) {
|
||||||
assert(ml->phys);
|
assert(ml->phys);
|
||||||
assert(ml->length);
|
assert(ml->length);
|
||||||
|
#if NONCONTIGUOUS
|
||||||
|
if(!(flags & PAF_CONTIG)) {
|
||||||
|
assert(ml->length == VM_PAGE_SIZE);
|
||||||
|
if(ml->next)
|
||||||
|
assert(ml->phys + ml->length != ml->next->phys);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,10 @@
|
||||||
/* Compile in asserts and custom sanity checks at all? */
|
/* Compile in asserts and custom sanity checks at all? */
|
||||||
#define SANITYCHECKS 0
|
#define SANITYCHECKS 0
|
||||||
#define VMSTATS 0
|
#define VMSTATS 0
|
||||||
|
|
||||||
|
/* VM behaviour */
|
||||||
#define JUNKFREE 0 /* Fill freed pages with junk */
|
#define JUNKFREE 0 /* Fill freed pages with junk */
|
||||||
|
#define NONCONTIGUOUS 0 /* Make phys pages max. noncontiguous */
|
||||||
|
|
||||||
/* How noisy are we supposed to be? */
|
/* How noisy are we supposed to be? */
|
||||||
#define VERBOSE 0
|
#define VERBOSE 0
|
||||||
|
|
Loading…
Reference in a new issue