summaryrefslogtreecommitdiff
path: root/kern
AgeCommit message (Collapse)Author
2013-06-29(slab_info): fix format warningsMarin Ramesa
* kern/slab.c (slab_info): Fix format for vm_size_t.
2013-06-09Fix object construction in the slab allocatorRichard Braun
There is currently no actual use of constructors, which is why this bug has been long overlooked. * kern/slab.c (kmem_cpu_pool_fill): Call constructor on buffers unless verification is enabled for the cache, or the constructor is NULL.
2013-06-04Comment unused variableMarin Ramesa
* kern/ipc_mig.c (syscall_device_write_request): Comment unused variable.
2013-06-04Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumachSamuel Thibault
2013-06-02Remove unused variableMiguel Figueiredo
* kern/act.c (act_create): Remove unused variable.
2013-06-02Fix yet another locking error in the slab allocatorRichard Braun
* kern/slab.c (kmem_cache_free): Relock cache before retrying releasing an object to the CPU pool layer.
2013-05-19Remove unneeded variable initializationMiguel Figueiredo
* kern/thread.c (thread_force_terminate): Remove unneeded variable initialization.
2013-05-19Remove duplicate lineSamuel Thibault
Reported by Miguel Figueiredo * kern/thread.c (thread_create): Remove duplicate reset of new_thread->pc_sample.buffer to 0.
2013-05-16Reduce fragmentation in the slab allocatorRichard Braun
This reverts a change brought when reworking slab lists handling that made the allocator store slabs in LIFO order, whatever their reference count. While it's fine for free slabs, it actually increased fragmentation for partial slabs. * kern/slab.c (kmem_cache_alloc_from_slab): Insert slabs that become partial at the end of the partial slabs list.
2013-05-16Rename list_insert to list_insert_headRichard Braun
This change increases clarity. * kern/list.h (list_insert): Rename to ... (list_insert_head): ... this. * kern/slab.c: Update calls to list_insert.
2013-05-13Drop unused variablesMiguel Figueiredo
* kern/slab.c (kalloc_init): Remove unused variables.
2013-04-21Optimize slab reapingRichard Braun
Instead of walking the list of free slabs while holding the cache lock, detach the list from the cache and directly compute the final count values, and destroy slabs after releasing the cache lock. * kern/slab.c (kmem_cache_reap): Optimize.
2013-04-21Rework slab lists handlingRichard Braun
Don't enforce strong ordering of partial slabs. Separating partial slabs from free slabs is already effective against fragmentation, and sorting would sometimes cause pathological scalability issues. In addition, store new slabs (whether free or partial) in LIFO order for better cache usage. * kern/slab.c (kmem_cache_grow): Insert new slab at the head of the slabs list. (kmem_cache_alloc_from_slab): Likewise. In addition, don't sort partial slabs. (kmem_cache_free_to_slab): Likewise. * kern/slab.h: Remove comment about partial slabs sorting.
2013-04-21Fix locking error in the slab allocatorRichard Braun
* kern/slab.c (kmem_cache_free): Lock cache before releasing an object to the slab layer.
2013-03-11Update BASEPRI_USERSamuel Thibault
* kern/sched.h (BASEPRI_USER): Increase to 25.
2013-03-06Increase number of prioritiesSamuel Thibault
* kern/sched.h (NRQS): Increase to 50.
2013-03-05Do not hardcode maximum priority valueSamuel Thibault
* kern/sched_prim.c (do_priority_computation): Replace 31 with NRQS - 1. idle_thread: Likewise.
2013-01-22Add the mach_print debugging system callRichard Braun
The purpose of this system call is to help debugging in situations where it's desirable to bypass the mach_msg call entirely. * include/mach/syscall_sw.h (mach_print): Generate system call code. * kern/syscall_subr.c: Include <kern/printf.h>. [MACH_KDB] (mach_print): New function. * kern/syscall_subr.h (mach_print): New prototype. * kern/syscall_sw.c [MACH_KDB] (mach_trap_table): Declare mach_print system call.
2013-01-13Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumachSamuel Thibault
2013-01-13Add statistics for task_events_infoDavid Höppner
* ipc/ipc_mqueue.c (ipc_mqueue_send, ipc_mqueue_receive): Increment counters for message sent and received. * kern/ipc_kobject.c (ipc_kobject_server): Increment sent and received counters for the kernel task. * kern/task.c (task_create): Zero statistics. * kern/task.c (task_info): Add task_events_info call. * kern/task.h: Add statistics. * vm/vm_fault.c (vm_fault_page): Increment zero_fills, pageins, reactivations and cow_faults counters. * vm/vm_fault.c (vm_fault_wire_fast): Increment faults counters. * vm/vm_pageout.c (vm_pageout_scan): Increment reactivations counter.
2013-01-08Fix slab cache list lockingRichard Braun
This problem was overlooked because of simple locks being no-ops. * kern/slab.c (slab_collect): Fix lock name to kmem_cache_list_lock. (host_slab_info): Likewise.
2013-01-08Add function to dump a raw summary of the slab allocator stateRichard Braun
The purpose of this function is to allow kernel code to display the state of the slab caches in situations where the host_slab_info RPC wouldn't be available, e.g. before a panic. * kern/slab.c (slab_info): New function. * kern/slab.h: Add declaration for slab_info.
2012-12-23Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumachSamuel Thibault
2012-12-23Make thread_suspend wait for !TH_UNINTSamuel Thibault
0a55db5 made thread_suspend return KERN_FAILURE when the target thread is in TH_UNINT state. That however is not currently handled by libc, and it's more useful to just wait for the thread to get interruptible. * kern/sched_prim.c (thread_invoke): Wake NEW_THREAD->STATE for thread_suspend. * kern/thread.c (thread_suspend): Wait on NEW_THREAD->STATE as long as THREAD has TH_UNINT.
2012-12-05Fix kernel task creation timeRichard Braun
The mapable_time_init function is called before machine_init, but the latter sets the system boot time. Fix their calling order. * kern/startup.c (setup_main): Call machine_init before mapable_time_init.
2012-12-04Strongly reduce risks of name capture in rbtree macrosRichard Braun
* kern/rbtree.h (rbtree_lookup): Prefix local variable names with three underscores. (rbtree_lookup_nearest): Likewise. (rbtree_insert): Likewise. (rbtree_lookup_slot): Likewise. (rbtree_insert_slot): Rewrite as an inline function.
2012-09-23Fix gnumach_server_routine prototypeSamuel Thibault
* kern/ipc_kobject.c (ipc_kobject_server): Set gnumach_server_routine prototype to mig_routine_t.
2012-09-23Add missing file for page statisticsRichard Braun
* kern/gnumach.srv: New file.
2012-09-23Provide basic page cache statisticsRichard Braun
* Makefrag.am (EXTRA_DIST): Add kern/gnumach.srv. (include_mach_HEADERS): Add include/mach/gnumach.defs and include/mach/vm_cache_statistics.h (nodist_libkernel_a_SOURCES): Add kern/gnumach.server.defs.c, kern/gnumach.server.h, kern/gnumach.server.c, kern/gnumach.server.msgids, kern/gnumach.server.defs. * include/mach/mach_types.h: Add #include <mach/vm_cache_statistics.h>. * kern/ipc_kobject.c (ipc_kobject_server): Declare and call gnumach_server_routine. * vm/vm_object.c (vm_object_cached_pages): New variable. (vm_object_cached_pages_lock_data): Likewise. (vm_object_deallocate): Update number of cached pages. (vm_object_lookup): Likewise. (vm_object_lookup_name): Likewise. (vm_object_destroy): Likewise. (vm_object_enter): Likewise. * vm/vm_object.h (ref_count): Declare as int. (resident_page_count): Likewise. (vm_object_cached_count): Add extern declaration. (vm_object_cached_pages): Likewise. (vm_object_cached_pages_lock_data): Likewise. (vm_object_cached_pages_update): New macro. * vm/vm_resident.c (vm_page_insert): Assert resident page count doesn't overflow, update number of cached pages as appropriate. (vm_page_replace): Likewise. (vm_page_remove): Update number of cached pages as appropriate. * vm/vm_user.c: Add #include <mach/vm_cache_statistics.h>. (vm_cache_statistics): New function. * vm/vm_user.h: Add #include <mach/mach_types.h>. (vm_cache_statistics): New declaration. * include/mach/gnumach.defs: New file.
2012-07-08Fix slab collection timingRichard Braun
The slab garbage collector uses sched_tick as its time reference, which is increased every seconds, while the interval is expressed in clock ticks. Use the proper time reference instead. * kern/slab.c (kmem_gc_last_tick): Declare as unsigned long. (slab_collect): Use elapsed_ticks instead of sched_tick.
2012-07-07Increase the slab collection intervalRichard Braun
* kern/slab.c (KMEM_GC_INTERVAL): Increase to 5 seconds.
2012-07-07Allocate kernel thread stacks out of kmem_mapRichard Braun
The kernel submaps eat most of the available kernel space. Using the main kernel map for thread stacks sometimes lead to exhaustion when many threads are created. Use kmem_map instead to increase this limit. * kern/thread.c (stack_alloc): Use kmem_map instead of kernel_map for stack allocation. (stack_collect): Likewise for release.
2012-07-07Merge kalloc_map into kmem_mapRichard Braun
* ipc/ipc_table.c: Add #include <kern/slab.h>. (ipc_table_alloc): Use kmem_map instead of kalloc_map when allocating a table. (ipc_table_realloc): Likewise for reallocation. (ipc_table_free): Likewise for release. * kern/kalloc.h (kalloc_map): Remove declaration. * kern/slab.c (KMEM_MAP_SIZE): Increase to 128 MiB. (KALLOC_MAP_SIZE): Remove macro. (kalloc_map_store): Remove variable. (kalloc_map): Likewise. (kalloc_pagealloc): Use kmem_map instead of kalloc_map for general purpose allocations. (kalloc_pagefree): Likewise. (kalloc_init): Remove the creation of kalloc_map.
2012-04-22Update comments.Richard Braun
Literature about red-black trees vary concerning the cases numbering, and the implementation doesn't make all of them clearly appear. Remove cases numbering references to avoid confusion.
2012-04-22Fix copyright assignmentRichard Braun
Maksym and I have assigned copyright to the Free Software Foundation. In addition, restore the original upstream copyrights for correctness. * kern/list.h: Fix copyright assignment. * kern/rbtree.c: Likewise. * kern/rbtree.h: Likewise. * kern/rbtree_i.h: Likewise. * kern/slab.c: Likewise. * kern/slab.h: Likewise.
2012-04-06Fix integer typeSamuel Thibault
* kern/thread.c (host_stack_usage): Set `total' type to natural_t.
2012-04-06Do not take address of va_list variableSamuel Thibault
This breaks on x86_64, where it is an array and thus gets bogus results. * ddb/db_output.c (db_printf, kdbprintf): Pass copy of va_list variable instead of its address. * kern/debug.c (panic, log): Likewise. * kern/printf.c (vprintf, iprintf, sprintf, vsnprintf): Likewise. (_doprnt): Take va_list instead of va_list *, fix usage and comment accordingly. * kern/printf.h (_doprnt): Take va_list instead of va_list *.
2012-03-20Use long typesSamuel Thibault
* ddb/db_examine.c (db_xcdump): Do not cast addr before passing to db_read_bytes. * ddb/db_macro.c (db_arg_variable): Return long. * ddb/db_macro.h (db_arg_variable): Likewise. * ddb/db_sym.c (db_maxoff): Set type to unsigned long. * ddb/db_task_thread.c (db_set_default_thread, db_get_task_thread): Return long. * ddb/db_variables.h (db_variable): Make fcn function field to return long. (FCN_NULL): Make function type return long. * i386/i386/db_interface.c (int_regs): Set field sizes to long. * i386/i386/db_machdep.h (db_expr_t): Set type to long. * i386/i386/db_trace.c (db_i386_reg_value): Return long. Use long types. (i386_frame, i386_kregs, interrupt_frame, db_nextframe): Set field sizes to long. (db_regs, i386_kregs): Use long * pointers. (db_lookup_i386_kreg): Return long *. (db_numargs, db_nextframe, db_stack_trace_cmd, db_i386_stack_trace): Use long types. * i386/i386/debug_i386.c (dump_ss): Fix format. * i386/i386/ktss.c (ktss_init): Use long type. * i386/i386/pcb.c (set_user_regs): Likewise. * i386/i386/thread.h (i386_saved_state, v86_segs, i386_kernel_state, i386_interrupt_state): Set field sizes to long. * i386/i386/trap.c (kernel_trap, user_trap): Fix formats. * kern/ast.h (ast_t): Set type to long. * kern/boot_script.c (create_task, resume_task, prompt_resume_task, boot_script_set_variable): Use long types. * kern/boot_script.h (boot_script_set_variable): Use long type. * kern/bootstrap.c (bootstrap_create): Pass long type. * kern/lock.c (simple_lock, simple_lock_try): Use long type. * linux/dev/kernel/softirq.c (linux_soft_intr): Fix format.
2012-03-20Use compiler defined __i386__ symbol instead of use defined i386Guillem Jover
* i386/configfrag.ac (i386): Remove definition. * i386/intel/pmap.c (pmap_update_interrupt): Rename i386 to __i386__. * i386/intel/pmap.h: Likewise. * kern/debug.c (Debugger): Likewise. * kern/lock.c (simple_lock, simple_lock_try, db_show_all_slocks): Likewise.
2012-03-09Use unsigned long for addresses and sizesSamuel Thibault
TODO: remonter formats * i386/include/mach/i386/vm_types.h (vm_offset_t): Define to unsigned long. (signed32_t): Define to signed int. (unsigned32_t): Define to unsigned int. * i386/include/mach/sa/stdarg.h (__va_size): Use sizeof(unsigned long)-1 instead of 3. * include/mach/port.h (mach_port_t): Define to vm_offset_t instead of natural_t. * include/sys/types.h (size_t): Define to unsigned long instead of natural_t. * linux/src/include/asm-i386/posix_types.h (__kernel_size_t): Define to unsigned long. (__kernel_ssize_t): Define to long. * linux/src/include/linux/stddef.h (size_t): Define to unsigned long. * device/dev_pager.c (dev_pager_hash): Cast port to vm_offset_t insted of natural_t. (device_pager_data_request): Fix format. * device/ds_routines.c (ds_no_senders): Fix format. * i386/i386/io_map.c (io_map): Likewise. * i386/i386at/autoconf.c (take_dev_irq): Likewise. * i386/i386at/com.c (comattach): Likewise. * i386/i386at/lpr.c (lprattach): Likewise. * i386/i386at/model_dep.c (mem_size_init, mem_size_init, c_boot_entry): Likewise. * i386/intel/pmap.c (pmap_enter): Likewise. * ipc/ipc_notify.c (ipc_notify_port_deleted, ipc_notify_msg_accepted, ipc_notify_dead_name): Likewise. * ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Likewise. * kern/ipc_kobject.c (ipc_kobject_destroy): Likewise. * kern/slab.c (kalloc_init): Likewise. * vm/vm_fault.c (vm_fault_page): Likewise. * vm/vm_map.c (vm_map_pmap_enter): Likewise. * xen/block.c (device_read): Likewise. * device/net_io.c (bpf_match): Take unsigned long * instead of unsigned int *. (bpf_do_filter): Make mem unsigned long instead of long. * i386/i386/ktss.c (ktss_init): Cast pointer to unsigned long instead of unsigned. * i386/i386/pcb.c (stack_attach, switch_ktss): Cast pointers to long instead of int. * i386/i386/trap.c (dump_ss): Likewise. * ipc/ipc_hash.c (IH_LOCAL_HASH): Cast object to vm_offset_t. * ipc/mach_msg.c (mach_msg_receive, mach_msg_receive_continue): Cast kmsg to vm_offset_t instead of natural_t. * kern/pc_sample.c (take_pc_sample): Cast to vm_offset_t instead of natural_t. * kern/boot_script.c (sym, arg): Set type of `val' field to long instead of int. (create_task, builtin_symbols, boot_script_parse_line, boot_script_define_function): Cast to long instead of int. * kern/bootstrap.c (bootstrap_create): Likewise. * kern/sched_prim.c (decl_simple_lock_data): Likewise. * kern/printf.c (vsnprintf): Set size type to size_t. * kern/printf.h (vsnprintf): Likewise. * vm/vm_map.h (kentry_data_size): Fix type to vm_size_t. * vm/vm_object.c (vm_object_pmap_protect_by_page): Fix size parameter type to vm_size_t.
2012-01-28Merge branch 'master' into master-slabSamuel Thibault
2012-01-22Fix build on 64bit hostSamuel Thibault
When stealing the memset function from the 32bit host libc on a 64bit host system, glibc tends to bring unwanted references to _Unwind_Resume, __gcc_personality_v0, etc. So let's stop stealing memset. * kern/strings.c (memset): New function. * Makefile.am (clib_routines): Remove memset.
2011-12-29Upgrade number of event queuesSamuel Thibault
* kern/sched_prim.c (NUMQUEUES): Increase to 1031
2011-12-17Remove arbitrary limits used by the zone systemRichard Braun
The zone allocator could limit the size of its zones to an arbitrary value set at zinit() time. There is no such parameter with the slab module. As a result of removing those limits, the kern/mach_param.h header becomes empty, and is simply removed altogether. * Makefrag.am (libkernel_a_SOURCES): Remove kern/mach_param.h. * i386/i386/fpu.c: Remove #include <kern/mach_param.h>. * i386/i386/machine_task.c: Likewise. * i386/i386/pcb.c: Likewise. * ipc/ipc_init.c: Likewise. (ipc_space_max): Remove variable. (ipc_tree_entry_max): Likewise. (ipc_port_max): Likewise. (ipc_pset_max): Likewise. * ipc/ipc_init.h (IPC_ZONE_TYPE): Remove macro. (ipc_space_max): Remove extern declaration. (ipc_tree_entry_max): Likewise. (ipc_port_max): Likewise. (ipc_pset_max): Likewise. * ipc/ipc_hash.c (ipc_hash_init): Don't use ipc_tree_entry_max to compute ipc_hash_global_size. * ipc/ipc_marequest.c: Remove #include <kern/mach_param.h>. (ipc_marequest_max): Remove variable. (ipc_marequest_init): Don't use ipc_marequest_max to compute ipc_marequest_size. (ipc_marequest_info): Return (unsigned int)-1 in maxp. * kern/act.c: Remove #include <kern/mach_param.h>. * kern/mach_clock.c: Likewise. * kern/priority.c: Likewise. * kern/task.c: Likewise. * kern/thread.c: Likewise. * vm/memory_object_proxy.c: Likewise. * vm/vm_fault.c: Likewise.
2011-12-17Remove the defunct kernel_task_create() functionRichard Braun
The kmem_suballoc() function, which has been replaced with kmem_submap(), is called by kernel_task_create(). Rather than update it, remove this now unused function. * kern/task.c (kernel_task_create): Remove function. * kern/task.h (kernel_task_create): Remove prototype.
2011-12-17Fix kern/kalloc.h includesRichard Braun
* device/dev_pager.c: Remove #include <kern/kalloc.h>. * i386/i386/io_perm.c: Add #include <kern/kalloc.h>. * kern/bootstrap.c: Likewise. * kern/ipc_tt.c: Likewise. * kern/pc_sample.c: Likewise. * kern/processor.c: Likewise. * kern/server_loop.ch: Likewise. * kern/thread.c: Likewise. * linux/dev/glue/block.c: Likewise. * linux/dev/glue/net.c: Likewise. * vm/vm_map.c: Likewise. * xen/block.c: Likewise. * xen/net.c: Likewise. * xen/store.c: Likewise.
2011-12-17Adjust the kernel to use the slab allocatorRichard Braun
* device/dev_lookup.c: Replace zalloc header, types and function calls with their slab counterparts. * device/dev_pager.c: Likewise. * device/ds_routines.c: Likewise. * device/io_req.h: Likewise. * device/net_io.c: Likewise. * i386/i386/fpu.c: Likewise. * i386/i386/io_perm.c: Likewise. * i386/i386/machine_task.c: Likewise. * i386/i386/pcb.c: Likewise. * i386/i386/task.h: Likewise. * i386/intel/pmap.c: Likewise. * i386/intel/pmap.h: Remove #include <kernel/zalloc.h>. * include/mach_debug/mach_debug.defs (host_zone_info): Replace routine declaration with skip directive. (host_slab_info): New routine declaration. * include/mach_debug/mach_debug_types.defs (zone_name_t) (zone_name_array_t, zone_info_t, zone_info_array_t): Remove types. (cache_info_t, cache_info_array_t): New types. * include/mach_debug/mach_debug_types.h: Replace #include <mach_debug/zone_info.h> with <mach_debug/slab_info.h>. * ipc/ipc_entry.c: Replace zalloc header, types and function calls with their slab counterparts. * ipc/ipc_entry.h: Likewise. * ipc/ipc_init.c: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_object.c: Likewise. * ipc/ipc_object.h: Likewise. * ipc/ipc_space.c: Likewise. * ipc/ipc_space.h: Likewise. * ipc/ipc_table.c (kalloc_map): Remove extern declaration. * kern/act.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/kalloc.h: Add #include <vm/vm_types.h>. (MINSIZE): Remove definition. (kalloc_map): Add extern declaration. (kget): Remove prototype. * kern/mach_clock.c: Adjust comment. * kern/processor.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/startup.c: Remove #include <kernel/zalloc.h>. * kern/task.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/thread.c: Likewise. * vm/memory_object_proxy.c: Likewise. * vm/vm_external.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_init.c: Likewise. * vm/vm_map.c: Likewise. * vm/vm_object.c: Likewise. * vm/vm_page.h: Remove #include <kernel/zalloc.h>. * vm/vm_pageout.c: Replace zalloc header, types and function calls with their slab counterparts. * vm/vm_resident.c: Likewise. (zdata, zdata_size): Remove declarations. (vm_page_bootstrap): Don't steal memory for the zone system.
2011-12-17Import the slab allocatorRichard Braun
As it is intended to completely replace the zone allocator, remove it on the way. So long to the venerable code ! * Makefrag.am (libkernel_a_SOURCES): Add kern/slab.{c,h}, remove kern/kalloc.c and kern/zalloc.{c,h}. * configfrag.ac (SLAB_VERIFY, SLAB_USE_CPU_POOLS): Add defines. * i386/Makefrag.am (libkernel_a_SOURCES): Remove i386/i386/zalloc.h. * i386/configfrag.ac (CPU_L1_SHIFT): Remove define. * include/mach_debug/slab_info.h: New file. * kern/slab.c: Likewise. * kern/slab.h: Likewise. * i386/i386/zalloc.h: Remove file. * include/mach_debug/zone_info.h: Likewise. * kern/kalloc.c: Likewise. * kern/zalloc.c: Likewise. * kern/zalloc.h: Likewise.
2011-12-17Import utility filesRichard Braun
* Makefrag.am (libkernel_a_SOURCES): Add kern/list.h, kern/rbtree.c, kern/rbtree.h and kern/rbtree_i.h. * kern/list.h: New file. * kern/rbtree.c: Likewise. * kern/rbtree.h: Likewise. * kern/rbtree_i.h: Likewise. * kern/macro_help.h (MACRO_BEGIN): Use GNU C compound statement enclosed in parentheses. (MACRO_END): Likewise.
2011-09-28Make thread_suspend honor the TH_UNINT flagSergio López
Interrupting a thread without a continuation, puts it in a inconsistent state. This is the cause for the bug described in https://lists.gnu.org/archive/html/bug-hurd/2011-09/msg00148.html * kern/thread.c (thread_suspend): Fail with KERN_FAILURE if thread is uninterruptible.