Revert "Merging in 1.0.2."

This reverts commit 50cf3276e7.
This commit is contained in:
Geoffrey Challen
2017-01-09 22:52:13 -05:00
parent 50cf3276e7
commit e318e3171e
118 changed files with 3158 additions and 1350 deletions

View File

@@ -31,6 +31,8 @@
#include <lib.h>
#include <spinlock.h>
#include <vm.h>
#include <kern/test161.h>
#include <test.h>
/*
* Kernel malloc.
@@ -743,8 +745,8 @@ kheap_dumpall(void)
* Print the allocated/freed map of a single kernel heap page.
*/
static
void
subpage_stats(struct pageref *pr)
unsigned long
subpage_stats(struct pageref *pr, bool quiet)
{
vaddr_t prpage, fla;
struct freelist *fl;
@@ -780,18 +782,21 @@ subpage_stats(struct pageref *pr)
}
}
kprintf("at 0x%08lx: size %-4lu %u/%u free\n",
(unsigned long)prpage, (unsigned long) sizes[blktype],
(unsigned) pr->nfree, n);
kprintf(" ");
for (i=0; i<n; i++) {
int val = (freemap[i/32] & (1<<(i%32)))!=0;
kprintf("%c", val ? '.' : '*');
if (i%64==63 && i<n-1) {
kprintf("\n ");
if (!quiet) {
kprintf("at 0x%08lx: size %-4lu %u/%u free\n",
(unsigned long)prpage, (unsigned long) sizes[blktype],
(unsigned) pr->nfree, n);
kprintf(" ");
for (i=0; i<n; i++) {
int val = (freemap[i/32] & (1<<(i%32)))!=0;
kprintf("%c", val ? '.' : '*');
if (i%64==63 && i<n-1) {
kprintf("\n ");
}
}
kprintf("\n");
}
kprintf("\n");
return ((unsigned long)sizes[blktype] * (n - (unsigned) pr->nfree));
}
/*
@@ -808,12 +813,55 @@ kheap_printstats(void)
kprintf("Subpage allocator status:\n");
for (pr = allbase; pr != NULL; pr = pr->next_all) {
subpage_stats(pr);
subpage_stats(pr, false);
}
spinlock_release(&kmalloc_spinlock);
}
/*
* Return the number of used bytes.
*/
unsigned long
kheap_getused(void) {
struct pageref *pr;
unsigned long total = 0;
unsigned int num_pages = 0, coremap_bytes = 0;
/* compute with interrupts off */
spinlock_acquire(&kmalloc_spinlock);
for (pr = allbase; pr != NULL; pr = pr->next_all) {
total += subpage_stats(pr, true);
num_pages++;
}
coremap_bytes = coremap_used_bytes();
// Don't double-count the pages we're using for subpage allocation;
// we've already accounted for the used portion.
if (coremap_bytes > 0) {
total += coremap_bytes - (num_pages * PAGE_SIZE);
}
spinlock_release(&kmalloc_spinlock);
return total;
}
/*
* Print number of used bytes.
*/
void
kheap_printused(void)
{
char total_string[32];
snprintf(total_string, sizeof(total_string), "%lu", kheap_getused());
secprintf(SECRET, total_string, "khu");
}
////////////////////////////////////////
/*
@@ -967,7 +1015,7 @@ subpage_kmalloc(size_t sz
prpage = alloc_kpages(1);
if (prpage==0) {
/* Out of memory. */
kprintf("kmalloc: Subpage allocator couldn't get a page\n");
silent("kmalloc: Subpage allocator couldn't get a page\n");
return NULL;
}
KASSERT(prpage % PAGE_SIZE == 0);