linux-kernel

Linux - Programmatically write to a proc file

I have found several examples online where we can create a proc file, assign read and write methods that are called every time the proc file is opened for read or written to. However, I can't seem to find any documentation on how to programatically write to a proc file. Ideally, I would like to add a timestamp with other user details ev...

Linux Kernel - Integer to ASCII

I need to convert an integer to it's ASCII representation from within the Linux Kernel. How can I do this? I can't find any built-in conversion methods. Are there any already in the kernel or do I need to add my own? ...

sendfile() usage on two mmaped files (linux)

Hello Can sendfile() linux syscall be used to send part of file from one mmaped file to other mmaped file? ...

problem in allocating kernel memory by malloc() from user space?

Is there any protection provided by kernel? Because when we tried to allocate memory using an malloc() from user space, the kernel allowed to allocated around 124 MB of memory, and when we try to write into it, the kernel crashed. If there was protection of kernel memory area, this wouldn't have happened ...

Do the changes to cpumask using sched_setaffinity() take place immediately

I am writing a linux kernel module that needs to pin two threads on two different cpus. I am planning to use sched_setaffinity() after exporting it in the kernel. Is there any other exported function for the same ? Also, if I set only 1 CPU in the cpumask, will the thread be moved to that cpu with immediate effect ? If not, how do I en...

spin_lock_irqsave vs spin_lock_irq

On a SMP machine we must use spin_lock_irqsave and not spin_lock_irq from interrupt context. Why would we want to save the flags (which contains the IF)? Is there another interrupt routine that could interrupt us? ...

Microsecond (or one ms) time resolution on an embedded device (Linux Kernel)

Hey guys, I have a kernel module I've built that requires at least 1 ms time resolution. I currently use do_gettimeofday() but I'm concerned that this won't work once I move my module to an embedded device. The device has a 180 Mz processor (MIPS) and the default HZ value in the kernel is 100. Thus using jiffies will only give me at bes...

Kernel - Finding written block numbers

Is there any way in the kernel to get a list of blocks that have been physically written to and the order in which they were written? ...

barriers in SMP linux kernel

Hello Is there smth like pthread_barrier in SMP Linux kernel? When kernel works simultaneously on 2 and more CPUs with the same structure, the barrier (like pthread_barrier) can be useful. It will stop all CPUs entering to it until last CPU will run the barrier. From this moment all CPUs again works. ...

How can I get page faults statistics from kernel

Hello How can I get page faults statistics from kernel for my application while it is running? What about other events, like inter-cpu migrations count in SMP nodes, or number of context switches? I want to count such events for various small parts of the program. Thanks. ...

Linux Kernel - Get last written memory block

In the linux kernel, are there any data structures that automatically always hold the last written block number for a partition? I can't find any built-in kernel source that could be used to get this information. Any help is appreciated. ...

setitimer, SIGALRM & multithread process (linux, c)

Hello I want to use setitimer() (or alarm()) in multithreaded process in linux 2.6+ with NPTL-enabled libc. Which thread will receive sigalarm (SIGALRM) from kernel? Thanks. ...

Setting terminal flags through kernel parameters in linux

Can we set terminal flags through kernel command line ? ...

how to acess and change variable of kernel space from user space

i, I have posted query previously and i am repeating same I want to modify igmpv3 (Linux) which is inbuilt in kernel2.6.-- such that it reads a value from a file and appropriately decides reserved(res 1) value inside the igmpv3 paket which is sent by a host. I want to add more to above question by saying that this is more a generic q...

userspace to kernel space and sysfs and how to use sysfs to change one reservered value in igmpv3 pkt.

I have posted query previously and i am repeating same I want to modify igmpv3 (Linux) which is inbuilt in kernel2.6.-- such that it reads a value from a file and appropriately decides reserved(res 1) value inside the igmpv3 paket which is sent by a host. I want to add more to above question by saying that this is more a generic questio...

Linux Kernel - programmatically retrieve block numbers as they are written to

I want to maintain a list of block numbers as they are physically written to using the linux kernel source. I plan to modify the kernel source to do this. I just need to find the structure and functions in the kernel source that handle writing to physical partitions and get the block numbers as they write to the physical partition. Any ...

Linux Kernel - Where in the kernel are blocks of data physically written to specific disk partitions?

I'm modifying the Linux kernel and am trying to find where in the kernel source blocks of data are physically written to disk partitions such as ubd0. Where does this occur in kernel source? The actual physical write call? I cannot find this. Thanks! Edit: The end goal is a list of block numbers that have been written to a few different...

Why can't I register edge triggered interrupts in Linux 2.6.26?

Howdy All, First time poster, so please excuse any stupidity. I'm working on porting a custom CPLD driver on a linux kernel built for an MPC83xx from 2.6.22 to 2.6.26, and am receiving an unexpected Oops. The driver works fine for the .22 kernel, but the .26 kernel chokes on my call to request_irq. Does anybody know why there was a cha...

Interpreting kernel message: "page allocation failure. order:1"

What is the correct interpretation of the following kernel error message: [N] swapper: page allocation failure. order:1, mode:0x20 [N] Pid: 0, comm: swapper Not tainted 2.6.x #15 Is the error fatal (similar to an OOM-kill) or is it just a warning message? ...

Inode to device information

I have 3 questions: I want to figure out if a file belongs to a USB device given the file inode. By looking in the latest kernel sources (2.6.33) on LXR, I think one can find that information by following pointers as follows: inode->super_block->block_device->backing_dev_info->device->device_driver(or device_type). However, the kernel ...