summaryrefslogtreecommitdiff
path: root/kern
AgeCommit message (Collapse)Author
2015-02-25kern: inherit the name of the parent taskJustus Winter
* kern/task.c (task_create): Inherit the name of the parent task.
2015-02-20kern: improve assertJustus Winter
Use the ternary operator to implement `assert' like it is done in the glibc. The glibcs changelog does not mention the rationale behind this change, but doing the same seems to improve our IPC performance. * kern/assert.h (assert): Define macro using the ternary operator.
2015-02-20kern: reduce the size of `struct thread'Justus Winter
Reduce the size of `struct thread' by twelve bytes making it fit into exactly five cache lines (on 32-bit platforms). * kern/thread.h (struct thread): Group the state and all flags in a bitfield. (TH_EV_WAKE_ACTIVE, TH_EV_STATE): Provide macros that generate keys for synchronization primitives like `thread_wakeup'. * kern/thread.c (thread_halt, thread_dowait, thread_suspend): Use the new keys instead of addresses of fields for the synchronisation. * kern/ipc_sched.c (thread_handoff): Likewise. * kern/sched_prim.c (thread_invoke, thread_dispatch): Likewise.
2015-02-18kern: avoid #if 0ing out thread_collect_scanJustus Winter
Currently, `thread_collect_scan' does nothing because `pcb_collect' is a nop. Its body is exempt from compilation by means of the preprocessor. This is unfortunate as it increases the risk of bitrot, and we still need to pay the price of rate-limiting thread_collect_scan. * kern/thread.c (thread_collect_scan): Drop #if 0 around the body. * vm/vm_pageout.c (vm_pageout_scan): Do not call `consider_thread_collect' and document why.
2015-01-02kern: Fix typos in comments (found by codespell)Stefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2014-12-16kern: gracefully handle bogus sample pc sequence numberJustus Winter
If a sequence number larger than the sample control sequence number is supplied, `nsamples' becomes negative. Handle this gracefully. * kern/pc_sample.c (get_sampled_pcs): Handle bogus sequence number.
2014-12-09kern: provide notifications about new tasksJustus Winter
These notifications are sent to the port registered via `register_new_task_notification' and provide a robust parental relation between tasks to a userspace server. * Makefrag.am: Add task_notify.defs. * include/mach/gnumach.defs: Add register_new_task_notification. * include/mach/task_notify.defs: New file. * kern/task.c (new_task_notification): New variable. (task_create): Send new task notifications. (register_new_task_notification): Add server function. * kern/task_notify.cli: New file.
2014-12-07Fix pthread_create warning on translator terminationSamuel Thibault
This was due to task_terminate not actually properly suspending threads before disable the task port, which was thus preventing pthread_create from being able to create a stack. Thanks Gabriele Giacone for finding out a reproducer of this. * kern/task.h (task_hold_locked): New declaration. * kern/task.c (task_hold): Move the locked part of the code into... (task_hold_locked): ... new function. (task_terminate): Call task_hold_locked just before deactivating the task. Call ipc_task_disable after waiting for threads to actually suspend with task_dowait.
2014-12-01kern: disable all counters by defaultJustus Winter
Make all five non-conditional counters conditional ones. Casual checking revealed that the hits-to-miss ratio is excellent. * kern/counters.c: Make all counters conditional. * kern/counters.h: Likewise. * kern/ipc_sched.c: Likewise. * kern/sched_prim.c: Likewise.
2014-09-30kern: silence compiler warning about uninitialized variableJustus Winter
* kern/slab.c (kmem_cache_compute_sizes): Initialize optimal_size and assert that a size is selected.
2014-09-30kern: fix type of recompute_prioritiesJustus Winter
* kern/sched_prim.c (recompute_priorities): Fix type. * kern/sched_prim.h (recompute_priorities): Likewise.
2014-09-26kern: create send rights as they are inserted at bootstrap timeJustus Winter
Previously, it was impossible to hand e.g. the master device port to more than one bootstrap task. Fix this by creating the send right as it is inserted into the target task. * kern/bootstrap.c (bootstrap_create): Do not create the send rights here... (boot_script_insert_right): ... but here.
2014-06-11kern: set the name of the kernel task to 'gnumach'Justus Winter
* kern/taks.c (task_init): Set the name of the kernel task to 'gnumach'.
2014-05-25Rewrite old-style #endif FOO directivesJustus Winter
* i386/include/mach/i386/cthreads.h: Rewrite old-style #endif FOO directives. * include/device/tape_status.h: Likewise. * include/mach/alert.h: Likewise. * include/mach/boot.h: Likewise. * include/mach/default_pager_types.defs: Likewise. * include/mach/default_pager_types.h: Likewise. * include/mach/multiboot.h: Likewise. * include/mach/notify.defs: Likewise. * include/mach_debug/pc_info.h: Likewise. * kern/act.h: Likewise. * kern/refcount.h: Likewise. * kern/shuttle.h: Likewise.
2014-04-30kern: include the MIG-generated server headers for MACHINE_SERVERJustus Winter
GNU MIG recently gained support for emitting x_server_routine declarations in the generated server header file. Using this declaration, the x_server_routine functions can be inlined into the ipc_kobject_server function. * kern/ipc_kobject.c: Include the MIG-generated server headers for the machine-dependent interfaces. (ipc_kobject_server): Drop the simple declaration of MACHINE_SERVER_ROUTINE. * i386/i386/machine_routines.h (MACHINE_SERVER_HEADER): New definition.
2014-04-13kern: set the name of tasks created during the bootstrapJustus Winter
* kern/bootstrap.c (boot_script_task_create): Set the name of newly created tasks.
2014-04-04Convert from K&R to ANSIMarin Ramesa
Convert from K&R style function definitions to ANSI style function definitions. * ddb/db_access.c: Convert function prototypes from K&R to ANSI. * ddb/db_aout.c: Likewise. * ddb/db_break.c: Likewise. * ddb/db_command.c: Likewise. * ddb/db_cond.c: Likewise. * ddb/db_examine.c: Likewise. * ddb/db_expr.c: Likewise. * ddb/db_ext_symtab.c: Likewise. * ddb/db_input.c: Likewise. * ddb/db_lex.c: Likewise. * ddb/db_macro.c: Likewise. * ddb/db_mp.c: Likewise. * ddb/db_output.c: Likewise. * ddb/db_print.c: Likewise. * ddb/db_run.c: Likewise. * ddb/db_sym.c: Likewise. * ddb/db_task_thread.c: Likewise. * ddb/db_trap.c: Likewise. * ddb/db_variables.c: Likewise. * ddb/db_watch.c: Likewise. * device/blkio.c: Likewise. * device/chario.c: Likewise. * device/dev_lookup.c: Likewise. * device/dev_name.c: Likewise. * device/dev_pager.c: Likewise. * device/ds_routines.c: Likewise. * device/net_io.c: Likewise. * device/subrs.c: Likewise. * i386/i386/db_interface.c: Likewise. * i386/i386/fpu.c: Likewise. * i386/i386/io_map.c: Likewise. * i386/i386/loose_ends.c: Likewise. * i386/i386/mp_desc.c: Likewise. * i386/i386/pcb.c: Likewise. * i386/i386/phys.c: Likewise. * i386/i386/trap.c: Likewise. * i386/i386/user_ldt.c: Likewise. * i386/i386at/com.c: Likewise. * i386/i386at/kd.c: Likewise. * i386/i386at/kd_event.c: Likewise. * i386/i386at/kd_mouse.c: Likewise. * i386/i386at/kd_queue.c: Likewise. * i386/i386at/lpr.c: Likewise. * i386/i386at/model_dep.c: Likewise. * i386/i386at/rtc.c: Likewise. * i386/intel/pmap.c: Likewise. * i386/intel/read_fault.c: Likewise. * ipc/ipc_entry.c: Likewise. * ipc/ipc_hash.c: Likewise. * ipc/ipc_kmsg.c: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_mqueue.c: Likewise. * ipc/ipc_notify.c: Likewise. * ipc/ipc_port.c: Likewise. * ipc/ipc_right.c: Likewise. * ipc/mach_debug.c: Likewise. * ipc/mach_msg.c: Likewise. * ipc/mach_port.c: Likewise. * ipc/mach_rpc.c: Likewise. * kern/act.c: Likewise. * kern/exception.c: Likewise. * kern/ipc_mig.c: Likewise. * kern/ipc_tt.c: Likewise. * kern/lock_mon.c: Likewise. * kern/mach_clock.c: Likewise. * kern/machine.c: Likewise. * kern/printf.c: Likewise. * kern/priority.c: Likewise. * kern/startup.c: Likewise. * kern/syscall_emulation.c: Likewise. * kern/syscall_subr.c: Likewise. * kern/thread_swap.c: Likewise. * kern/time_stamp.c: Likewise. * kern/timer.c: Likewise. * kern/xpr.c: Likewise. * vm/memory_object.c: Likewise. * vm/vm_debug.c: Likewise. * vm/vm_external.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_kern.c: Likewise. * vm/vm_map.c: Likewise. * vm/vm_pageout.c: Likewise. * vm/vm_user.c: Likewise.
2014-04-04Use explicit prototypes for struct dev_ops fieldsMarin Ramesa
* device/conf.h: Include <sys/types.h>, <mach/port.h>, <mach/vm_prot.h>. Predefine struct io_req, io_req_t and io_return_t. (dev_ops): Add explicit prototypes for d_open, d_close, d_read, d_write, d_getstat, d_setstat, d_mmap, d_port_death. (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): Add prototypes. (nomap): Fix prototype. * device/dev_name.c (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): New functions. (nomap): Fix prototype. * device/ds_routines.c (dev_close): Pass 0 as flag parameter. * device/kmsg.c (kmsgclose): Drop return value. * device/kmsg.h (kmsgclose): Fix prototype. * i386/i386at/com.c (comopen): Fix prototype. (comclose): Fix prototype, drop return value. (comread, comwrite): Fix prototype. * i386/i386at/com.h (comopen, comclose, comread, comwrite): Fix prototype. * i386/i386at/conf.c (dev_ops): Use nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath where appropriate. * i386/i386at/kd.c (kdclose, kdread, kdwrite, kdmmap): Fix prototype. * i386/i386at/kd.h (kdclose, kdread, kdwrite, kdmmap): Likewise. * i386/i386at/kd_event.c (kbdopen): Likewise. * i386/i386at/kd_event.h (kbdopen): Likewise. * i386/i386at/kd_mouse.c (mouseopen): Likewise. * i386/i386at/kd_mouse.h (mouseopen): Likewise. * i386/i386at/lpr.c (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/lpr.h (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/mem.c (memmmap): Likewise. * i386/i386at/mem.h (memmmap): Likewise. * i386/i386at/model_dep.c (timemmap): Likewise. * i386/i386at/model_dep.h (timemmap): Likewise. * kern/mach_clock.c (timeopen, timeclose): Likewise. * kern/mach_clock.h: Include <sys/types.h>, predefine struct io_req and io_req_t. (timeopen, timeclose): Fix prototype.
2014-03-26kern: fix formatting of multiboot modulesJustus Winter
Previously, bootstrap_create would print the multiboot modules with padding applied to the end of the line. As multiboot modules as used by the Hurd span more than one line. This makes the list of modules hard to read and it looks unclean, more like an accident. Furthermore, it is not clear what the intend of this was, as the padding is applied at the end of the line, with no further information printed thereafter. * kern/bootstrap.c (bootstrap_create): Remove variable maxlen and len, update printfs.
2014-02-26kern: fix mig_strncpyJustus Winter
Previously, the function mig_strncpy would always zero-terminate the destination string. Make mig_strncpy behave like mig_strncpy and strncpy in the glibc. Also fix the implementation of mig_strncpy to return the length of the written string to align the implementation with the declaration in include/mach/mig_support.h. * kern/ipc_mig.c (mig_strncpy): Do not zero-terminate the destination string. Return length of destination string.
2014-02-12Reduce kmem_map to make room for kentry_data_sizeSamuel Thibault
* kern/slab.c (KMEM_MAP_SIZE): Decrease from 128MiB to 96MiB.
2014-02-05kern: implement task_set_nameJustus Winter
task_set_name sets the name of a task. This is a debugging aid. The name will be used in error messages printed by the kernel. * kern/task.c (task_set_name): New function. * kern/task.h (task_set_name): New declaration.
2014-02-04kern: make kmem_error panicJustus Winter
The slab allocator relies on the fact that kmem_cache_error does not return. Previously, kmem_error was using printf. Use panic instead. Found using the Clang Static Analyzer. * kern/slab.c (kmem_error): Use panic instead of printf.
2014-02-04kern: use kmem_warn instead of kmem_error in kmem_cache_errorJustus Winter
* kern/slab.c (kmem_cache_error): Use kmem_warn instead of kmem_error to print the cache name and its address.
2014-02-01kern: add a name field to struct taskJustus Winter
* kern/task.c (task_create): Initialize name with the address of the task. * kern/task.h (TASK_NAME_SIZE): New definition. (struct task): Add field name.
2014-02-01kern: add snprintfJustus Winter
* kern/printf.c (snprintf): New function. * kern/printf.h (snprintf): New declaration.
2014-01-16kern: include the mig-generated server headers in ipc_kobject.cJustus Winter
GNU MIG recently gained support for emitting x_server_routine declarations in the generated server header file. Using this declaration, the x_server_routine functions can be inlined into the ipc_kobject_server function. * kern/ipc_kobject.c: Include the mig-generated server headers.
2014-01-09kern: align kmem_cache objects using __cacheline_alignedJustus Winter
* kern/slab.h (struct kmem_cache): Align kmem_cache objects using __cacheline_aligned.
2014-01-06kern: optimize the layout of struct kmem_cacheJustus Winter
* kern/slab.h (struct kmem_cache): Reorder the fields so that all hot fields are within the first cache line.
2014-01-05kern: explain the significance of the chosen lengthJustus Winter
* kern/slab.h (KMEM_CACHE_NAME_SIZE): Explain the significance of the chosen length.
2014-01-03kern: make struct kmem_cache fit into two cache linesJustus Winter
Previously, the size of struct kmem_cache was 136 bytes, just eight bytes larger than 128 bytes, which is typically two cache lines on today's CPUs. By reducing the size of the name field which holds a human-readable description by eight bytes to 24 bytes, the struct kmem_cache can be made fit into two cache lines. This change should not affect the usefulness of this field. For reference, the length of the largest hard-coded name is 17. * kern/slab.h (KMEM_CACHE_NAME_SIZE): Define to 24.
2014-01-03kern: reduce the size of struct taskJustus Winter
* kern/task.h (struct task): Reduce the size of struct task by 2 * sizeof boolean_t by using a bit field for the boolean flags.
2013-12-20Mark pure functions with attribute pureMarin Ramesa
2013-12-20kern/strings.c (strlen): mark with attribute pureMarin Ramesa
* kern/strings.c (strlen): Mark with attribute pure.
2013-12-20Declare void argument lists (part 2)Marin Ramesa
Declare void argument lists that were not declared in the first part of this patch and * kern/sched_prim.h (recompute_priorities): Fix prototype. * kern/startup.c (setup_main) (recompute_priorities): Fix call.
2013-12-17kern: avoid the casts in enqueue_head() and enqueue_tail()Marin Ramesa
* kern/eventcount.c (simpler_thread_setrun) (enqueue_head) (th): Avoid the cast. * kern/thread.c (thread_halt_self) (enqueue_tail) (thread): Likewise. * kern/thread_swap.c (thread_swapin) (enqueue_tail) (thread): Likewise.
2013-12-17Mark functions that don't return with attribute noreturnMarin Ramesa
2013-12-17kern: qualify pointers whose dereferenced values are constant with constMarin Ramesa
2013-12-17Cleanup of the copyin() and copyout() callsMarin Ramesa
* device/ds_routines.c (device_write_trap) (copyin) (data): Cast to (void *). Argument is an address. (device_write_trap) (copyin) (io_data): Don't cast. (device_writev_trap) (copyin) (iovec, stack_iovec): Likewise. (device_writev_trap) (copyin) (data, p): Cast to (void *). Arguments are addresses. * kern/bootstrap.c (build_args_and_stack) (copyout) (arg_count, string_pos, zero): Don't cast. * kern/ipc_mig.c (syscall_vm_map) (copyin, copyout) (addr, address): Likewise. (syscall_vm_allocate) (copyin, copyout) (addr, address): Likewise. (syscall_task_create) (copyout) (name, child_task): Likewise. (syscall_mach_port_allocate) (copyout) (name, namep): Likewise. * kern/time_stamp.c (copyout) (temp, tsp): Likewise.
2013-12-17kern/sched_prim.h: remove unnecessary __GNUC__ #ifdefMarin Ramesa
Attribute noreturn is used irrespective of __GNUC__. Remove unnecessary #ifdef. * kern/sched_prim.h [__GNUC__]: Remove #ifdef.
2013-12-16kern: quiet GCC warnings about set but unused variablesMarin Ramesa
* kern/lock.h (simple_lock_data_empty): Define. (decl_simple_lock_data, simple_unlock): Likewise. * kern/sched_prim.c (lock): Declare. [MACH_SLOCKS]: Remove #ifs. * kern/task.c (task_lock, task_unlock): Remove address operator.
2013-12-15kern/sched_prim.c: avoid castsMarin Ramesa
Avoid the casts by passing the address of the links thread structure member to enqueue_tail(). * kern/sched_prim.c: Avoid casts.
2013-12-15Type definitionMarin Ramesa
* i386/i386/ast_check.c (init_ast_check, cause_ast_check): Define return type. * i386/i386/pic.c (intnull, prtnull): Define argument types. * i386/i386at/com.c (compr_addr): Likewise. (compr): Likewise. (compr_addr): Fix printf format. * i386/i386at/kd.c (kd_cmdreg_write, kd_kbd_magic): Define argument types. * i386/i386at/kd_mouse.c (init_mouse_hw): Likewise. * ipc/mach_port.c (sact_count): Define return type. * ipc/mach_rpc.c (mach_port_rpc_sig): Define argument types. * kern/act.c (dump_act): Define return type. * kern/lock_mon.c (simple_lock, simple_lock_try, simple_unlock, lip, lock_info_sort, lock_info_clear, print_lock_info): Define return type. (time_lock): Define return type and argument type. * kern/timer.c (time_trap_uexit): Define argument type.
2013-12-15kern/mach_clock.c: update commentMarin Ramesa
This is mach_clock.c, not clock_prim.c. * kern/mach_clock.c: Update comment.
2013-12-15Declare void argument listsMarin Ramesa
2013-12-11Cleanup of the memcpy(), memmove(), memcmp() and memset() callsMarin Ramesa
Addresses were cast to (void *). Pointers uncasted. * device/ds_routines.c (ds_read_done) (memset) (start_sent): Cast to (void *) instead to (char *). Argument is an address. (ds_read_done) (memset) (end_data): Likewise. * i386/i386/pcb.c (thread_getstatus) (memcpy) (pm): Don't cast. Argument is a pointer. (thread_getstatus) (memcpy) (iopb): Likewise. * i386/i386at/immc.c (immc_cnputc) (memmove): Cast first argument to (void *). Argument is an address. (immc_cnputc) (memmove): Cast second argument to (void *). Argument is an address. (immc_cnputc) (memset): Cast first argument to (void *). Argument is an address. * i386/i386at/model_dep.c (i386at_init) (memcpy) (phystokv): Cast to (void *) instead to (char *). Argument is an address. * i386/intel/pmap.c (pmap_init) (memset) (addr): Likewise. * ipc/mach_debug.c (mach_port_space_info) (memset) (table_addr + size_used): Likewise. (mach_port_space_info) (memset) (tree_addr + size_used): Likewise. * kern/host.c (host_processor_sets) (memcpy) (newaddr): Likewise. (host_processor_sets) (memcpy) (addr): Likewise. * kern/xpr.c (xprbootstrap) (memset) (addr): Likewise. * vm/vm_debug.c (mach_vm_object_pages) (memset) (addr + size_used): Likewise.
2013-12-09kern/startup.c: use boolean valuesMarin Ramesa
* kern/startup.c (reboot_on_panic): Use boolean values.
2013-12-09kern/act.h: remove unnecessary includeMarin Ramesa
File kern/act.h includes itself. Remove this include. * kern/act.h: Don't include kern/act.h.
2013-12-09Cleanup of the prototypesMarin Ramesa
* device/cirbuf.h (nqdb): Remove prototype without definition. * device/conf.h (dev_set_indirect): Likewise. * kern/boot_script.h (boot_script_read_file): Likewise. * kern/eventcount.h (evc_notify_abort): Remove duplicate prototype. * kern/thread.h (thread_set_own_priority): Likewise. * kern/thread_swap.h (thread_swapout): Remove prototype without definition. * kern/timer.h (softclock): Remove duplicate prototype. * vm/pmap.h (pmap_resident_count, pmap_access, pmap_phys_address, pmap_phys_to_frame): Remove prototypes without function definition. * vm/vm_page.h (vm_set_page_size): Likewise.
2013-12-09kern/syscall_sw.c: use boolean instead of an intMarin Ramesa
* kern/syscall_sw.c (kern_invalid_debug): Use boolean instead of an int.