kernel-module

How to recompile just a single kernel module?

十年热恋 提交于 2020-01-11 15:04:30
问题 Usually kernel source are stored in /usr/src/linux-2.6.x/ . To avoid to recompile the entire kernel if I modify a module's source, how can I recompile just that module? 回答1: Switch to the root directory of your source tree and run the following command: $ make modules SUBDIRS=drivers/the_module_directory And to install the compiled module: $ make modules_install SUBDIRS=drivers/the_module_directory Note: As lunakid mentions, the latter command might not build the module first, so be careful.

How to recompile just a single kernel module?

女生的网名这么多〃 提交于 2020-01-11 15:04:21
问题 Usually kernel source are stored in /usr/src/linux-2.6.x/ . To avoid to recompile the entire kernel if I modify a module's source, how can I recompile just that module? 回答1: Switch to the root directory of your source tree and run the following command: $ make modules SUBDIRS=drivers/the_module_directory And to install the compiled module: $ make modules_install SUBDIRS=drivers/the_module_directory Note: As lunakid mentions, the latter command might not build the module first, so be careful.

How to find physical and logical core number in a kernel module?

故事扮演 提交于 2020-01-11 08:16:28
问题 Are there kernel functions in Linux that would return the number of the physical core and logical core (in case of Hyperthreading) on which a kernel module is running ? 回答1: Have a look at the end of include/linux/smp.h : smp_processor_id() gives you the number of the current executing CPU. get_cpu() will do the same and will also disable preemption so that you will stay on that CPU until put_cpu() is called. From user-space, you can use sched_getcpu() or getcpu() to obtain the same

How to find physical and logical core number in a kernel module?

眉间皱痕 提交于 2020-01-11 08:16:18
问题 Are there kernel functions in Linux that would return the number of the physical core and logical core (in case of Hyperthreading) on which a kernel module is running ? 回答1: Have a look at the end of include/linux/smp.h : smp_processor_id() gives you the number of the current executing CPU. get_cpu() will do the same and will also disable preemption so that you will stay on that CPU until put_cpu() is called. From user-space, you can use sched_getcpu() or getcpu() to obtain the same

Write module of kernel (Linux), which to save the page of process from removing to the swap

て烟熏妆下的殇ゞ 提交于 2020-01-06 19:59:09
问题 Need to save the page of process (the user part!) from removing to the swap. I need to do it in the kernel, only. (language C I know) (Maybe insert hook in shrink_page_list?) I have IDs of processes, which need to save and threshold amount of physical memory in the system (We fill, while it isn't filled). IDs and threshold write in /proc, /dev or /sys. How to approach this? What files to look at? What tutorials to read? Maybe there are examples that are somehow are related with this task.

Linux Kernel Check VID / PID Number?

随声附和 提交于 2020-01-06 14:06:16
问题 What I am looking for is the command to check the live USB disks serial number from within a kernel module. from within the kernel, lsusb won't work. TMI Clause: I am developing a live USB device for a client, and this will be a current part of our copy protection. 回答1: Your program would be querying the serial number via the operating system. And you know what, your client has the ability to alter the operating system, so your program would not be able to completely trust the information

why does `synchronize_rcu()` not deadlock when beening called inside a read lock block?

安稳与你 提交于 2020-01-06 09:06:42
问题 synchronize_rcu() is used to waits only for ongoing RCU read-side critical sections to complete. If so, it should been blocked forever when beening called inside a read block. However, the following code works well on my linux kernel, why? void port_range_clean( void ) { struct port_range *p; redo: rcu_read_lock(); list_for_each_entry_rcu(p, &port_rt->ports, list) { list_del_rcu(&p->list); synchronize_rcu(); rcu_read_unlock(); kfree(p); goto redo; } } 来源: https://stackoverflow.com/questions

why does `synchronize_rcu()` not deadlock when beening called inside a read lock block?

删除回忆录丶 提交于 2020-01-06 09:05:21
问题 synchronize_rcu() is used to waits only for ongoing RCU read-side critical sections to complete. If so, it should been blocked forever when beening called inside a read block. However, the following code works well on my linux kernel, why? void port_range_clean( void ) { struct port_range *p; redo: rcu_read_lock(); list_for_each_entry_rcu(p, &port_rt->ports, list) { list_del_rcu(&p->list); synchronize_rcu(); rcu_read_unlock(); kfree(p); goto redo; } } 来源: https://stackoverflow.com/questions

ENFILE, File table overflow, when using kernel iterate_dir

 ̄綄美尐妖づ 提交于 2020-01-05 04:39:08
问题 I recently started with system programming and was wondering how iterate_dir works. I have written something and I can't figure out why I get errors. My code starts to fail at about 190k-210k iterations. struct dir_context context2 = { actor2, 0 }; for (i = 0; i < 1000000; i++) { file = filp_open("/", O_RDONLY, 0); if (IS_ERR(file)) { printk(KERN_ALERT "ERR: %d", file); break; } if (iterate_dir(file, &context2)) { printk(KERN_ALERT "iterate_dir failed"); break; } filp_close(file, 0); } The

Create sysfs entry from kernel module

蹲街弑〆低调 提交于 2020-01-02 09:09:23
问题 I want to pass a string > 1024 chars to my module (filesystem). As kernel parameters are limited to 1024 chars, someone recommended to use sysfs instead. I tried to include this example in my super.c class to create a string 'filename' & string 'code' entry in sysfs for my module. static decl_subsys(myfs, NULL, NULL); struct myfs_attr { struct attribute attr; char *value; }; static struct myfs_attr fname = { .attr.name="filename", .attr.owner = THIS_MODULE, .attr.mode = 0644, .value = "/my