Building off of this, I would like to change process priorities based on RAM usage. I’m perfectly aware that this isn’t always the best way to change priorities, but this is just for a project. I’m trying to use renice and execvp to set process priorities. The problem is that I want to launch renice with additional parameters to change
Tag: linux-kernel
Is there a different memory allocation path other than the buddy allocator in linux?
I’m understanding memory allocation in Linux and doing some changes in buddy allocator (__alloc_pages_nodemask) for my experiments. I create a new flag in struct page->flags (by adding a new flag in enum pageflags in page-flags.h. I set this bit permanently in __alloc_pages_nodemask (to not to be cleared once set and survive all further allocation and freeing. I modify PAGE_FLAGS_CHECK_AT_PREP to
why module_param_hw( ) macro is more secure than module_param( )?
I’m starting to learn kernel modules programming. To pass any parameter to the kernel module you use module_param( ) macro which i guess work something like dynamic linking method in user space (deffer symbols relocation to run time by kernel modules loader) you can correct me if I’m wrong. Anyways, module_param() takes a permission parameter to specify the read write
How to show hidden sysctl tunable?
I’m on a Yocto Linux distribution and I need to set the sysctl tunable kernel.panic_on_rcu_stall to 1. The problem is when I list the elements inside /proc/sys/kernel I have no panic_on_rcu_stall and if I try to set the option anyway I get the folowing error: I know that the key exist, we can see it on the Linux Kernel documentation,
Is it possible to add a customized name for the (non file-backed) mmap region?
Just curious whether it is possible to specify a name for the non file-backed mmap region? Some thing like the [New VMA area] in the following example: Answer The content of maps comes from the show_map_vma function in fs/proc/task_mmu.c. Looking at it, if you want a custom name for a non-file-backed mapping, it’d need to come from either vma->vm_ops->name or
Should I release data after the use of get_user_pages_fast?
I’m using the get_user_pages_fast, which I allocate a memory buffer in the user and create a pages in the kernel space. Should I free the struct pages** after the use this memory? or call to specific release function? Thanks! Answer From documentation on get_user_pages() (which has similar functionality, but with more parameters, and needs a semaphore held): Each page returned
Determining filesystem for block device if module not loaded
I’ve been wondering this for a while now. When using Linux and plugging in an e.g. USB stick or external storage device via USB, how does the kernel determine which filesystem is on that device, if the correct module is not currently loaded in memory? Assume that the external storage device is ext4 formatted. At the time of plugging in
How to use system() in a kernel module as stdlib.h cannot be used in a kernel program?
When developing a kernel module in Linux, using the C standard library isn’t allowed. However, in case I need to use some common functionality like system(), how do I implement this? Answer The answer is: you don’t. There are very, very few instances in which you would need to do something similar to system(), that is to call a user-space
“add-symbol-file” can’t recognize .bss & .data symbols when using kgdb to debug kernel modules
I am trying to use gdb 8.3.1 for the kernel module on RPI-4 board. When I use the command add-symbol-file to add .bss and .data sections, it doesn’t work. The Kernel version is 5.4 and CONFIG_DEBUG_INFO is turned on. I list the simple code, dmesg and kgdb info below. If you have any idea, please give me some advice. Module
What instruction does Linux use to direct Intel CPU to setup a DMA transfer?
I know there are kernel apis that device drivers can use to set the transfer direction, count etc., but I would like to understand what CPU instruction does the api use to inform cpu to initiate this DMA transfer? Answer For most cases each device has its own DMA/bus mastering abilities built into the device; and the device driver uses