linux-kernel

How to change linux kernel process priority in programmatic way?

我与影子孤独终老i 提交于 2021-01-29 07:38:39
问题 I found some function 'renice' that changes the nice value of process. But I want to know how to change priority in kernel code . Is it okay that just changing the priority value in sched_entity of process? 回答1: If you want to change the niceness of the process programmatically, I would advise against setting these values in the kernel struct directly. Instead, you can utilize several POSIX functions such as setpriority or pthread_setschedparam . The default scheduler policy on Linux is SCHED

How to change linux kernel process priority in programmatic way?

大兔子大兔子 提交于 2021-01-29 07:37:40
问题 I found some function 'renice' that changes the nice value of process. But I want to know how to change priority in kernel code . Is it okay that just changing the priority value in sched_entity of process? 回答1: If you want to change the niceness of the process programmatically, I would advise against setting these values in the kernel struct directly. Instead, you can utilize several POSIX functions such as setpriority or pthread_setschedparam . The default scheduler policy on Linux is SCHED

Access and use the values of the accelerometer in the Android kernel level

杀马特。学长 韩版系。学妹 提交于 2021-01-29 06:24:05
问题 How can I access the accelerometer in the android kernel space and use it's data? I'm working on a project where I need to control some of the phone's functionality while the phone is moving (in a car) and I want to use the accelerometer to help determine if the phone had accelerated. It has to all be done in the kernel space. I found on the android developer pages how to use the accelerometer and the SensorEvent to detect changes in a user level application. But how to do something like that

Unreadable content of 'pathname' parameter in 'mkdir()' system call after inline hooking

蓝咒 提交于 2021-01-29 06:13:57
问题 I'm trying inline hooking system calls. The hook function is like this: asmlinkage long hooked_mkdir(const char __user *pathname, umode_t mode) { static char *msg = "hooked sys_mkdir(), mkdir name: "; printk("%s%s", msg, pathname); //print hex content to check bug. int i; for (i = 0; pathname[i] != '\0'; i++) { printk("\\x%x", pathname[i]); } return old_mkdir(pathname, mode); } Now I mkdir 3 directories named 111 , 222 and 333 . The syscalls were made successfully. However, the pathname is

Linux Kernel generate compile-commands.json for module

廉价感情. 提交于 2021-01-29 05:23:00
问题 The problem : Most of macro definition and even header files are not looked up by an IDE because include path is not specified in the IDE configuration. It inhibits autocompletion and navigation. Here is my Makefile : #-Wno-declaration-after-statement ccflags-y := -std=gnu11 -Wno-declaration-after-statement -Werror obj-m += pfsw.o pfsw-objs := src/init.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean I ran

Confusion about syn queue and accept queue

断了今生、忘了曾经 提交于 2021-01-28 20:04:40
问题 When reading TCP source code, I find a confused thing: I know TCP has two queues in 3 way handshake: The first queue stores connections which server has received the SYN and send back ACK + SYN , which we call as syn queue . The second queue stores the connections that 3WHS are successful and connection established, which we call as accept queue . But when reading codes, I find listen() will call inet_csk_listen_start() , which will call reqsk_queue_alloc() to create icsk_accept_queue . And

How to use Zero-copy sendmsg/Receive in Boost.Asio [closed]

六月ゝ 毕业季﹏ 提交于 2021-01-28 11:21:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . Improve this question I am using Boost.Asio, I want to improve my system by using Zero-copy sendmsg/Receive. Can I use Zero-copy sendmsg/Receive in Boost.Asio? Could you give me how to use them if I can use them? 回答1: Short answer, you can only if your in-memory representation

ARM64 - Linux Memory Write protection won't disable

喜你入骨 提交于 2021-01-28 09:51:53
问题 i'm trying to disable the Memory Write protection on an ARM64 system from within an LKM. (Startet in the DOM0 of the Xen hypervisor) I found the corresponding PTE to an virtual address by using the Linux Kernel Functions. pgd_t *pgd; pte_t *ptep, pte; pud_t *pud; pmd_t *pmd; pgd = pgd_offset(init_mm, (addr)); if (pgd_none(*pgd) || pgd_bad(*pgd)) goto out; printk(KERN_NOTICE "Valid pgd 0x%lx\n",pgd); pud = pud_offset(pgd, addr); if (pud_none(*pud) || pud_bad(*pud)) goto out; printk(KERN_NOTICE

How to get a Linux panic output to a USB serial console when system has also a display adapter

房东的猫 提交于 2021-01-28 08:29:39
问题 I am having troubles with a Linux kernel panic which I need to investigate further. When it happens, the kernel panic output always goes to the display adapter only and is shown on the monitor. I need to have the kernel panic output to a serial USB console, not only on the display adapter. In the situation where the panic happens there is no monitor available. I have a serial USB console working, can log in from there and I also see some kernel messages there sometimes. However when I provoke

wait_event and lock interaction

倾然丶 夕夏残阳落幕 提交于 2021-01-28 05:09:22
问题 I'm new to linux kernel development and wonder how wait_event/wait_event_interruptible interacts with other locking primitives in the kernel. I'm used to C++ std::condition_variable::wait and want to achieve something similar in the kernel. I have a queue of receive buffers which are filled using DMA transfers. The list is protected using a spin lock. Finished buffers are added by the DMA finished soft IRQ. I created a character device which allows reading of the finished buffers. So far this