Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| drivers [2018/02/16 17:12] – [Interrupts] admin | drivers [2018/05/18 09:53] (current) – [Debugging] admin | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| * kmalloc is the primary allocator in the Linux kernel, for objects from 8 bytes to 128KB. The allocated area is guaranteed to be physically contiguous. | * kmalloc is the primary allocator in the Linux kernel, for objects from 8 bytes to 128KB. The allocated area is guaranteed to be physically contiguous. | ||
| * vmalloc provides virtually contiguous memory zones that may not be physically contiguous. The resulting virtual addresses are higher than the top of physical memory. vmalloc cannot be used when the real physical address is needed, e.g. for DMA, and cannot be used at interrupt time. Allocation of large areas is possible, since physical memory fragmentation is not an issue. | * vmalloc provides virtually contiguous memory zones that may not be physically contiguous. The resulting virtual addresses are higher than the top of physical memory. vmalloc cannot be used when the real physical address is needed, e.g. for DMA, and cannot be used at interrupt time. Allocation of large areas is possible, since physical memory fragmentation is not an issue. | ||
| + | * kzalloc | ||
| + | * kcalloc | ||
| + | * dma_alloc_coherent | ||
| + | * dma_alloc_sg | ||
| + | * contiguous memory algorithms (CMA, ION) | ||
| Debugging features: | Debugging features: | ||
| Line 24: | Line 29: | ||
| An issue with I/O memory accesses is memory reordering, which may require memory barriers (rmb(), wmb(), mw()). | An issue with I/O memory accesses is memory reordering, which may require memory barriers (rmb(), wmb(), mw()). | ||
| + | ===== User space memory handling ===== | ||
| User-space applications can access physical addresses directly through /dev/mem. | User-space applications can access physical addresses directly through /dev/mem. | ||
| + | |||
| + | * Process heap (sbrk, brk) | ||
| + | * Direct/ | ||
| + | * Allocators (malloc, calloc, realloc, free) | ||
| + | |||
| ====== Modules ====== | ====== Modules ====== | ||
| Line 79: | Line 90: | ||
| * Bottom half, implemented the available work deferring mechanisms: | * Bottom half, implemented the available work deferring mechanisms: | ||
| * SoftIRQs, executed with all i/r enabled. **They run in interrupt context.** A softirq handler can run simultaneously on multiple CPUs. They are executed once all i/r handlers have completed, before the scheduler resumes (sleeping not allowed). HI and TASKLET softirqs are used to execute tasklets. | * SoftIRQs, executed with all i/r enabled. **They run in interrupt context.** A softirq handler can run simultaneously on multiple CPUs. They are executed once all i/r handlers have completed, before the scheduler resumes (sleeping not allowed). HI and TASKLET softirqs are used to execute tasklets. | ||
| - | * Tasklets, executed with all i/r enabled. **They run in interrupt context.** A taklet is guaranteed to execute on a single CPU at a time. Implemented as a function, and easily usable by individual device drivers. The interrupt handler can schedule the execution of a tasklet with tasklet_schedule() or tasklet_hi_schedule(). | + | * Tasklets, executed with all i/r enabled. They are built on top of softirqs. **They run in interrupt context.** A taklet is guaranteed to execute on a single CPU at a time. Implemented as a function, and easily usable by individual device drivers. The interrupt handler can schedule the execution of a tasklet with tasklet_schedule() or tasklet_hi_schedule(). |
| * Workqueues, not limited to handling interrupts. **They run in process context (kernel thread).** All i/r enabled, and sleeping is allowed. A workqueue is registered with INIT_WORK and triggered with queue_work(). | * Workqueues, not limited to handling interrupts. **They run in process context (kernel thread).** All i/r enabled, and sleeping is allowed. A workqueue is registered with INIT_WORK and triggered with queue_work(). | ||
| Line 98: | Line 109: | ||
| Threaded interrupts are executed inside a thread (allows to block inside the handler). There is support for interrupt handler execution priority. | Threaded interrupts are executed inside a thread (allows to block inside the handler). There is support for interrupt handler execution priority. | ||
| + | |||
| + | UIO allows the handling from interrupt in user space. | ||
| ====== Concurrency ====== | ====== Concurrency ====== | ||
| The kernel lock validator is an useful tool to detect violations of locking rules during system life. Alternatives to locking are the use of lock-free algorithms (e.g. read copy update, RCU) or atomic operations (.e.g. atomic_set/ | The kernel lock validator is an useful tool to detect violations of locking rules during system life. Alternatives to locking are the use of lock-free algorithms (e.g. read copy update, RCU) or atomic operations (.e.g. atomic_set/ | ||
| + | ===== Semaphores ===== | ||
| ===== Mutexes ===== | ===== Mutexes ===== | ||
| Line 127: | Line 141: | ||
| * Kernel markers | * Kernel markers | ||
| * LTTng with LTTV | * LTTng with LTTV | ||
| + | * printk | ||
| + | * kernel configs | ||
| + | * debugfs/ | ||
| + | * ftrace | ||
| + | * Kdb | ||
| + | * Kgdb | ||
| + | * jtag + gdb | ||
| + | * emulation (QEmu) | ||
| + | Userspace: | ||
| + | * printf | ||
| + | * strace | ||
| + | * ltrace | ||
| + | * valgrind | ||
| + | * gdb | ||
| ====== Userspace drivers ====== | ====== Userspace drivers ====== | ||
| http:// | http:// | ||