summaryrefslogtreecommitdiff
path: root/kern
AgeCommit message (Collapse)Author
2021-12-31thread: Fix thread_abort clearing of an event waitAlicia
881fe9da8bd1 ("kern/thread.c: some minor style changes") introduced a spurious comment.
2021-12-30kern/thread.c: some minor style changesAdam Kandur
Greeting, I have changed some stuff in kern/thread.c which makes code more readable for me. Maybe it will be usefull. Message-Id: <20211230082643.8171-1-sys.arch.adam@gmail.com>
2021-08-27vm_page_grab: allow allocating in high memorySamuel Thibault
vm_page_grab was systematically using the VM_PAGE_SEL_DIRECTMAP selector to play safe with existing code. This adds a flags parameter to let callers of vm_page_grab specify their constraints. Linux drivers need 32bit dmas, Xen drivers use kvtophys to clear some data. Callers of kmem_pagealloc_physmem and vm_page_grab_phys_addr also use kvtophys. Otherwise allocations can go to highmem. This fixes the allocation jam in the directmap segment. * vm/vm_page.h (VM_PAGE_DMA, VM_PAGE_DMA32, VM_PAGE_DIRECTMAP, VM_PAGE_HIGHMEM): New macros. (vm_page_grab): Add flags parameter. * vm/vm_resident.c (vm_page_grab): Choose allocation selector according to flags parameter. (vm_page_convert, vm_page_alloc): Pass VM_PAGE_HIGHMEM to vm_page_grab. (vm_page_grab_phys_addr): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * vm/vm_fault.c (vm_fault_page): Pass VM_PAGE_HIGHMEM to vm_page_grab. * vm/vm_map.c (vm_map_copy_steal_pages): Pass VM_PAGE_HIGHMEM to vm_page_grab. * kern/slab.c (kmem_pagealloc_physmem): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * i386/intel/pmap.c (pmap_page_table_page_alloc): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * xen/block.c (device_read): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * linux/dev/glue/block.c (alloc_buffer): Pass VM_PAGE_DMA32 to vm_page_grab.
2021-08-12assert: Tell the compiler that failures are unlikelySamuel Thibault
2021-04-05thread_info: Fix crash when requesting for thread that never ranSamuel Thibault
* kern/thread.c (thread_info): Set last_processor to 0 when the thread never ran.
2021-04-05thread_info: Fix returning last_processorSamuel Thibault
thread->last_processor is a processor_t, not a slot number. * kern/thread.c (thread_info): Set sched_info->last_processor to thread->last_processor->slot_num rather than thread->last_processor.
2021-04-04SMP: Fix warningsSamuel Thibault
2021-03-27clock: Let timer proceed even before we have set threadsDamien Zammit
Message-Id: <20210326094850.2606-4-damien@zamaudio.com>
2020-10-07elf-load: Avoid loading PIE binaries at address 0Samuel Thibault
It seems that ld.so sometimes gets into troubles and hangs at bootstrap. * kern/elf-load.c (exec_load): When x.e_type == ET_DYN || x.e_type == ET_REL, add 128MiB as loadbase.
2020-10-07bootstrap: Increase STACK_SIZESamuel Thibault
* kern/bootstrap.c (STACK_SIZE): Set to 128KB. glibc's __MAX_ALLOCA_CUTOFF is 64K by default.
2020-09-19smp: Add --enable-ncpus option and fix buildSamuel Thibault
* configfrag.ac (--enable-ncpus): Add option to set $mach_ncpus. * i386/i386/cpu_number.h (CPU_NUMBER, cpu_number): New macros, set to 0 for now. * i386/i386/db_interface.c (cpu_interrupt_to_db): New function. * i386/i386/db_interface.h (cpu_interrupt_to_db): New declaration. * i386/i386/mp_desc.c (int_stack_base): New array. (intel_startCPU): New function. * i386/i386at/model_dep.c: Include <i386/smp.h> (int_stack_top, int_stack_base): Turn into arrays (i386at_init): Update accesses accordingly. * i386/i386at/model_dep.h (int_stack_top, int_stack_base, ON_INT_STACK): Likewise. * i386/intel/pmap.c (cpus_active, cpus_idle, cpu_update_needed): Add variables. * i386/intel/pmap.h (cpus_active, cpus_idle, cpu_update_needed): Mark extern. * kern/cpu_number.h: Include <machine/cpu_number.h> * linux/dev/arch/i386/kernel/irq.c (local_bh_count, local_irq_count): Hardcode to the address of intr_count. We will not use the Linux code in SMP mode anyway.
2020-09-19smp: Add generic smp pseudoclassAlmudena Garcia
This pseudoclass generalize the initialization and access of SMP data, allowing expands it to other architectures. In x86, the functions calls to apic functions. *kern/smp.c: Source file. Implements a interface to load the SMP functions for the current architecture. *kern/smp.h: Header file. Add declaration for smp_data structure. *i386/i386/smp.c: Source file. Implements a set of functions to manage the SMP actions in i386 *i386/i386/smp.h: Header file. Add declarations for SMP functions in i386.
2020-07-10Add hardware interrupt notification mechanismSamuel Thibault
This allows privileged userland drivers to get notifications of hardware interrupts. Initial work by Zheng Da, reworked by Damien Zammit and myself. * Makefrag.am (libkernel_a_SOURCES): Add device/intr.c and device/intr.h. (include_device_HEADERS): Add include/device/notify.defs and include/device/notify.h. * device/dev_hdr.h (name_equal): Add declaration. * device/ds_routines.c: Include <device/intr.h> (ds_device_intr_register, ds_device_intr_ack): New functions. * device/intr.c, device/intr.h: New files. * doc/mach.texi (Device Interrupt): New section. * i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386/irq.c and i386/i386/irq.h. * i386/i386/irq.c, i386/i386/irq.h: New files. * i386/i386at/conf.c: Include <device/intr.h>. (irqname): New macro. (dev_name_list): Add irq device. * include/device/device.defs (device_intr_register, device_intr_ack): New RPCs. * include/device/notify.defs, include/device/notify.h: New files. * kern/startup.c: Include <device/intr.h> (start_kernel_threads): Start intr_thread thread. * linux/dev/arch/i386/kernel/irq.c: Include <device/intr.h> (linux_action): Add user_intr field. (linux_intr): Call user_intr action if any. (mask_irq, unmask_irq): Move functions to i386/i386/pic.c (__disable_irq, __enable_irq): Move functions to i386/i386/irq.c. (install_user_intr_handler): New function. (request_irq): Initialize user_intr field. * linux/src/include/asm-i386/irq.h (__disable_irq, __enable_irq): Remove prototypes. * i386/i386/pic.c (mask_irq, unmask_irq): New functions. * i386/i386/pic.h (mask_irq, unmask_irq): New prototypes.
2020-07-09Add experimental RPC infrastructureSamuel Thibault
This is free for experimenting RPCs, with no backward compatibility guarantees. * Makefrag.am (EXTRA_DIST): Add kern/experimental.srv. (include_mach_HEADERS): Add include/mach/experimental.defs. (nodist_lib_dep_tr_for_defs_a_SOURCES): Add kern/experimental.server.defs.c. (nodist_libkernel_a_SOURCES): Add kern/experimental.server.h, kern/experimental.server.c, kern/experimental.server.msgids. (nodist_libkernel_a_SOURCES): Add kern/experimental.server.defs. * include/mach/experimental.defs: New file. * kern/experimental.srv: New file. * kern/ipc_kobject.c: Include <kern/experimental.server.h>. (ipc_kobject_server): Call experimental_server_routine.
2020-04-06mach_trap_table: Fix 64bit versionSamuel Thibault
The addition of the mach_trap_name field made the 64bit unused field spurious. * kern/syscall_sw.h (mach_trap_t): Remove `unused' field.
2020-04-06bootstrap: Add missing reference to send port between tasksSamuel Thibault
When giving the port to a bootstrap task to another bootstrap task, we need to add a reference. This shows up on error-cleanup (e.g. when forgetting to define the root). * kern/bootstrap.c (boot_script_insert_task_port): Call ipc_port_make_send on `task''s itk_sself.
2020-04-06boot_script: Explicit missing symbol nameSamuel Thibault
* kern/boot_script.c: Include <kern/printf.h>. (boot_script_exec): Print missing symbol name on symbol lookup error.
2020-04-05x86_64: Fix passing argumentSamuel Thibault
* kern/boot_script.c (add_arg): Make val parameter long.
2020-03-31Fix build with -fno-commonSamuel Thibault
which will be the default in gcc-10. * device/io_req.h (io_inband_cache): Add extern qualifier. * device/tty.h (tthiwat, ttlowat): Likewise. * i386/i386/db_machdep.h (ddb_regs): Likewise. * kern/cpu_number.h (master_cpu): Likewise. * kern/time_stamp.h (ts_tick_count): Likewise. * linux/src/drivers/scsi/in2000.h (proc_scsi_in2000): Likewise. * device/ds_routines.c (io_inband_cache): New variable. * i386/i386/db_interface.c (ddb_regs): Likewise. * kern/processor.c (master_cpu): Likewise. * kern/time_stamp.c (ts_tick_count): Likewise. * linux/pcmcia-cs/modules/pci_fixup.c (pci_root): Remove variable.
2020-03-28bootstrap.c: Add 32-on-64bit supportSamuel Thibault
* kern/bootstrap.c (bootstrap_create): Support loading 32bit binaries on 64bit.
2020-03-28syscall_sw.h: Add 64bit variantSamuel Thibault
* kern/syscall_sw.h (mach_trap_t): Fix structure for 64bit.
2020-01-01Cope with machine_info.memory_size overflowSamuel Thibault
* kern/startup.c (setup_main): When memory size overflows machine_info.memory_size, set to maximum size.
2019-11-01sched: cause ast on master processor tooSamuel Thibault
Nowadays' processors are way fast enough to handle everything fine. * kern/sched_prim.c (thread_setrun): Do not check against target processor being master.
2019-10-27patch: add last_processor to thread info structuresAlmudena Garcia
* include/mach/thread_info.h (thread info structures): Add new member "last_processor" in thread_sched_info. * kern/thread.c (thread management): Fill new member "last_processor" in thread_info() function.
2019-08-11Fix formatSamuel Thibault
* kern/task.c (task_create_kernel): Fix passing string size.
2019-08-11Fix uninitialized valueSamuel Thibault
* kern/gsync.c (temp_mapping): Initialize start address to VM_MIN_KERNEL_ADDRESS.
2018-11-19Fix interactivity of inactive threadsSamuel Thibault
A new thread will mosty probably start working, assume it will take its share of CPU, to avoid having to find it out slowly. Decaying will however fix that quickly if it actually does not work. This fixes stalling issues when a program keeps creating threads. * kern/thread.c (thread_create): Set new_thread's cpu_usage and sched_usage to a fair share of the current load.
2018-11-19Fix task and thread collection frequencySamuel Thibault
sched_tick is incremented only once per second, not once per tick. * kern/task.c (consider_task_collect): Divide task_collect_max_rate by (hz / 1) to get a number of scheduler ticks. * kern/thread.c (consider_thread_collect): Divide thread_collect_max_rate by (hz / 1) to get a number of scheduler ticks.
2018-11-19Drop SIMPLE_CLOCK supportSamuel Thibault
This wasn't building and is not useful with nowaday's hardware. * configfrag.ac (SIMPLE_CLOCK): Do not define. * kern/sched.h [SIMPLE_CLOCK] (sched_usec): Remove variable declaration. * kern/sched_prim.c [SIMPLE_CLOCK] (sched_usec): Remove variable. [SIMPLE_CLOCK] (sched_init): Do not initialize sched_usec variable. [SIMPLE_CLOCK] (recompute_priorities): Do not tinker sched_usec variable. * kern/thread.c [SIMPLE_CLOCK] (thread_info): Do not ajust for clock drift.
2018-11-19Make scheduling more reactiveSamuel Thibault
Give smaller quantums to processes, to get more frequent context switches. This fixes some reactivity for concurrent processes. * kern/sched.h (MIN_QUANTUM): Define to hz / 33. * kern/sched_prim.c (sched_init): Use MIN_QUANTUM instead of hz / 10.
2018-11-04Fix using all dynamic prioritiesSamuel Thibault
6a2342010811 ("Increase number of priorities") increased NRQS but didn't increase PRI_SHIFT to extend the use of the additional queues by the scheduler. This does it. While at it, extend to NRQS to 64, the double of the original 32, to keep all values coherent. * i386/i386/sched_param.h (PRI_SHIFT): Set from 18 to 17. * kern/sched.h (PRI_SHIFT): Set from 18 to 17. (NRQS): Set to 64.
2018-06-27Add cause_ast_check prototypeSamuel Thibault
As reported by Almudena Garcia <liberamenso10000@gmail.com> * kern/ast.h [NCPUS > 1] (cause_ast_check): Add prototype.
2018-06-27Define CPU_L1_SIZE even when NCPUS != 1Samuel Thibault
As reported by Almudena Garcia <liberamenso10000@gmail.com> * kern/cpu_number.h [NCPUS != 1] (CPU_L1_SIZE): Define macro.
2018-06-17Add missing prototypeSamuel Thibault
* kern/machine.h (action_thread): Add prototype.
2018-01-28Fix warningSamuel Thibault
* kern/sched_prim.c (assert_wait): Fix panic format.
2018-01-28Fix warningSamuel Thibault
* kern/ast.c (ast_check): Fix panic format.
2017-10-27Fix commit 10ebf9565f69760e46a8f271e22c5367d54e10ff.Justus Winter
* kern/task.c (task_ledger_acquire): Remove function that I added by accident. (task_ledger_release): Likewise.
2017-10-26kern: Fix new task notifications.Justus Winter
* kern/task.c (task_create_kernel): Handle NULL parent tasks.
2017-10-26kern: Fix crash.Justus Winter
Check receiver in task_create. Fixes a crash when sending that message to a non-task port. * kern/bootstrap.c (boot_script_task_create): Use the new function. * kern/task.c (task_create): Rename to task_create_internal, create a new function in its place that checks the receiver first. * kern/task.h (task_create_internal): New prototype.
2017-10-23Drop the register qualifier.Justus Winter
* i386/intel/pmap.c: Drop the register qualifier. * ipc/ipc_kmsg.h: Likewise. * kern/bootstrap.c: Likewise. * kern/profile.c: Likewise. * kern/thread.c: Likewise. * vm/vm_object.c: Likewise.
2017-08-05kern: Fix reporting the minimum quantum used for scheduling.Justus Winter
* kern/host.c (host_info): Scale 'min_quantum' by 'tick', then convert to milliseconds.
2017-05-07Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumachSamuel Thibault
2017-03-18kern: Make kernel task available to bootscript.Justus Winter
* kern/bootstrap.c (bootstrap_create): Insert the variable 'kernel-task' into the bootscript environment. Userspace can use this instead of guessing based on the order of the first tasks.
2017-03-04Rewrite gsync so that it works with remote tasks v2Agustina Arzille
2017-03-04Implement basic sleeping locks for gnumachAgustina Arzille
* kern/atomic.h: New file. * kern/kmutex.h: New file. * kern/kmutex.c: New file. * Makefrag.am (libkernel_a_SOURCES): Add atomic.h, kmutex.h, kmutex.c. * kern/sched_prim.h (thread_wakeup_prim): Make it return boolean_t. * kern/sched_prim.c (thread_wakeup_prim): Return TRUE if we woke a thread, and FALSE otherwise.
2016-12-09rbtree: minor changeRichard Braun
* kern/rbtree.h (rbtree_for_each_remove): Remove trailing slash.
2016-11-10gsync: Avoid NULL pointer dereferenceBrent Baccala
* kern/gsync.c (gsync_wait, gsync_wake, gsync_requeue): Return immediately if task argument is TASK_NULL
2016-10-31gsync: fix licenceSamuel Thibault
Agustina relicenced her work. * kern/gsync.c: Relicence to GPL 2+. * kern/gsync.h: Relicence to GPL 2+.
2016-10-31gsync: Fix crash when task is not current taskSamuel Thibault
* kern/gsync.c (gsync_wait, gsync_wake, gsync_requeue): Return KERN_FAILURE when task != current_task().
2016-10-31gsync: Fix assertion failure with MACH_LDEBUGSamuel Thibault
vm_map_lock_read calls check_simple_locks(), so we need to lock hbp after taking the vm_map read lock. * kern/gsync.c (gsync_wait): Call vm_map_lock_read before locking &hbp->lock. (gsync_wake): Likewise.