Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
* Makefrag.am: Include the exception protocol in 'gnumach.msgids'.
* kern/exc.defs: New file.
|
|
* include/mach_debug/slab_info.h (CACHE_FLAGS_NO_CPU_POOL,
CACHE_FLAGS_SLAB_EXTERNAL, CACHE_FLAGS_NO_RECLAIM,
CACHE_FLAGS_VERIFY, CACHE_FLAGS_DIRECT): Remove macros.
* kern/slab.c (host_slab_info): Pass raw cache flags to caller.
|
|
The slab allocator has grown to use multiple ways to allocate slabs
as well as track them, which got a little messy. One consequence is
the breaking of the KMEM_CF_VERIFY option. In order to make the code
less confusing, this change expresses all options as explicit cache
flags and clearly defines their relationships.
The special kmem_slab and vm_map_entry caches are initialized
accordingly.
* kern/slab.c (KMEM_CF_DIRECTMAP): Rename to ...
(KMEM_CF_PHYSMEM): ... this new macro.
(KMEM_CF_DIRECT): Restore macro.
(KMEM_CF_USE_TREE, KMEM_CF_USE_PAGE): New macros.
(KMEM_CF_VERIFY): Update value.
(kmem_pagealloc_directmap): Rename to...
(kmem_pagealloc_physmem): ... this new function.
(kmem_pagefree_directmap): Rename to ...
(kmem_pagefree_physmem): ... this new function.
(kmem_pagealloc, kmem_pagefree): Update macro names.
(kmem_slab_use_tree): Remove function.
(kmem_slab_create, kmem_slab_destroy): Update according to the new
cache flags.
(kmem_cache_compute_sizes): Rename to ...
(kmem_cache_compute_properties): ... this new function, and update
to properly set cache flags.
(kmem_cache_init): Update call to kmem_cache_compute_properties.
(kmem_cache_alloc_from_slab): Check KMEM_CF_USE_TREE instead of
calling the defunct kmem_slab_use_tree function.
(kmem_cache_free_to_slab): Update according to the new cache flags.
kmem_cache_free_verify): Add assertion.
(slab_init): Update initialization of kmem_slab_cache.
* kern/slab.h (KMEM_CACHE_DIRECTMAP): Rename to ...
(KMEM_CACHE_PHYSMEM): ... this new macro.
* vm/vm_map.c (vm_map_init): Update initialization of vm_map_entry_cache.
|
|
Caches that use external slab data but allocate slabs from the direct
physical mapping can look up slab data in constant time by associating
the slab data directly with the underlying page.
* kern/slab.c (kmem_slab_use_tree): Take KMEM_CF_DIRECTMAP into account.
(kmem_slab_create): Set page private data if relevant.
(kmem_slab_destroy): Clear page private data if relevant.
(kmem_cache_free_to_slab): Use page private data if relevant.
* vm/vm_page.c (vm_page_init_pa): Set `priv' member to NULL.
* vm/vm_page.h (vm_page_set_priv, vm_page_get_priv): New functions.
|
|
* kern/slab.c (slab_init): Remove unused variables.
|
|
Since the slab allocator has been changed to sit directly on top of the
physical allocator, failures caused by fragmentation have been observed,
as one could expect. This change makes the slab allocator revert to
kernel virtual memory when allocating larger-than-page slabs. This
solution is motivated in part to avoid the complexity of other solutions
such as page mobility, and also because a microkernel cannot be extended
to new arbitrary uncontrolled usage patterns such as a monolithic kernel
with loadable modules. As such, large objects are rare, and their use
infrequent, which is compatible with the use of kernel virtual memory.
* kern/slab.c: Update module description.
(KMEM_CF_SLAB_EXTERNAL, KMEM_CF_VERIFY): Update values.
(KMEM_CF_DIRECT): Remove macro.
(KMEM_CF_DIRECTMAP): New macro.
(kmem_pagealloc_directmap, kmem_pagefree_directmap,
kmem_pagealloc_virtual, kmem_pagefree_virtual): New functions.
(kmem_pagealloc, kmem_pagefree, kmem_slab_create, kmem_slab_destroy,
kalloc, kfree): Update to use the new pagealloc functions.
(kmem_cache_compute_sizes): Update the algorithm used to determine slab
size and other cache properties.
(kmem_slab_use_tree, kmem_cache_free_to_slab, host_slab_info): Update to
correctly use the cache flags.
(slab_init): Add KMEM_CACHE_DIRECTMAP to the kmem_slab_cache init flags.
* kern/slab.h (KMEM_CACHE_VERIFY): Change value.
(KMEM_CACHE_DIRECTMAP): New macro.
* vm/vm_map.c (vm_map_init): Add KMEM_CACHE_DIRECTMAP to the
vm_map_entry_cache init flags.
|
|
Now that the slab allocator doesn't use kernel virtual memory any more,
this map has become irrelevant.
* kern/slab.c (KMEM_MAP_SIZE): Remove macro.
(kmem_map_store, kmem_map): Remove variables.
(slab_init): Remove call kmem_submap.
* kern/slab.h (kmem_map): Remove extern declaration.
|
|
Allocating directly out of the physical memory allocator makes the slab
allocator vulnerable to failures due to fragmentation. This change makes
the slab allocator use the lowest possible size for its slabs to reduce
the chance of contiguous allocation failures.
* kern/slab.c (KMEM_MIN_BUFS_PER_SLAB, KMEM_SLAB_SIZE_THRESHOLD): Remove
macros.
(kmem_cache_compute_sizes): Update the algorithm used to determine slab
size and other cache properties.
|
|
A few errors were introduced in the latest changes.
o Add VM_PAGE_WAIT calls around physical allocation attempts in case of
memory exhaustion.
o Fix stack release.
o Fix memory exhaustion report.
o Fix free page accounting.
* kern/slab.c (kmem_pagealloc, kmem_pagefree): New functions
(kmem_slab_create, kmem_slab_destroy, kalloc, kfree): Use kmem_pagealloc
and kmem_pagefree instead of the raw page allocation functions.
(kmem_cache_compute_sizes): Don't store slab order.
* kern/slab.h (struct kmem_cache): Remove `slab_order' member.
* kern/thread.c (stack_alloc): Call VM_PAGE_WAIT in case of memory
exhaustion.
(stack_collect): Call vm_page_free_contig instead of kmem_free to
release pages.
* vm/vm_page.c (vm_page_seg_alloc): Fix memory exhaustion report.
(vm_page_setup): Don't update vm_page_free_count.
(vm_page_free_pa): Check page parameter.
(vm_page_mem_free): New function.
* vm/vm_page.h (vm_page_free_count): Remove extern declaration.
(vm_page_mem_free): New prototype.
* vm/vm_pageout.c: Update comments not to refer to vm_page_free_count.
(vm_pageout_scan, vm_pageout_continue, vm_pageout): Use vm_page_mem_free
instead of vm_page_free_count, update types accordingly.
* vm/vm_resident.c (vm_page_free_count, vm_page_free_count_minimum):
Remove variables.
(vm_page_free_avail): New variable.
(vm_page_bootstrap, vm_page_grab, vm_page_release, vm_page_grab_contig,
vm_page_free_contig, vm_page_wait): Use vm_page_mem_free instead of vm_page_free_count,
update types accordingly, don't set vm_page_free_count_minimum.
* vm/vm_user.c (vm_statistics): Likewise.
|
|
In order to increase the amount of memory available for kernel objects,
without reducing the amount of memory available for user processes,
a new allocation strategy is introduced in this change.
Instead of allocating kernel objects out of kernel virtual memory,
the slab allocator directly uses the direct mapping of physical
memory as its backend. This largely increases the kernel heap, and
removes the need for address translation updates.
In order to allow this strategy, an assumption made by the interrupt
code had to be removed. In addition, kernel stacks are now also
allocated directly from the physical allocator.
* i386/i386/db_trace.c: Include i386at/model_dep.h
(db_i386_reg_value): Update stack check.
* i386/i386/locore.S (trap_from_kernel, all_intrs,
int_from_intstack): Update interrupt handling.
* i386/i386at/model_dep.c: Include kern/macros.h.
(int_stack, int_stack_base): New variables.
(int_stack_high): Remove variable.
(i386at_init): Update interrupt stack initialization.
* i386/i386at/model_dep.h: Include i386/vm_param.h.
(int_stack_top, int_stack_base): New extern declarations.
(ON_INT_STACK): New macro.
* kern/slab.c: Include vm/vm_page.h
(KMEM_CF_NO_CPU_POOL, KMEM_CF_NO_RECLAIM): Remove macros.
(kmem_pagealloc, kmem_pagefree, kalloc_pagealloc, kalloc_pagefree): Remove
functions.
(kmem_slab_create): Allocate slab pages directly from the physical allocator.
(kmem_slab_destroy): Release slab pages directly to the physical allocator.
(kmem_cache_compute_sizes): Update the slab size computation algorithm to
return a power-of-two suitable for the physical allocator.
(kmem_cache_init): Remove custom allocation function pointers.
(kmem_cache_reap): Remove check on KMEM_CF_NO_RECLAIM.
(slab_init, kalloc_init): Update calls to kmem_cache_init.
(kalloc, kfree): Directly fall back on the physical allocator for big
allocation sizes.
(host_slab_info): Remove checks on defunct flags.
* kern/slab.h (kmem_slab_alloc_fn_t, kmem_slab_free_fn_t): Remove types.
(struct kmem_cache): Add `slab_order' member, remove `slab_alloc_fn' and
`slab_free_fn' members.
(KMEM_CACHE_NOCPUPOOL, KMEM_CACHE_NORECLAIM): Remove macros.
(kmem_cache_init): Update prototype, remove custom allocation functions.
* kern/thread.c (stack_alloc): Allocate stacks from the physical allocator.
* vm/vm_map.c (vm_map_kentry_cache, kentry_data, kentry_data_size): Remove
variables.
(kentry_pagealloc): Remove function.
(vm_map_init): Update calls to kmem_cache_init, remove initialization of
vm_map_kentry_cache.
(vm_map_create, _vm_map_entry_dispose, vm_map_copyout): Unconditionnally
use vm_map_entry_cache.
* vm/vm_map.h (kentry_data, kentry_data_size, kentry_count): Remove extern
declarations.
* vm/vm_page.h (VM_PT_STACK): New page type.
* device/dev_lookup.c (dev_lookup_init): Update calls to kmem_cache_init.
* device/dev_pager.c (dev_pager_hash_init, device_pager_init): Likewise.
* device/ds_routines.c (mach_device_init, mach_device_trap_init): Likewise.
* device/net_io.c (net_io_init): Likewise.
* i386/i386/fpu.c (fpu_module_init): Likewise.
* i386/i386/machine_task.c (machine_task_module_init): Likewise.
* i386/i386/pcb.c (pcb_module_init): Likewise.
* i386/intel/pmap.c (pmap_init): Likewise.
* ipc/ipc_init.c (ipc_bootstrap): Likewise.
* ipc/ipc_marequest.c (ipc_marequest_init): Likewise.
* kern/act.c (global_act_init): Likewise.
* kern/processor.c (pset_sys_init): Likewise.
* kern/rdxtree.c (rdxtree_cache_init): Likewise.
* kern/task.c (task_init): Likewise.
* vm/memory_object_proxy.c (memory_object_proxy_init): Likewise.
* vm/vm_external.c (vm_external_module_initialize): Likewise.
* vm/vm_fault.c (vm_fault_init): Likewise.
* vm/vm_object.c (vm_object_bootstrap): Likewise.
* vm/vm_resident.c (vm_page_module_init): Likewise.
(vm_page_bootstrap): Remove initialization of kentry_data.
|
|
This change replaces the historical page allocator with a buddy allocator
implemented in vm/vm_page.c. This allocator allows easy contiguous allocations
and also manages memory inside segments. In a future change, these segments
will be used to service requests with special constraints, such as "usable
for 16-bits DMA" or "must be part of the direct physical mapping".
* Makefrag.am (libkernel_a_SOURCES): Add vm/vm_page.c.
* i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386at/biosmem.{c,h}.
* i386/i386/vm_param.h: Include kern/macros.h.
(VM_PAGE_DMA_LIMIT, VM_PAGE_MAX_SEGS, VM_PAGE_DMA32_LIMIT,
VM_PAGE_DIRECTMAP_LIMIT, VM_PAGE_HIGHMEM_LIMIT, VM_PAGE_SEG_DMA,
VM_PAGE_SEG_DMA32, VM_PAGE_SEG_DIRECTMAP, VM_PAGE_SEG_HIGHMEM): New macros.
* i386/i386at/model_dep.c: Include i386at/biosmem.h.
(avail_next, avail_remaining): Remove variables.
(mem_size_init): Remove function.
(i386at_init): Initialize and use the biosmem module for early physical
memory management.
(pmap_free_pages): Return phys_last_addr instead of avail_remaining.
(init_alloc_aligned): Turn into a wrapper for biosmem_bootalloc.
(pmap_grab_page): Directly call init_alloc_aligned instead of pmap_next_page.
* i386/include/mach/i386/vm_types.h (phys_addr_t): New type.
* kern/bootstrap.c (free_bootstrap_pages): New function.
(bootstrap_create): Call free_bootstrap_pages instead of vm_page_create.
* kern/cpu_number.h (CPU_L1_SIZE): New macro.
* kern/slab.h: Include kern/cpu_number.h.
(CPU_L1_SIZE): Remove macro, moved to kern/cpu_number.h.
* kern/startup.c (setup_main): Change the value of machine_info.memory_size.
* linux/dev/glue/glue.h (alloc_contig_mem, free_contig_mem): Update prototypes.
* linux/dev/glue/kmem.c (linux_kmem_init): Don't use defunct page queue.
* linux/dev/init/main.c (linux_init): Don't free unused memory.
(alloc_contig_mem, free_contig_mem): Turn into wrappers for the vm_page
allocator.
* linux/pcmcia-cs/glue/ds.c (PAGE_SHIFT): Don't undefine.
* vm/pmap.h (pmap_startup, pmap_next_page): Remove prototypes.
* vm/vm_fault.c (vm_fault_page): Update calls to vm_page_convert.
* vm/vm_init.c (vm_mem_init): Call vm_page_info_all.
* vm/vm_object.c (vm_object_page_map): Update call to vm_page_init.
* vm/vm_page.h (vm_page_queue_free): Remove variable declaration.
(vm_page_create, vm_page_release_fictitious, vm_page_release): Remove
declarations.
(vm_page_convert, vm_page_init): Update prototypes.
(vm_page_grab_contig, vm_page_free_contig): New prototypes.
* vm/vm_resident.c (vm_page_template, vm_page_queue_free,
vm_page_big_pagenum): Remove variables.
(vm_page_bootstrap): Update and call vm_page_setup.
(pmap_steal_memory): Update and call vm_page_bootalloc.
(pmap_startup, vm_page_create, vm_page_grab_contiguous_pages): Remove functions.
(vm_page_init_template, vm_page_grab_contig,
vm_page_free_contig): New functions.
(vm_page_init): Update and call vm_page_init_template.
(vm_page_release_fictitious): Make static.
(vm_page_more_fictitious): Update call to vm_page_init.
(vm_page_convert): Rewrite to comply with vm_page.
(vm_page_grab): Update and call vm_page_alloc_pa.
(vm_page_release): Update and call vm_page_free_pa.
|
|
* kern/log2.h: New file.
|
|
To avoid running out of memory due to the increased consumption by radix
trees which replaced arrays.
* kern/slab.c (KMEM_MAP_SIZE): Bump from 96MiB to 128MiB.
* i386/i386/vm_param.h (VM_KERNEL_MAP_SIZE): Add 32MiB accordingly.
|
|
* linux/dev/glue/block.c (out): Cast to device_t.
* linux/dev/init/main.c (alloc_contig_mem): Initialize addr and cast return value to void *.
* i386/i386/phys.c (pmap_copy_page): Initialize src_map.
* i386/intel/pmap.c: Include i386at/model_dep.h.
* kern/mach_clock.c (mapable_time_init): Cast to void *.
|
|
when backward time correction happens to get bigger than the tick duration.
* kern/mach_clock.c (clock_interrupt): When `tickdelta' is bigger than `usec',
truncate it to `usec-1'.
|
|
* kern/slab.c (_slab_info): Print total used and reclaimable memory.
|
|
* kern/slab.c (_slab_info): Include flags in the slab information.
|
|
* ddb/db_command.c (db_show_cmds): Add `slabinfo'.
* kern/slab.c (slab_info): Generalize so that it can be used with
different printf-like functions, and turn it into a static function.
(slab_info): New wrapper retaining the old behaviour.
(db_show_slab_info): New wrapper that uses `db_printf' instead.
* kern/slab.h (db_show_slab_info): New declaration.
|
|
* kern/syscall_sw.h (mach_trap_t): Turn unused field into `mach_trap_name'.
(MACH_TRAP, MACH_TRAP_STACK): Record name.
* i386/i386/debug_i386.c (syscall_trace_print): Use the name and
format the arguments to look like c.
|
|
* device/cirbuf.c: Add missing include.
* i386/i386/debug.h (dump_ss): Hide declaration from assembler.
* i386/i386/debug_i386.c: Fix include.
* kern/sched_prim.h: Add missing include, fix declaration.
|
|
* kern/bootstrap.c (boot_script_prompt_task_resume): Drop into the
debugger instead of merely waiting for return using `safe_gets', which
disables interrupts, making it impossible to break into the debugger
using the magic keys.
|
|
* 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.
|
|
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.
|
|
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.
|
|
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.
|
|
* kern/bootstrap.c (boot_script_exec_cmd): Avoid holding the lock
across the call to `thread_create'.
|
|
* kern/lock.c (simple_unlock): Really zero-out unused simple lock info
entries.
|
|
* 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.
|
|
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.
|
|
* 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.
|
|
* kern/macros.h: Avoid re-defining macros.
* linux/src/include/linux/compiler-gcc.h: Likewise.
* linux/src/include/linux/compiler.h: Likewise.
|
|
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.
|
|
* 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.
|
|
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.
|
|
* kern/bootstrap.c (boot_script_free_task): Deallocate task.
|
|
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'.
|
|
* 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.
|
|
* kern/bootstrap.c (boot_script_exec_cmd): Add missing unlock.
(user_bootstrap): Likewise.
|
|
* kern/slab.c (host_slab_info): Fix locking.
|
|
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.
|
|
* Makefile.am (clib_routines): Steal `__umoddi3'.
* kern/printf.c (MAXBUF): Increase size.
(printnum, _doprnt): Handle long long integers.
* kern/printf.h (printnum): Adjust declaration.
|
|
* kern/server_loop.ch: Remove superfluous file.
|
|
* kern/bootstrap.c (boot_script_exec_cmd): Improve error handling.
|
|
This avoids calling `thread_deallocate' with an uninitialized value,
as found by the Clang Static Analyzer.
* kern/thread.c (kernel_thread): Fix error handling.
|
|
* kern/printf.h (sprintf, snprintf, vsnprintf, printf): Add the
`printf' function attribute that allows the compiler to check the
format strings and arguments.
|
|
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.
|
|
* kern/exception.c (exception_parse_reply): Use `BAD_TYPECHECK'.
|