summaryrefslogtreecommitdiff
path: root/kern
AgeCommit message (Collapse)Author
2015-09-14XXX pmm from x15, userspace crashes soonJustus Winter
2015-09-14xxx avoid allocaJustus Winter
2015-09-14kern/slab: directmap updateRichard Braun
The main impact of the direct physical mapping on the kmem module is the slab size computation. The page allocator requires the allocation size to be a power-of-two above the page size since it uses the buddy memory allocation algorithm. Custom slab allocation functions are no longer needed since the only user was the kentry area, which has been removed recently. The KMEM_CACHE_NOCPUPOOL flag is also no longer needed since CPU pools, which are allocated from a kmem cache, can now always be allocated out of the direct physical mapping.
2015-09-14kern/slab: rename constructor typeRichard Braun
2015-09-14kern/slab: move internal data to slab_i.hRichard Braun
As it's done for other modules, this separation makes the public interface easy to identify.
2015-09-14kern/slab: rework buffer-to-slab lookupRichard Braun
Instead of using a red-black tree, rely on the VM system to store kmem specific private data.
2015-09-14kern/slab: remove the KMEM_CACHE_NORECLAIM flagRichard Braun
Don't encourage anyone to use non reclaimable pools of resources, it's a Bad Thing To Do.
2015-09-14kern: remove the list of free stacksJustus Winter
* kern/counters.c: Remove relevant counters. * kern/counters.h: Likewise. * kern/thread.c (stack_free_{list,count,limit}): Drop variables. (stack_next): Remove macro. (stack_alloc_try): Allocate stack using the slab allocator. (stack_alloc): Merely call `stack_alloc_try'. (stack_free): Adopt accordingly.
2015-09-14kern: allocate kernel stacks using the slab allocatorJustus Winter
* kern/slab.c (kmem_cache_init): Relax alignment restriction. * kern/thread.c (stack_cache): New variable. (stack_alloc): Use the slab allocator. (stack_collect): Adjust accordingly. (thread_init): Initialize `stack_cache'.
2015-09-14codify locking contractsJustus Winter
Conflicts: vm/vm_page.h
2015-09-14kern: provide a way to steal a lockJustus Winter
During the message transport, the sender acquires a lock that is released by the sender. By making this explicit, we can provide stronger guarantees about the locking. * ipc/ipc_mqueue.c (ipc_mqueue_receive): Steal lock. * ipc/ipc_object.h (io_lock_steal): New macro. * ipc/ipc_port.h (ip_lock_steal): Likewise. * ipc/mach_msg.c (mach_msg_trap): Steal lock in the inlined version of `ipc_mqueue_receive'. * kern/lock.c (lock_done): Assert that the current thread holds the lock. * kern/lock.h (lock_write_steal): New macro.
2015-09-14kern: use a general lock for the IPC structuresJustus Winter
* ipc/ipc_thread.h (ith_{lock_init,lock,unlock}): Use a general lock. * kern/task.h (struct task): Use a general lock for `itk_lock_data'. (itk_{lock_init,lock,unlock}): Use a general lock. * kern/thread.h (struct thread): Use a general lock for `ith_lock_data'.
2015-09-14kern/lock: add lock_takenJustus Winter
* kern/lock.h (lock_taken): New macro.
2015-09-14turn all_psets_lock into a general lockJustus Winter
2015-09-14yyy more general locks, crashes, maybe b/c interrupt handlerJustus Winter
2015-09-14kern: new function `thread_sleep_lock'Justus Winter
* kern/sched_prim.c (thread_sleep_lock): New function. * kern/sched_prim.h (thread_sleep_lock): New delcaration.
2015-09-07kern: use proper memory fences when handling the mapped timeJustus Winter
* include/mach/time_value.h (struct mapped_time_value): Adjust comment. * kern/mach_clock.c (mtime): Likewise. Also make it volatile. (update_mapped_time): Use full hardware barriers. (read_mapped_time): New macro with proper fences. (record_time_stamp, host_get_time): Use the new macro.
2015-09-07kern: fix loop reading the time valueJustus Winter
Previously, recent versions of gcc would hoist the loads out of the loop reading the time value. * kern/macros.h (access_once): New macro. * kern/mach_clock.c (host_get_time): Use the new macro to prevent the loads from being hoisted out of the loop.
2015-08-28Make sure the reply port's reference is released when the thread needs to be ↵Flávio Cruz
halted. * kern/thread.h (thread_halt_self): Add continuation_t parameter. * kern/thread.c (thread_halt_self): Pass continuation_t parameter to thread_block instead of thread_exception_return. * kern/ast.c (ast_taken): Pass thread_exception_return to thread_halt_self. * kern/profile.c (profile_thread): Likewise. * kern/exception.c (exception_no_server): Likewise. (thread_release_and_exception_return): New function. (exception_raise_continue_slow): Pass thread_release_and_exception_return to thread_halt_self.
2015-08-28Add a thread_no_continuation definitionFlávio Cruz
to replace the use of the NULL pointer. * kern/sched_prim.h (thread_no_continuation): New macro. * kern/machine.c (processor_assign, processor_doaction): Use thread_no_continuation instead of 0. * kern/profile.c (send_last_sample_buf): Likewise * kern/sched_prim.c (thread_sleep, thread_invoke, thread_dispatch): Likewise. * kern/task.c (task_terminate, task_assign): Likewise. * kern/thread.c (thread_suspend): Likewise. * kern/thread.h (struct thread): Change type of swap_func field to continuation_t.
2015-08-20kern/bootstrap: tune lockingJustus Winter
* kern/bootstrap.c (boot_script_exec_cmd): Avoid holding the lock across the call to `thread_create'.
2015-08-20kern: really zero-out unused simple lock info entriesJustus Winter
* kern/lock.c (simple_unlock): Really zero-out unused simple lock info entries.
2015-08-17kern: keep track of the writer when debugging locksJustus Winter
* configfrag.ac (MACH_LDEBUG): Adjust comment, we use it to sanity check all locks now. * kern/lock.c (lock_write): Keep track of the writer thread. (lock_done): Clear writer. (lock_read_to_write): Keep track of the writer thread. (lock_write_to_read): Assert that the current thread holds the lock. Clear writer. (lock_try_write): Keep track of the writer thread. (lock_try_read_to_write): Likewise. (lock_set_recursive): Assert that the current thread holds the lock. * kern/lock.h (struct lock): New field `writer'. (have_read_lock, have_write_lock, have_lock): New macros that can be used to assert that the current thread holds the given lock. If MACH_LDEBUG is not set, they evaluate to true.
2015-08-17kern: improve simple lock debuggingJustus Winter
Do not bother saving the return address when acquire a simple lock. Save the location as provided by the compiler as string instead. Also save the lock parameter. * kern/lock.c (struct simple_locks_info): Drop `ra', add `expr', `loc'. (simple_lock): Rename to `_simple_lock', add expression and location parameters and save them. (simple_lock_try): Likewise. (simple_unlock): Zero-out the now unused slot in the list of taken locks. (db_show_all_slocks): Use the new information. * kern/lock.h (simple_lock, simple_lock_try): Provide macro versions passing the location and expression as string.
2015-08-17kern: disable the simple lock checks while debuggingJustus Winter
* kern/lock.c (do_check_simple_locks): New variable. (check_simple_locks): Make check conditional. (check_simple_locks_{en,dis}able): New functions. * kern/lock.h (check_simple_locks_{en,dis}able): New declarations. * ddb/db_trap.c (db_task_trap): Disable simple lock checks.
2015-08-15Avoid re-defining macrosJustus Winter
* kern/macros.h: Avoid re-defining macros. * linux/src/include/linux/compiler-gcc.h: Likewise. * linux/src/include/linux/compiler.h: Likewise.
2015-07-25kern: add boot-time clock, use it for time stampsHEADmasterJustus Winter
The kernel keeps track of task and thread creation times by saving a time stamp. Previously, the real-time clock was used for this. When the real-time clock is changed, however, the reference frame for the time stamps is lost. This surfaced in Hurd systems reporting spuriously long uptimes. Fix this by creating a boot-time clock and use it as reference frame for the time stamps. * kern/mach_clock.c (clock_boottime_offset): Create clock by keeping track of the offset from the real-time. (clock_boottime_update): New function. (record_time_stamp): Use the boot-time clock for time stamps. (read_time_stamp): New function to convert it back to real-time. (host_set_time): Call `clock_boottime_update'. * kern/mach_clock.h (record_time_stamp): Amend comment. (read_time_stamp): New declaration. * kern/task.c (task_info): Use `read_time_stamp'. * kern/thread.c (thread_info): Likewise.
2015-07-25kern/lock: make sure the macros are only used on simple locksJustus Winter
* kern/lock.h (struct slock, simple_lock_data_empty): Add field `is_a_simple_lock'. (simple_lock_assert): New macro that tests for `is_a_simple_lock'. Use this macro to assert that the arguments to various other macros are indeed simple locks.
2015-07-20kern/bootstrap: deallocate threadJustus Winter
Previously, killing the thread would fail because of the extra reference, making task_terminate loop forever. * kern/bootstrap.c (boot_script_exec_command): Deallocate thread.
2015-07-19kern/bootstrap: deallocate taskJustus Winter
* kern/bootstrap.c (boot_script_free_task): Deallocate task.
2015-07-18kern/printf: do not serialize printf and coJustus Winter
A lot of code assumes that printf is re-entrant, e.g. the pagination code in the debugger, or any use of assert inside the console driver. * kern/printf.c: Drop the lock serializing calls to `_doprnt'. (printf_init): Remove function. * kern/printf.h (printf_init): Remove declaration. * kern/startup.c (setup_main): Remove call to `printf_init'.
2015-07-18kern/lock: use compiler built-in functions to get return addressJustus Winter
* kern/lock.c (struct simple_locks_info): Fix type of `ra'. (simple_lock, simple_lock_try): Use compiler built-in functions to get return address.
2015-07-18kern/bootstrap: fix lockingJustus Winter
* kern/bootstrap.c (boot_script_exec_cmd): Add missing unlock. (user_bootstrap): Likewise.
2015-07-18kern/slab: fix lockingJustus Winter
* kern/slab.c (host_slab_info): Fix locking.
2015-07-11kern: make sure the queue macros are only used on queuesJustus Winter
This turns mistakes as the one corrected in e59f05e9 into compile-time errors. * kern/queue.h: Add a new macro, queue_assert, and use it to assert that all arguments given to the queue macros have the correct type. * device/net_io.c (ENQUEUE_DEAD): Adapt to the fact that `queue_next(q)' is no longer an lvalue.
2015-07-10kern: make printf handle long long integersJustus Winter
* Makefile.am (clib_routines): Steal `__umoddi3'. * kern/printf.c (MAXBUF): Increase size. (printnum, _doprnt): Handle long long integers. * kern/printf.h (printnum): Adjust declaration.
2015-07-09kern: remove superfluous fileJustus Winter
* kern/server_loop.ch: Remove superfluous file.
2015-07-09kern: improve error handlingJustus Winter
* kern/bootstrap.c (boot_script_exec_cmd): Improve error handling.
2015-06-20kern: fix error handlingJustus Winter
This avoids calling `thread_deallocate' with an uninitialized value, as found by the Clang Static Analyzer. * kern/thread.c (kernel_thread): Fix error handling.
2015-06-09kern: add function attributes to the printf-functionsJustus Winter
* kern/printf.h (sprintf, snprintf, vsnprintf, printf): Add the `printf' function attribute that allows the compiler to check the format strings and arguments.
2015-05-29kern: fix argument handlingJustus Winter
Previously, the processor argument was not checked. If called with a non-processor argument (like a task), `processor' is set to NULL, triggering a page fault. Likewise for the other functions. * kern/processor.c (processor_get_assignment): Fix argument handling. * kern/task.c (task_get_assignment): Likewise. * kern/thread.c (thread_get_assignment): Likewise.
2015-05-23kern: avoid breaking the strict-aliasing rulesJustus Winter
* kern/exception.c (exception_parse_reply): Use `BAD_TYPECHECK'.
2015-05-22ipc: drop size parameter from `ipc_space_create'Justus Winter
* ipc/ipc_space.c (ipc_space_create): Drop size parameter. * ipc/ipc_space.h (ipc_space_create): Adopt declaration, fix comment. * kern/ipc_tt.c (ipc_task_init): Adopt accordingly.
2015-05-20ipc: undo manual inlining of `ipc_entry_X' functionsJustus Winter
Today we can rely on the compiler to inline functions. Undoing this manual optimization is a first step to replace the IPC tables. * ipc/mach_msg.c (mach_msg_trap): Undo the manual inlining of `ipc_entry_lookup', `ipc_entry_dealloc', and `ipc_entry_get'. * ipc/ipc_kmsg.c (ipc_kmsg_copyin_header, ipc_kmsg_copyout_header): Likewise. * kern/exception.c (exception_raise): Likewise. * kern/ipc_mig.c (fast_send_right_lookup): Likewise.
2015-05-20kern: add radix tree libraryJustus Winter
Import a radix tree library from Richard Braun's librbraun. * Makefile.am (clib_routines): Steal `__ffsdi2'. * Makefrag.am (libkernel_a_SOURCES): Add new files. * kern/rdxtree.c: New file. * kern/rdxtree.h: Likewise. * kern/rdxtree_i.h: Likewise. * kern/startup.c (setup_main): Initialize radix tree library.
2015-05-20kern: gracefully handle resource shortageJustus Winter
* kern/thread.c (stack_alloc): Report resource shortage. * kern/sched_prim.h (stack_alloc): Adjust declaration accordingly. * kern/thread_swap.c (thread_doswapin): Report resource shortage. (swapin_thread_continue): If the swap-in fails, put the thread back on the queue and go back to sleep. * kern/thread_swap.h (thread_doswapin): Adjust declaration accordingly.
2015-05-20kern: gracefully handle resource shortageJustus Winter
* kern/task.c (task_create): Gracefully handle resource shortage.
2015-05-19kern: import `macros.h' from x15Justus Winter
Import the macro definitions from the x15 kernel project, and replace all similar definitions littered all over the place with it. Importing this file will make importing code from the x15 kernel easier. We are already using the red-black tree implementation and the slab allocator from it, and we will import even more code in the near future. * kern/list.h: Do not define `structof', include `macros.h' instead. * kern/rbtree.h: Likewise. * kern/slab.c: Do not define `ARRAY_SIZE', include `macros.h' instead. * i386/grub/misc.h: Likewise. * i386/i386/xen.h: Do not define `barrier', include `macros.h' instead. * kern/macro_help.h: Delete file. Replaced by `macros.h'. * kern/macros.h: New file. * Makefrag.am (libkernel_a_SOURCES): Add new file, remove old file. * device/dev_master.h: Adopt accordingly. * device/io_req.h: Likewise. * device/net_io.h: Likewise. * i386/intel/read_fault.c: Likewise. * ipc/ipc_kmsg.h: Likewise. * ipc/ipc_mqueue.h: Likewise. * ipc/ipc_object.h: Likewise. * ipc/ipc_port.h: Likewise. * ipc/ipc_space.h: Likewise. * ipc/ipc_splay.c: Likewise. * ipc/ipc_splay.h: Likewise. * kern/assert.h: Likewise. * kern/ast.h: Likewise. * kern/pc_sample.h: Likewise. * kern/refcount.h: Likewise. * kern/sched.h: Likewise. * kern/sched_prim.c: Likewise. * kern/timer.c: Likewise. * kern/timer.h: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_map.h: Likewise. * vm/vm_object.h: Likewise. * vm/vm_page.h: Likewise.
2015-05-02kern: fix commentJustus Winter
* kern/rbtree.h: Fix comment.
2015-04-24kern: avoid hardcoding the lowest priorityJustus Winter
The number of priorities has been changed from 32 to 50 in 6a234201081156e6d5742e7eeabb68418b518fad. * kern/syscall_subr.c (thread_depress_priority): Avoid hardcoding the lowest priority.