diff options
author | neal <neal> | 2008-06-16 21:27:40 +0000 |
---|---|---|
committer | neal <neal> | 2008-06-16 21:27:40 +0000 |
commit | 0cc9b9efcad805a9118c368b72b13417315526c9 (patch) | |
tree | 03548e0caa9ec35d3f5326195e9b3ecc30d40679 /ruth | |
parent | 64639177cfc19f25b4c65ec7a8f8af110264c907 (diff) |
libhurd-mm/
2008-06-16 Neal H. Walfield <neal@gnu.org>
* map.h: New file.
* map.c: New file.
* Makefile.am (libhurd_mm_a_SOURCES): Add map.h and map.c.
* headers.m4: Link map.h to sysroot/include/hurd/map.h.
* pager.h: Rewrite.
* pager.c: Likewise.
* anonymous.h (ANONYMOUS_STAGING_AREA): New define.
(anonymous_pager_fill_t): Don't pass the base of the region. Pass
the location of the storage corresponding to the pages on which
the faults were raised and the offset into the region. Update
users.
(struct anonymous_pager): Add fields map_area, map_area_count and
lock. Remove field alloced_region.
(anonymous_pager_alloc): Replace size parameter with length
parameter. Take access parameter indicating the desired access.
Update users.
* anonymous.c (offset_compare): Compare the values, not the
pointers.
(fault): Update signature to be consistent with new API. Lock
ANON->LOCK. Always look up the storage descriptor corresponding
to the faulted page. Copy the storage to the faulted address as
required. Update how we call ANON->FILL to be consistent with the
new API.
(destroy): Free ANON->STAGING_AREA.
(anonymous_pager_alloc): Update signature to be consistent with
new API. Allocate the staging area if ANONYMOUS_STAGING_AREA is
set. Allocate it separately from the main map. Create a map
corresponding to the region.
(anonymous_pager_destroy): Just lock ANON->LOCK. Don't call
destroy, call pager_deinit.
* mmap.c: Include <hurd/map.h>.
(mmap): Add support for protection other than read/write.
(munmap): Rewrite to use new API. Use map_split to support
splitting of memory maps.
* exceptions.c: Don't include "pager.h", include "map.h".
(exception_handler_normal): Don't call pager_fault but map_fault.
(exception_handler_activated): Likewise.
ruth/
2008-06-16 Neal H. Walfield <neal@gnu.org>
* ruth.c (main): Improve mmap test. Update use of
anonymous_pager_alloc to be consistent with new API. Update fill
functions to be consistent with new API. Remove redundant test.
benchmarks/
2008-06-16 Neal H. Walfield <neal@gnu.org>
* activity-distribution.c (main): Update use of
anonymous_pager_alloc to be consistent with new API. Update fill
functions to be consistent with new API.
Diffstat (limited to 'ruth')
-rw-r--r-- | ruth/ChangeLog | 6 | ||||
-rw-r--r-- | ruth/ruth.c | 96 |
2 files changed, 49 insertions, 53 deletions
diff --git a/ruth/ChangeLog b/ruth/ChangeLog index 2984afc..2d3490e 100644 --- a/ruth/ChangeLog +++ b/ruth/ChangeLog @@ -1,3 +1,9 @@ +2008-06-16 Neal H. Walfield <neal@gnu.org> + + * ruth.c (main): Improve mmap test. Update use of + anonymous_pager_alloc to be consistent with new API. Update fill + functions to be consistent with new API. Remove redundant test. + 2008-06-05 Neal H. Walfield <neal@gnu.org> * ruth.c (main): Replace use of slot_lookup with as_cap_lookup. diff --git a/ruth/ruth.c b/ruth/ruth.c index 26c0df9..6ec3599 100644 --- a/ruth/ruth.c +++ b/ruth/ruth.c @@ -267,16 +267,40 @@ main (int argc, char *argv[]) { printf ("Checking mmap... "); -#define SIZE (16 * PAGESIZE) - void *buffer = mmap (0, SIZE, PROT_READ | PROT_WRITE, + const int pages = 16; + void *buffer = mmap (0, pages * PAGESIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); assert (buffer != MAP_FAILED); - char *p; - for (p = buffer; (uintptr_t) p < (uintptr_t) buffer + SIZE; p ++) - *p = 1; - for (p = buffer; (uintptr_t) p < (uintptr_t) buffer + SIZE; p ++) - assert (*p == 1); + struct { int start; int count; } order[] = { { 1, 2 }, + { 3, 3 }, + { 10, 2 }, + { 15, 1 } }; + bool unmapped[pages]; + memset (unmapped, 0, sizeof (unmapped)); + + int j; + for (j = 0; j < pages; j ++) + *(int *) (buffer + j * PAGESIZE) = j; + + int i; + for (i = 0; i < sizeof (order) / sizeof (order[0]); i ++) + { + assert (order[i].start + order[i].count <= pages); + + munmap (buffer + order[i].start * PAGESIZE, order[i].count * PAGESIZE); + + for (j = order[i].start; j < order[i].start + order[i].count; j ++) + unmapped[j] = true; + + for (j = 0; j < pages; j ++) + if (! unmapped[j]) + assertx (*(int *) (buffer + j * PAGESIZE) == j, + "%d =? %d", + *(int *) (buffer + j * PAGESIZE), j); + } + + munmap (buffer, pages * PAGESIZE); printf ("ok.\n"); } @@ -892,11 +916,13 @@ main (int argc, char *argv[]) const int s = 4 * PAGESIZE; bool fill (struct anonymous_pager *anon, - void *base, uintptr_t offset, - uintptr_t pages, + uintptr_t offset, uintptr_t count, + void *pages[], struct exception_info info) { - int *p = base + offset; + assert (count == 1); + + int *p = pages[0]; int i; for (i = 0; i < PAGESIZE / sizeof (int); i ++) p[i] = offset / sizeof (int) + i; @@ -906,7 +932,7 @@ main (int argc, char *argv[]) void *addr; struct anonymous_pager *pager - = anonymous_pager_alloc (ADDR_VOID, NULL, s, + = anonymous_pager_alloc (ADDR_VOID, NULL, s, MAP_ACCESS_ALL, OBJECT_POLICY_DEFAULT, 0, fill, &addr); assert (pager); @@ -920,55 +946,19 @@ main (int argc, char *argv[]) } { - printf ("Checking rendered regions (all at once)... "); - - const int s = 4 * PAGESIZE; - - bool fill (struct anonymous_pager *anon, - void *base, uintptr_t offset, - uintptr_t pages, - struct exception_info info) - { - static int once; - - assert (! once); - once = true; - - int *p = base; - int i; - for (i = 0; i < s / sizeof (int); i ++) - p[i] = i; - - return true; - } - - void *addr; - struct anonymous_pager *pager - = anonymous_pager_alloc (ADDR_VOID, NULL, s, - OBJECT_POLICY_DEFAULT, ANONYMOUS_NO_RECURSIVE, - fill, &addr); - assert (pager); - - int *p = addr; - int i; - for (i = 0; i < s / sizeof (int); i ++) - assert (p[i] == i); - - printf ("ok\n"); - } - - { printf ("Checking discardability... "); bool fill (struct anonymous_pager *anon, - void *base, uintptr_t offset, - uintptr_t pages, + uintptr_t offset, uintptr_t count, + void *pages[], struct exception_info info) { + assert (count == 1); + if (! info.discarded) return true; - * (int *) (base + offset) = offset / PAGESIZE; + * (int *) pages[0] = offset / PAGESIZE; return true; } @@ -991,7 +981,7 @@ main (int argc, char *argv[]) void *addr; struct anonymous_pager *pager - = anonymous_pager_alloc (ADDR_VOID, NULL, goal * PAGESIZE, + = anonymous_pager_alloc (ADDR_VOID, NULL, goal * PAGESIZE, MAP_ACCESS_ALL, OBJECT_POLICY (true, OBJECT_PRIORITY_LRU), 0, fill, &addr); assert (pager); |