diff --git a/kern/include/lib.h b/kern/include/lib.h index 498ec28..5374a96 100644 --- a/kern/include/lib.h +++ b/kern/include/lib.h @@ -130,6 +130,7 @@ void *kmalloc(size_t size); void kfree(void *ptr); void kheap_printstats(void); void kheap_printused(void); +unsigned long kheap_getused(void); void kheap_nextgeneration(void); void kheap_dump(void); void kheap_dumpall(void); diff --git a/kern/vm/kmalloc.c b/kern/vm/kmalloc.c index f38dc37..3a5abbc 100644 --- a/kern/vm/kmalloc.c +++ b/kern/vm/kmalloc.c @@ -819,17 +819,17 @@ kheap_printstats(void) spinlock_release(&kmalloc_spinlock); } + /* - * Print number of used heap bytes. + * Return the number of used bytes. */ -void -kheap_printused(void) -{ + +unsigned long +kheap_getused(void) { struct pageref *pr; unsigned long total = 0; - char total_string[32]; - /* print the whole thing with interrupts off */ + /* compute with interrupts off */ spinlock_acquire(&kmalloc_spinlock); for (pr = allbase; pr != NULL; pr = pr->next_all) { total += subpage_stats(pr, true); @@ -837,7 +837,18 @@ kheap_printused(void) total += coremap_used_bytes(); spinlock_release(&kmalloc_spinlock); - snprintf(total_string, sizeof(total_string), "%lu", total); + 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"); } diff --git a/test161/tests/synch/cvt1.t b/test161/tests/synch/cvt1.t index 55e206d..7777395 100644 --- a/test161/tests/synch/cvt1.t +++ b/test161/tests/synch/cvt1.t @@ -2,9 +2,11 @@ name: "CV Test 1" description: Tests core CV functionality through cyclic waiting. -tags: [synch, cvs] +tags: [synch, cvs, kleaks] depends: [boot, semaphores, locks] sys161: cpus: 32 --- +khu cvt1 +khu diff --git a/test161/tests/synch/cvt2.t b/test161/tests/synch/cvt2.t index da00f74..95625c5 100644 --- a/test161/tests/synch/cvt2.t +++ b/test161/tests/synch/cvt2.t @@ -3,9 +3,11 @@ name: "CV Test 2" description: Tests core CV functionality through a mixture of sleeping and waking threads. -tags: [synch, cvs] +tags: [synch, cvs, kleaks] depends: [boot, semaphores, locks] sys161: cpus: 32 --- +khu cvt2 +khu diff --git a/test161/tests/synch/cvt5.t b/test161/tests/synch/cvt5.t index 0a9cd48..09338fb 100644 --- a/test161/tests/synch/cvt5.t +++ b/test161/tests/synch/cvt5.t @@ -1,10 +1,12 @@ --- name: "CV Test 5" description: - Tests CV and location relationship. -tags: [synch, cvs] + Tests CV and lock relationship. +tags: [synch, cvs, kleaks] depends: [boot, locks] sys161: cpus: 32 --- +khu cvt5 +khu diff --git a/test161/tests/synch/lt1.t b/test161/tests/synch/lt1.t index a64df15..e1528b9 100644 --- a/test161/tests/synch/lt1.t +++ b/test161/tests/synch/lt1.t @@ -2,9 +2,11 @@ name: "Lock Test 1" description: Tests core lock functionality through modifications to shared state. -tags: [synch, locks] +tags: [synch, locks, kleaks] depends: [boot, semaphores] sys161: cpus: 32 --- +khu lt1 +khu diff --git a/test161/tests/synch/rwt1.t b/test161/tests/synch/rwt1.t index 52c89d5..ef008e7 100644 --- a/test161/tests/synch/rwt1.t +++ b/test161/tests/synch/rwt1.t @@ -3,9 +3,11 @@ name: "RW Lock Test 1" description: Tests core reader-writer lock functionality by reading and writing shared state. -tags: [synch, rwlocks] +tags: [synch, rwlocks, kleaks] depends: [boot, semaphores] sys161: cpus: 32 --- +khu rwt1 +khu diff --git a/test161/tests/synch/rwt2.t b/test161/tests/synch/rwt2.t index cb2900a..2dbe216 100644 --- a/test161/tests/synch/rwt2.t +++ b/test161/tests/synch/rwt2.t @@ -3,9 +3,11 @@ name: "RW Lock Test 2" description: Tests that reader-writer locks allow maximum read concurrency when no writers are waiting. -tags: [synch, rwlocks] +tags: [synch, rwlocks, kleaks] depends: [boot, semaphores, cvs] sys161: cpus: 32 --- +khu rwt2 +khu diff --git a/test161/tests/synch/sem1.t b/test161/tests/synch/sem1.t index d8b0afc..61a27e3 100644 --- a/test161/tests/synch/sem1.t +++ b/test161/tests/synch/sem1.t @@ -2,9 +2,11 @@ name: "Semaphore Test" description: Tests core semaphore logic through cycling signaling. -tags: [synch, semaphores] +tags: [synch, semaphores, kleaks] depends: [boot] sys161: cpus: 32 --- +khu sem1 +khu diff --git a/test161/tests/synchprobs/sp1.t b/test161/tests/synchprobs/sp1.t index 454add7..b3925ad 100644 --- a/test161/tests/synchprobs/sp1.t +++ b/test161/tests/synchprobs/sp1.t @@ -3,4 +3,6 @@ name: "Whalemating Test" tags: [synchprobs] depends: [boot, semaphores, locks] --- +khu sp1 +khu diff --git a/test161/tests/synchprobs/sp2.t b/test161/tests/synchprobs/sp2.t index ca6e1ea..9a53695 100644 --- a/test161/tests/synchprobs/sp2.t +++ b/test161/tests/synchprobs/sp2.t @@ -3,4 +3,6 @@ name: "Stoplight Test" tags: [synchprobs] depends: [boot, semaphores, locks, cvs] --- +khu sp2 +khu