summaryrefslogtreecommitdiff
path: root/kern
AgeCommit message (Collapse)Author
2024-02-28Check for null ports in task_set_essential, task_set_name and thread_set_name.Flavio Cruz
Otherwise, it is easy to crash the kernel if userland passes arbitrary port names. Message-ID: <ZdriTgNhPsfu7c2M@jupiter.tail36e24.ts.net>
2024-02-23kern: move pset_idle_lock/unlock to headerSamuel Thibault
so that kern/machine.c can use it
2024-02-23kern: Use _nocheck variants of locks taken at splsched()Damien Zammit
Fixes assertion errors when LDEBUG is compiled in. Message-ID: <20240223081404.458062-1-damien@zamaudio.com>
2024-02-23kern: Use _irq variant of lock and disable interruptsDamien Zammit
During quantum adjustment, disable interrupts and call appropriate lock. Message-ID: <20240223080948.457792-1-damien@zamaudio.com>
2024-02-23kern/processor: Do not set default_pset.empty on bootstrapDamien Zammit
This is not needed because cpu_up does this when it comes online, it calls pset_add_processor(). Message-ID: <20240223080357.457465-1-damien@zamaudio.com>
2024-02-22kern/gsync: Use vm_map_lookup with keep_map_lockedDamien Zammit
This prevents a deadlock in smp where a read lock on the map is taken in gsync and then the map is locked again inside vm_map_lookup() but another thread had a pre-existing write lock, therefore the second read lock blocks. This is fixed by removing the initial gsync read lock on the map but keeping the read lock held upon returning from vm_map_lookup(). Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-4-damien@zamaudio.com>
2024-02-22vm_map_lookup: Add parameter for keeping map lockedDamien Zammit
This adds a parameter called keep_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-3-damien@zamaudio.com>
2024-02-19Fix compile with MACH_LOCK_MONDamien Zammit
2024-02-19Introduce and use assert_splsched()Samuel Thibault
2024-02-19kern: Fix parenthesis around assignment used as valueDamien Zammit
2024-02-12smp: Set processor set to non-empty when adding a processorDamien Zammit
This allows the slave_pset to be used for actual tasks with the processor_set RPCs. Message-ID: <20240212053817.1919056-1-damien@zamaudio.com>
2024-02-12Add thread_set_name RPC.Flavio Cruz
Like task_set_name, we use the same size as the task name and will inherit the task name, whenever it exists. This will be used to implement pthread_setname_np. Message-ID: <20240212062634.1082207-2-flaviocruz@gmail.com>
2024-02-12Replace kernel header includes in include/mach/mach_types.h with forward ↵Flavio Cruz
declarations. I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was impossible because files included from kern/task.h end up requiring kern/thread.h (through percpu.h), creating a recursive dependency. With this change, mach_types.h only defines forward declarations and modules have to explicitly include the appropriate header file if they want to be able touch those structures. Most of the other includes are required because we no longer grab many different includes through mach_types.h. Message-ID: <20240212062634.1082207-1-flaviocruz@gmail.com>
2024-02-11task: fix addressability of assign_active fieldSamuel Thibault
It is used for thread_wakeup and alike.
2024-02-11smp: Create AP processor set and put all APs inside itDamien Zammit
This has the effect of running with one cpu only with smp, but has the ability to enable APs in userspace with the right processor set RPCs. Message-ID: <20240211120051.1889789-1-damien@zamaudio.com>
2024-02-11smp: Fix parenthesis around logic expression valueDamien Zammit
Message-ID: <20240211070915.1879676-1-damien@zamaudio.com>
2023-10-01mach_msg: Fix checking reception sizeSamuel Thibault
We need to check against the actual user size that will be used, not the current kernel size. Usually userland uses amply-large reception buffer, but better be exact.
2023-10-01Add and use ikm_cache_alloc/free/_trySamuel Thibault
2023-10-01slab: Make whatis look furtherSamuel Thibault
Without a tree, we can still look up by hand in the buffers. This also allows to find freed objects.
2023-10-01ddb: Add whatis commandSamuel Thibault
This is convenient when tracking buffer overflows
2023-09-30Allow disabling of MACH_PCSAMPLE and disable by defaultDamien Zammit
This fixes a page fault when the sampling occurs in MP. Perhaps it is not MP safe yet. Message-Id: <20230930063032.75232-4-damien@zamaudio.com>
2023-09-29kdb: Add "show all runqs" debug commandDamien Zammit
Message-Id: <20230929045936.31535-1-damien@zamaudio.com>
2023-09-25percpu: active_stack with gsDamien Zammit
Message-Id: <20230925002417.467022-1-damien@zamaudio.com>
2023-09-24SMP: Fix setting up initial gdtSamuel Thibault
We cannot access cpu_id_lut from the initial AP state, so update the percpu segment after loading gdt.
2023-09-24percpu active_thread using gs segmentDamien Zammit
TESTED: As per previous commit Message-Id: <20230924052824.449219-4-damien@zamaudio.com>
2023-09-24percpu area using gs segmentDamien Zammit
This speeds up smp again, by storing the struct processor in a percpu area and avoiding an expensive cpu_number every call of current_processor(), as well as getting the cpu_number by an offset into the percpu area. Untested on 64 bit and work remains to use other percpu arrays. TESTED: (NCPUS=8) -smp 1 boots to login shell ~2x slower than uniprocessor TESTED: (NCPUS=8) -smp 2 boots to INIT but hangs there TESTED: (NCPUS=8) -smp 4 gets stuck seemingly within rumpdisk and hangs TESTED: (NCPUS=1) uniprocessor is a bit faster than normal Message-Id: <20230924103428.455966-3-damien@zamaudio.com>
2023-09-24cpu_number: Inline widely used simple functionDamien Zammit
TESTED: on uniprocessor and smp, both behaved as normal. Message-Id: <20230924103428.455966-2-damien@zamaudio.com>
2023-08-22sched_prim.c: Check all run queues not just master processorDamien Zammit
Message-Id: <20230816014835.2322718-6-damien@zamaudio.com>
2023-08-22eventcount: Fix locking thread while calling thread_setrunSamuel Thibault
2023-08-22sched_prim.c: Lock thread when calling thread_setrunDamien Zammit
Message-Id: <20230816014835.2322718-5-damien@zamaudio.com>
2023-08-21slab: Optimize non-slab PAGE_SIZE allocationsSamuel Thibault
In case there is no slab for PAGE_SIZE allocations, we can use direct physical allocation rather than consuming the kernel virtual space.
2023-08-14pmap+slab: Add more smoketestsSamuel Thibault
Checking the range of addresses for operations on the kernel_pmap is quite cheap, and allows to catch oddities quite early enough.
2023-08-14slab [SLAB_VERIFY]: Fix not enabling KMEM_CF_VERIFY on 4K slabsSamuel Thibault
2023-08-13slab [SLAB_VERIFY]: Do not enable KMEM_CF_VERIFY on large slabsSamuel Thibault
That would be refused by kmem_cache_compute_properties later on anyway, and prevent the kernel from booting at all.
2023-08-13lock: Fix SMP buildSamuel Thibault
2023-08-13kern/sched_prim: Cause ast on cpu coming out of idleDamien Zammit
Message-Id: <20230811083424.2154350-3-damien@zamaudio.com>
2023-08-12simple lock: check that the non-_irq variants are not called from IRQSamuel Thibault
2023-08-12assert: fix concurrency against irqsSamuel Thibault
by using simple_lock_irq.
2023-08-12clock: Convert timer_lock to using simple_lock_irqSamuel Thibault
2023-08-12sched: Add waitq_lock helpers which check they are called at spl7Samuel Thibault
2023-08-12sched: Add runq_lock helpers which check they are called at spl7Samuel Thibault
2023-08-12kern: Check that locking thread is done at spl7Samuel Thibault
2023-08-12lock: Add _irq variantsSamuel Thibault
And pave the way for making the non-_irq variants check that they are never used within interrupts. We do have a few places which were missing it, as the following commits will show.
2023-08-12lock: Add more sanity checksSamuel Thibault
2023-08-12lock: Reset l->writer also for read-write upgradees which are doneSamuel Thibault
2023-08-12lock: Fix building with MACH_LDEBUG but NCPUS==1Samuel Thibault
2023-08-12lock: Rename simple_unlock version with information to _simple_unlockSamuel Thibault
For coherency with the rest of the implementations
2023-08-06kern/thread: Only loop over cpus that existDamien Zammit
Message-Id: <20230805154859.2003109-1-damien@zamaudio.com>
2023-08-05Add timing info to MACH_LOCK_MON lock monitoringDamien Zammit
Booting to beginning of bootstrap with different number of cpus and checking the lock statistics where TIME is in milliseconds: Set MACH_LOCK_MON to 1 in configfrag.ac, then Configure options --enable-ncpus=8 --enable-kdb --enable-apic --disable-linux-groups -smp 1 db{0}> show all slocks SUCCESS FAIL MASKED STACK TIME LOCK/CALLER 4208 0/0 4208/100 2/0 7890/1 0xc1098f54(c11847c8) 1 0/0 1/100 0/0 7890/7890 0x315(c11966e0) 30742 0/0 0/0 2106/0 160/0 0xf52a9e2c(f5a07958) 30742 0/0 0/0 0/0 140/0 0xf52a5e2c(f5a07b10) 149649 0/0 3372/2 1/0 120/0 0xc118a590(c118a9d4) 16428 0/0 0/0 1/0 90/0 0xf52a5dd0(f5a07ab8) 14345 0/0 0/0 18/0 80/0 0xf64afe2c(f64aa488) 1791 0/0 0/0 1/0 80/0 0xf52a3e70(f5e57f70) 17331 total locks, 0 empty buckets 2320150 0/0 455490/19 11570533/4 17860/0 0xc10a4580(c10a4580) -smp 2 (could not wait until booted) db{0}> show all slocks SUCCESS FAIL MASKED STACK TIME LOCK/CALLER 47082 0/0 47082/100 0/0 413940/8 0xc1098f54(c11847c8) 2 0/0 2/100 0/0 413940/206970 0x6ede(c11966e0) 47139 0/0 0/0 2106/0 4670/0 0xc119edec(f5e409b0) 132895 3/0 3372/2 1/0 4580/0 0xc118a590(c118a9d4) 118313 0/0 2/0 0/0 3660/0 0xc1098ec4(c1189f80) 183233 1/0 1714/0 2/0 2290/0 0xc1098e54(c118aa8c) 14357 0/0 0/0 1878/0 1200/0 0xf52a4de0(f5e40a60) 14345 0/0 0/0 18/0 1200/0 0xf52a4dec(f528f488) 16910 total locks, 0 empty buckets 2220850 455/0 485391/21 11549793/5 879030/0 0xc10a4580(c10a4580) Message-Id: <20230722045043.1579134-1-damien@zamaudio.com>
2023-05-17Fix task_info for TASK_THREAD_TIMES_INFO.Flavio Cruz
We are checking for the existence of time_value64_t but we didn't add that to the task_thread_times_info structure. Message-Id: <ZGRDbS0XIm1fJwkG@jupiter.tail36e24.ts.net>