summaryrefslogtreecommitdiff
path: root/libhurd-mm/pager.c
AgeCommit message (Collapse)Author
2008-06-232008-06-23 Neal H. Walfield <neal@gnu.org>neal
* pager.c (pager_deinit): Drop PAGER->LOCK before calling MAP_DESTROY.
2008-06-172008-06-17 Neal H. Walfield <neal@gnu.org>neal
* pager.c (pager_init): Clear PAGER->LOCK. (pager_deinit): Don't use a while loop but an infinite loop.
2008-06-16libhurd-mm/neal
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.
2008-05-29libhurd-mm/neal
2008-05-29 Neal H. Walfield <neal@gnu.org> * exceptions.c (exception_handler_activated): Assume the fault is on the stack if it is one page above or three pages below the stack pointer. (exception_handler_init): Allocate an area of address space EXCEPTION_STACK_SIZE bytes larges. Fill it with pages. Set the first page as the thread's exception page and the top of the area minus one word as the stack pointer. Set the last word to the location of the exception page. * ia32-exception-entry.S: Include <hurd/exceptions.h>. (PAGESIZE): Don't define. (_exception_handler_entry): Rewrite to not assume that the exception page is at the start of the page in which the stack pointer is, but at the location stored in the word after the bottom of the stack. * Makefile.am (libhurd_mm_a_CCASFLAGS): New variable. * pager.c (ensure_stack): Change SPACE to be EXCEPTION_STACK_SIZE - PAGESIZE bytes large. Write to each page. libpthread/ 2008-05-29 Neal H. Walfield <neal@gnu.org> * sysdeps/l4/hurd/pt-sysdep.h Include <hurd/exceptions.h>. (EXCEPTION_AREA_SIZE): Define. (EXCEPTION_AREA_SIZE_LOG2): Likewise. (EXCEPTION_PAGE): Likewise. (PTHREAD_SYSDEP_MEMBERS): Change object's type to an addr_t. Update users. Remove field exception_page, replace with exception_area. Add field exception_area_va. * sysdeps/l4/hurd/pt-thread-alloc.c: Include <hurd/as.h> and <hurd/addr.h>. (__pthread_thread_alloc): Allocate EXCEPTION_AREA_SIZE bytes of address space. Save it in THREAD->EXCEPTION_AREA_VA. Allocate a page for each page in that area. Save them in THREAD->EXCEPTION_AREA. * sysdeps/l4/hurd/ia32/pt-setup.c (__pthread_setup): Set EXCEPTION_PAGE->EXCEPTION_HANDLER_SP to the end of EXCEPTION_PAGE->EXCEPTION_HANDLER_SP minus one word, in which we save the address of the exception page. * sysdeps/l4/hurd/pt-thread-start.c (__pthread_thread_start): Set IN.EXCEPTION_PAGE to the first page in THREAD->EXCEPTION_AREA_VA. * sysdeps/l4/hurd/pt-thread-halt.c: Include <hurd/mutex.h>, <hurd/as.h> and <hurd/addr.h>. (saved_object_lock): New variable. (__pthread_thread_halt): Lock SAVED_OBJECT_LOCK when accessing SAVED_OBJECT. Free the address space used by the exception area (THREAD->EXCEPTION_AREA_VA) and its associated storage (THREAD->EXCEPTION_AREA). hurd/ 2008-05-29 Neal H. Walfield <neal@gnu.org> * exceptions.h: Include <hurd/stddef.h>. [ASM]: Only define relevant macros. (EXCEPTION_STACK_SIZE_LOG2): Define. (EXCEPTION_STACK_SIZE): Define. * stddef.h [ASM]: Only define relevant macros. (PAGESIZE): Don't append C type specifier. (PAGESIZE_LOG2): Likewise. viengoos/ 2008-05-29 Neal H. Walfield <neal@gnu.org> * as.c: Include <hurd/exceptions.h>. (ensure_stack): Change SPACE to be EXCEPTION_STACK_SIZE - PAGESIZE bytes large. Write to each page. * cap-lookup.c: Include <hurd/exceptions.h>. (ensure_stack): Change SPACE to be EXCEPTION_STACK_SIZE - PAGESIZE bytes large. Write to each page. * zalloc.c (ZONE_SIZE): Add suffix the 1 with a U type qualifier. (ZONES): Include one less zone.
2008-02-20libhurd-mm/neal
2008-02-20 Neal H. Walfield <neal@gnu.org> * anonymous.h: Include <hurd/exceptions.h> and <l4/thread.h>. (ANONYMOUS_ZEROFILL): Rename from this... (ANONYMOUS_NO_CLEAR): ... to this, inverting logic. Update users. (ANONYMOUS_DISCARDABLE): Don't define. (ANONYMOUS_NO_ALLOC): Define. (ANONYMOUS_NO_RECURSIVE): Likewise. (ANONYMOUS_THREAD_SAFE): Likewise. (anonymous_pager_fill_t): Likewise. (struct anonymous_pager): Add fields allocated_region, staging_area, fill, fill_thread, fill_lock and policy. Change fill's type to anonymous_pager_fill_t. (anonymous_pager_alloc): Take additional parameters, P and ADDR_OUT. Change the fill function's type to anonymous_pager_fill_t. Require that the address is not already allocated. Update users. * anonymous.c: Include <string.h> and <hurd/rm.h>. (struct storage_desc): Remove field addr and replace with offset. (addr_compare): Remove function. (offset_compare): New function. (storage_desc): Change node key from the addr field to the offset field. (fault): Rewrite to handle a fill function, discarded pages, and the ANONYMOUS_NO_RECURSIVE and ANONYMOUS_NO_ALLOC flags. (destroy): Free the allocated region and any staging area. (anonymous_pager_alloc): Rewrite to allocate virtual memory. Set up the data structure appropriately if ANONYMOUS_THREAD_SAFE is given. * pager.h (PAGER_REGION_LENGTH): New define. (pager_fault_t): Change ABI such that the callback must release PAGER->LOCK. * pager.c (pager_fault): Don't release PAGER->LOCK. ruth/ 2008-02-20 Neal H. Walfield <neal@gnu.org> * ruth.c: Include <hurd/anonymous.h>, <stdlib.h> and <l4.h>. (main): Add tests to check rendered regions and discardable pages.
2008-02-082008-02-08 Neal H. Walfield <neal@gnu.org>neal
* pager.c (__attribute__): New function. (pager_fault): Call it before taking PAGERS_LOCK.
2007-12-122007-12-12 Neal H. Walfield <neal@gnu.org>neal
* mmap.c (munmap): Implement. * pager.h (pager_destroy_t): New type. (struct pager): New field, destory. (pagers): New declaration. * pager.c (pagers): Remove static qualifier. * anonymous.c (destroy): New function. (anonymous_pager_alloc): Set ANON->PAGER.DESTROY to it. (anonymous_pager_destroy): Call destroy to do the bulk of the work.
2007-12-102007-12-10 Neal H. Walfield <neal@gnu.org>neal
* as.c: Don't include <pthread.h>. Include <hurd/mutex.h>. (free_spaces_lock): Make an ss_mutex_t, not a pthread_mutex_t. Update users. * storage.c: Don't include <pthread.h>. Include <hurd/mutex.h>. (struct storage_desc): Make lock an ss_mutex_t, not a pthread_mutex_t. Update users. (storage_descs_lock): Likewise. * pager.h: Don't include <pthread.h>. Include <hurd/mutex.h>. (struct pager): Make lock an ss_mutex_t, not a pthread_mutex_t. Update users. (pagers_lock): Likewise.
2007-11-272007-11-27 Neal H. Walfield <neal@gnu.org>neal
* as.c: Include <pthread.h>. Remove dead code. (free_spaces_lock): New variable. (free_space_split): Assert that it is held. (as_alloc): Make thread-safe. (as_alloc_at): Likewise. (as_free): Likewise. (as_alloced_dump): Likewise. * storage.c: Include <pthread.h> and <atomic.h>. (free_count): Make a uatomic32_t, rather than an int. Update users to access it using atomic operations. (struct storage_desc): New field, lock. (storage_descs_lock): New global variable. (link): Assert that STORAGE_DESCS_LOCK is held. (unlink): Likewise. Don't assert that E->NEXT is NULL, which is valid. (slab_space_reserve): Make an atomicptr_t, rather than a void *. Update users to access it using atomic operations. (check_slab_space_reserve): Rewrite function to be thread-safe. (storage_desc_free): Assert that STORAGE_DESCS_LOCK is held. (storage_alloc): Rewrite function to be thread-safe. (storage_free): Likewise. (storage_init): Take STORAGE_DESCS_LOCK. Initialize SDESC->LOCK. * capalloc.c: Include <pthread.h>. (struct cappage_desc): New field, lock. (unlink): Don't assert E->NEXT. (cappage_descs_lock): New variable. (capalloc): Make thread safe. (capfree): Likewise. * pager.h: Include <pthread.h>. (pager_fault_t): Note that PAGER->LOCK will be held. (struct pager): New field, lock. (pagers_lock): New declaration. (pager_install): Note locking requirements. (pager_relocate): Likewise. (pager_deinstall): Likewise. * pager.c (pagers_lock): New definition. (pager_install): Add asserts. (pager_relocate): Likewise. (pager_deinstall): Likewise. (pager_fault): Likewise. Make function thread-safe. * anonymous.c (struct storage_desc): Add comment about locking. (fault): Add assert. (anonymous_pager_alloc): Take PAGERS_LOCK before calling pager_install and drop it afterwards. (anonymous_pager_destroy): Take PAGERS_LOCK before calling pager_deinstall and drop it afterwards. Take ANON->PAGER.LOCK.
2007-11-19hurd/neal
2007-11-19 Neal H. Walfield <neal@gnu.org> * Makefile.am (includehurd_HEADERS): Add exceptions.h. * headers.m4: Link $(BUILDIR)/include/hurd/exceptions.h to exceptions.h. * exceptions.h: New file. viengoos/ 2007-11-19 Neal H. Walfield <neal@gnu.org> * thread.h (struct thread): Add fields have_exception and exception. (UTCB_AREA_SIZE): Provide space for two UTCBs. * thread.c: Include <hurd/exceptions.h>. (thread_create_in): For each thread that we allocate, allocate two consecutive l4 thread ids. (thread_commission): Initialize the main thread and the exception thread. (thread_decommission): Destroy both the main thread and the exception thread. * rm.h: Add RM_exception_collect. (rm_method_id_string): Handle RM_exception_collect. (exception_collect): New RPC method. * server.c: Include <hurd/exceptions.h>. (server_loop): If FROM is the exception thread, look up the thread object using the main thread id. Propagate any fault to the exception thread. If not immediately successful, save the message in THREAD->EXCEPTION and set THREAD->HAVE_EXCEPTION. Implement the exception_collect method. (DEBUG): Also print the method number. libhurd-mm/ 2007-11-19 Neal H. Walfield <neal@gnu.org> * Makefile.am (libhurd_mm_a_SOURCES): Add exceptions.h, exceptions.c, pager.h, pager.c, anonymous.h and anonymous.c. * headers.m4: Link $(BUILDDIR)/include/hurd/pager.h to pager.h. Link $(BUILDDIR)/include/hurd/anonymous.h to anonymous.h. * mm-init.c: Include "exceptions.h". (mm_init): Call exception_handler_init. * pager.h: Completely rewrite. * pager.c: Likewise. * anonymous.h: Likewise. * anonymous.c: Likewise. * exceptions.h: New file. * exceptions.c: Likewise. * mmap.c: Include <hurd/anonymous.h>. (mmap): Rewrite to use an anonymous pager.
2005-04-062005-04-06 Neal H. Walfield <neal@gnu.org>neal
* vm.h (hurd_vm_allocate): Remove declaration. (hurd_vm_release): Rename from hurd_vm_deallocate. Update callers. (VM_HERE): Remove. (VM_ZEROFILL): Remove. * vm.c (hurd_vm_allocate): Remove function. (hurd_vm_release): Rename from hurd_vm_deallocate. * mm.h: Include <stdint.h>, <sys/types.h>, <l4/types.h> and <hurd/physmem.h>. (hurd_store_t): New typedef. (hurd_memory_t): Likewise. (hurd_memory_use): New declaration. (hurd_memory_transfer): Likewise. (hurd_store_fault_t): New typedef. (hurd_store_init): New declaration. (hurd_store_size): New declaration. (HURD_VM_HERE): New definition. (hurd_store_bind_to_vm): New declaration. (hurd_store_flush): New declaration. * priv.h: Include "vm.h" and "mm.h". (here): New debugging macro. (struct region): Move to... * mm.h: ...here. (struct hurd_memory): Rename from struct frame. Rename field dc_start to cont_start. Add field cont. Remove field refs. Update users. (memory_slab): Rename from frame_slab. Update users. (memory_alloc_into): Rename from frame_alloc_into. Update users. (frame_alloc): Move to... * priv.h (frame_insert): Move to... * mm.h (hurd_store_cache): ...here. * priv.h (frame_find_first): Move to... * mm.h (hurd_store_find_cached): ...here. * priv.h (frame_map): Move to... * mm.h (hurd_memory_map): ...here. * priv.h (frame_dealloc): Move to... * mm.h (hurd_memory_dealloc): ...here. * priv.h (struct hurd_store): Rename from struct store. Remove fields server and handle. Add fields hook and fault. Rename field frames to memory. Update users. (store_find_free): Remove declaration. (struct map): Add field store_offset. (default_container): Likewise. (map_init): Likewise. (map_free): Rename from map_dealloc. Update callers. (map_init): New declaration. (map_find_first): Rename from map_find. Update callers. (as_find_free): Rename from map_find_free. Update callers. (container_find_free): Remove declaration. (core_slab_allocate_buffer): Rename from mem_slab_allocate_buffer. Update users. (core_slab_deallocate_buffer): Rename from mem_slab_deallocate_buffer. Update users. (frame_spare): Rename to memory_spare. Update users. (core_store): New declaration. * map.c (VIRTUAL_MEMORY_START): Move from here... * priv.h: ...to here. * map.c (as): Move from here... * as.c: ...to here. (map_system_init): Rename from map_init. Reserve the UTCB and the KIP. (memory_spare): Rename from frame_spare. (core_slab_allocate_buffer): Rename from mem_slab_allocate_buffer. (core_slab_deallocate_buffer): Rename from mem_slab_deallocate_buffer. (map_init): New function. (map_free): Rename from map_dealloc. (map_find): Rename from map_find_first. Avoid gratuitous hurd_btree_map_prev. (map_find_free): Remove function. (store_find_free): Move from here... * as.c (as_find_free): ...to here. * frame.c: Move from here... * memory.c: ...to here. Include <hurd/startup.h>. (swap_store): Remove definition. (memory_slab): Rename from frame_slab. (default_container): New static global. (dc_offset): New function. (memory_system_init): Likewise. (memory_alloc_into): Rename from frame_alloc_into. (hurd_memory_new): New function. Refactored from frame_alloc. (hurd_memory_delete): New function. (hurd_memory_alloc): Rename from frame_alloc. Rewritten to use hurd_memory_new. (frame_insert): Move from here... * store.c (hurd_store_cache): ...to here. * memory.c (hurd_memory_use): New function. (hurd_memory_transfer): New function. (hurd_memory_dealloc): Rename from frame_dealloc. Don't deallocate too eagerly: split memory which is only partially deallocated. (frame_find_first): Move from here... * store.c (hurd_store_find_cached): ...to here. * memory.c (hurd_memory_map): Rename from frame_map. Loop mapping all of the requested if a single RPC is insufficient. * mm-init.c (default_container): Remove definition. (hurd_mm_init): Don't initialize DEFAULT_CONTAINER. Don't initialize the store data structures. Call memory_system_init, core_system_init, hurd_anonymous_init, and map_system_init. Use core_allocate rather than hurd_vm_allocate to allocate a stack for the pager thread. * pager.c (pager): Don't round ADDR. Call MAP->STORE->FAULT if the physical memory is not cached. * physmem-user.h: Include <hurd/physmem.h>. Improve documentation. (hurd_pm_control_t): Remove redundant typedef. (hurd_pm_container_t): Likewise. (hurd_pm_container_access_t): Remove typedef. (HURD_PM_CONT_ALLOC_PARTIAL): Remove redundant define. (HURD_PM_CONT_ALLOC_SQUASH): Likewise. (HURD_PM_CONT_ALLOC_EXTRA): Likewise. (HURD_PM_CONT_ALLOC_DMA): Likewise. (hurd_pm_container_share): Change ACCESSS from a hurd_pm_container_access_t * to a hurd_pm_container_t *. (hurd_pm_container_map): Rename parameter rights to flags. Add new parameter AMOUNT. Update callers. * physmem-user.c (container_ops): Remove redundant enumeration. (hurd_pm_container_create): Use hurd_pm_container_create_id as the RPC identifier. (hurd_pm_container_share): Use hurd_pm_container_share_id as the RPC identifier. (hurd_pm_container_allocate): Use hurd_pm_container_allocate_id as the RPC identifier. (hurd_pm_container_deallocate): Use hurd_pm_container_deallocate_id as the RPC identifier. (hurd_pm_container_map): Use hurd_pm_container_map_id as the RPC identifier. If AMOUNTP is non-NULL, return the number of bytes mapped in *AMOUNTP. Remove debugging code. (hurd_pm_container_copy): Use hurd_pm_container_copy_id as the RPC identifier. * anonymous.h: New file. * anonymous.c: New file. * as.c: New file. * core.c: New file. * frame.c: Remove file. * store.c: New file. * Makefile.am (libhurd_mm_a_SOURCES): Add as.c, store.c, memory.c, core.c, anonymous.c and anonymous.h. Remove frame.c. * headers.m4: Install anonymous.h as <hurd/anonymous.h>.
2005-03-092005-03-09 Neal H. Walfield <neal@gnu.org>neal
* map.c: Include "vm.h". (map_init): Cast HURD_STARTUP_ADDR to a uintptr_t. * pager.c (pager): Comment fix.
2005-01-11/neal
2005-01-11 Neal H. Walfield <neal@gnu.org> * libhurd-mm: New directory. * Makefile.am (SUBDIRS): Add libhurd-mm. * configure.ac: Add include for libhurd-mm/headers.m4. (AC_CONFIG_FILES): Add libhurd-mm/Makefile. deva/ 2005-01-11 Neal H. Walfield <neal@gnu.org> * Makefile.am (deva_SOURCES): Remove physmem-user.h and physmem-user.c. (deva_LDADD): Add ../libhurd-btree/libhurd-btree.a and ../libhurd-mm/libhurd-mm.a. * ia32-cmain.c: Include <hurd/mm.h>. (pager_tid): New global variable. (cmain): Allocate a thread that the memory management subsystem can use as the pager thread. Call hurd_mm_init. Set the PAGER_TID as the current thread's pager. * mmap.c: Rewrite to use new interfaces. * physmem-user.h: Remove obsolete file. * physmem-user.c: Likewise. libhurd-mm/ 2005-01-11 Neal H. Walfield <neal@gnu.org> * Makefile.am: Initial check in. * README: Likewise. * frame.c: Likewise. * headers.m4: Likewise. * map.c: Likewise. * mm-init.c: Likewise. * mm.h: Likewise. * pager.c: Likewise. * physmem-user.c: Likewise. * physmem-user.h: Likewise. * priv.h: Likewise. * vm.c: Likewise. * vm.h: Likewise. physmem/ 2005-01-11 Neal H. Walfield <neal@gnu.org> * Makefile.am (physmem_SOURCES): Add frame-entry.c and frame.c (physmem_LDADD): Add ../libhurd-btree/libhurd-btree.a. * frame-entry.c: New file. * frame.c: New file. * README: Rewrite. * container.c: Likewise. * physmem.h: Likewise. * physmem.c (create_bootstrap_caps): Change container_t to struct container *. task/ 2005-01-11 Neal H. Walfield <neal@gnu.org> * Makefile.am (task_SOURCES): Remove physmem-user.h and physmem-user.c. (task_LDADD): Add ../libhurd-btree/libhurd-btree.a and ../libhurd-mm/libhurd-mm.a. * ia32-cmain.c: Include <hurd/mm.h>. (pager_tid): New global variable. (cmain): Allocate a thread that the memory management subsystem can use as the pager thread. Call hurd_mm_init. Set the PAGER_TID as the current thread's pager. * mmap.c: Rewrite to use new interfaces. * physmem-user.h: Remove obsolete file. * physmem-user.c: Likewise. wortel/ 2005-01-11 Neal H. Walfield <neal@gnu.org> * startup.c (physmem_map): Rename . . . (allocate): . . . to this. Rewrite it. (map): New function. (cmain): Call map, not physmem_map. * wortel.c (setup_components): Allocate an extra thread for the task server. (start_elf): Update assert.