FAQ Database Discussion Community


How does the Linux kernel “listen” to the C library?

c,linux-kernel,system-calls,userspace
I'm trying to build up a "big picture" of how things work in the Linux kernel and userspace, and I'm quite confused. I know that userspace make use of system calls to "talk" to the kernel, but I don't know how. I tried to read the C library and kernel...

Traversing `vm_area_struct`'s of a process

c,linux,linux-kernel,filesystems,mmap
As an extension of an answer to Traversing all the physical pages of a process and data here http://www.makelinux.net/ldd3/chp-15-sect-1, I had a small question. In the first answer as suggested to traverse the physical pages of a process, struct vm_area_struct *vma = 0; unsigned long vpage; if (task->mm && task->mm->mmap)...

Where to find vma->fault()?

linux-kernel,memory
I understand vma->fault() will take two arguments which are vma and vmf. But I am not sure what vma->fault() will do inside of itself because I cannot find the code or document that talks about the initialization of this field in vm_area_struct->vm_ops->fault().

Do concurrency issues in kernel happen when using single core processor?

concurrency,linux-kernel,multicore
When a kernel is compiled on a multicore system, there will be multiple threads or processes operating simultaneously. So, concurrency problem will be an issue. However, when there is only one core in the processor. will it still be a problem?...

perf : How to check processess running on particular cpu

linux,linux-kernel,perf
Is there any option in perf to look into processes running on a particular cpu /core, and how much percentage of that core is taken by each process. Reference links would be helpful....

How to use macbook storage space for linux kernel development from other linux machine?

osx,git,ubuntu,linux-kernel,storage
I have Macbook pro and HP Compaq mini(running ubuntu 14.04, used for testing custom kernel). Now what I need is, I want to have the whole linux source in macbook storage but need to work on that source from linux machine( HP Compaq in my case). So if something goes...

Sofware pwm as linux kernel module

c,linux,linux-kernel,embedded,pwm
I need to implement PWM-module for linux kernel, it should be high resolution ( will be cool more than 10kHz on my 400MHz ARM cpu) Can anyone give me an advice, what I can use for that purpose? Kernel version is 2.6.28.9. Device hasn't a harware PWM driver. Now I...

Can't access the open /arch/x86/syscalls/syscall_32.tbl

linux-kernel,syscall
As i'm writing this command after i shift to the kernel. When i compile it, it wasn't showing any list.Is there any other command to open the list ? open /arch/x86/syscalls/syscall_32.tbl ...

Would tail block appending to file in linux kernel?

linux,file,file-io,io,linux-kernel
We have two processes: Append to the log file Tail the log file and send it to the centralised monitor My concern is if the process 2 would block process 1 during reading the file? Is there any lock contention in kernel/disk driver here?...

why it is not wise to check -ENODEV for debugfs api

linux-kernel
debugfs api such as debugfs_create_dir said If debugfs is not enabled in the kernel, the value -ENODEV will be returned. It is not wise to check for this value, but rather, check for NULL or !NULL instead as to eliminate the need for #ifdef in the calling code. But why...

Compile a linux 2.6 kernel module with newer compiler

c,gcc,linux-kernel
I build embedded machines that run an RT_PREMPT version of Linux. It's an Ubuntu 10.04 installation running an Linux 2.6 kernel. Yes, it's an old kernel, but I'm stuck with it for awhile. When I compiled the kernel, I used gcc version 4.4. On this system, there is a kernel...

When to Update ALSA Audio Driver Buffer Pointer

linux-kernel,usb,linux-device-driver,alsa
I am writing an USB Audio Playback driver using ALSA APIs. For that I was trying to understand existing audio drivers in Linux kernel. But I get confused on when to update the kernel audio buffer pointer. We know kernel puts new audio data in a ring buffer and our...

Infinite loop when I read from /proc which is implemented with seq_file

linux,linux-kernel,filesystems
I wrote a simple code snippet to learn the usage of /proc file system. When I finished, everything is ok except the reading from this file causes an infinite loop. Some codes show below: static struct seq_operations proc_seq_ops = { .start = proc_seq_start, .next = proc_seq_next, .stop = proc_seq_stop, .show...

Add module to angstrom kernel

linux,linux-kernel,angstrom-linux
I'm working on the Altera cyclone V Soc FPGA Dev Kit. I'm using the GSRD 14.1 Angstrom provides by rocketboards.com (http://www.rocketboards.org/foswiki/Documentation/GSRD141AngstromGettingStarted) [email protected]_cyclone5:~# uname -a Linux socfpga_cyclone5 3.10.31-ltsi This kernel don't support usb serial device and I think that I need to add usbserial and maybe usbcore drivers to communicate with...

Measure memory usage of a certain Linux driver module

memory,memory-leaks,linux-kernel,linux-device-driver
I want to check whether the kernel driver module which I just finished has a memory leak problem. But I don't know how to do it in kernel space. Dynamic memory allocation is very hard to handle I think. Anyone has the experience in debugging such memory problem in kernel...

Calling complete() on automatic variable of type struct completion defined in “waiting” thread

linux-kernel,linux-device-driver
I try to understand use of completion in a piece of code. Basically, one kernel thread creates automatic variable struct completion which is, I assume, allocated on the thread's stack. Then it pushes pointer of the completion struct to another thread (using fifo) and waits for completion. struct completion done;...

Linux Device Tree (DTS): i2c device on USB-I2C bridge

linux-kernel,device-tree
I have an i2c device (touch controller). Usually I would add it to the .dts file like this when it is connected to the SoC i2c master (a tegra chip in my case): [email protected] { st1332: [email protected] { compatible = "sitronix,st1232"; reg = <0x55>; interrupt-parent = <&gpio>; interrupts = <189...

Does int 80h interrupt a kernel process?

c,linux,assembly,linux-kernel
First some background knowledge, this is from the book: Linux System Programming: Talking Directly to the Kernel and C Library Signals are a mechanism for one-way asynchronous notifications. A signal may be sent from the kernel to a process, from a process to another process, or from a process to...

Using strsep in kernel space to separate a string

c,string,linux-kernel,kernel
I'm trying to separate a string based on some delimeter in a kernel module. I'm trying to use the strsep() function, but when I try to use it my kernel crashes. Can someone identify the bug in the code below? char *test = "test1:test2:test3"; char *token = test; char *end...

OpenWRT make is failing because kernel is asking for config options interactively

linux-kernel,openwrt
I am on the chaos calmer repo and I have a custom kernel configuration that I need used. The kernel configuration file is located at /opt/OpenWRT/target/linux/x86/config-3.18 I've tried running make kernel_oldconfig, but that does not solve the issue. I've tried running make kernel_menuconfig and that fails to rectify the problem...

Intercept ELF loader in linux kernel: fs/binfmt_elf.c file via loadable kernel module

c,linux-kernel,kernel,kernel-module,elf
I am new to kernel coding and at present I am working with ELF files which have been modified a little bit for the security purposes for which I need to look at some of it's custom section headers and extract the unique code encryption key from it for the...

how to get a clock from a device tree node

c,linux-kernel,embedded,linux-device-driver,device-tree
I have the following issue: I want to define the clock a CPU should use during frequency transitions in the device tree rather than in the clock driver code (in this way it will be more generic). I want to define the "transition-clock" property in the device tree, something like:...

Buildroot custom kernel under 1MB

linux,linux-kernel,kernel,buildroot
I am trying to build minimal kernel under 1 Mb with Buildroot. It is intended for small board with qspi memory and basic functionality, ethernet, usb, spi, and some GPIO's. Basic terminal access via ssh and UART. My first thoughts are if it is even possible to modify kernel .config...

How to add poll function to the kernel module code?

linux,linux-kernel,driver
as I know, to inform the user space from kernel space, one way is to using poll. That means kernel driver should provide poll method first. Below code is found from internet, and it really works! #include <linux/module.h> #include <linux/kernel.h> #include <linux/proc_fs.h> #include <linux/string.h> #include <linux/vmalloc.h> #include <asm/uaccess.h> MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Fortune...

Why do we have memory zones in linux?

linux-kernel,virtualization,intel
I was reading this on a page that: Because of hardware limitations, the kernel cannot treat all pages as identical. Some pages, because of their physical address in memory, cannot be used for certain tasks. Because of this limitation, the kernel divides pages into different zones. I was wondering about...

Raspberry Pi C++ Header Documentation

c++,linux,linux-kernel,raspberry-pi,embedded-linux
Is there some sort of documentation for what kind of headers you can include in c++ files when writing programs for Raspberry Pi or linux in general? For instance I found this great guide on how to access the SPI bus from the Pi using c++ (http://hertaville.com/2013/07/24/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c/) I was able...

Eudyptula-Challenge and kernel path

makefile,linux-kernel
I have decided to take the Eudyptula-Challenge. After I submitted the first task which is to build a simple "Hello World!" module, I received the following answer. Please read the requirements for the Makefile and allow the module to be built against any kernel source tree on the filesystem, not...

How to cross-compile asterisk with dahdi already cross-compiled for arm?

linux-kernel,arm,cross-compiling,asterisk
I'm trying to cross-compile asterisk for ARM. Everything's fine when I cross compile mandatory modules like sqlite3, ncurses and openssl and then including them when cross-compiling asterisk with their respective option --with-sqlite3, --with-ncurses --with-crypto and --with-ssl. But when I tried to include dahdi, nothing came true. This happened when --with-dahdi=$(DAHDI_DIR)/linux:...

Are PCIe device drivers beneficial if using Linux as a bootloader for bare-metal code?

linux-kernel,embedded-linux,bootloader,pci-e,bare-metal
I am developing an embedded system on a PowerPC processor and there is need for communication with an FPGA via PCIe. I wish to use Linux/embedded-Linux as a bootloader to leverage its PCIe initialization code and driver API for simplified PCIe driver development. However in the end I want to...

Kernel task_struct & siblings pointers

c,linux,list,linux-kernel,kernel
I have a question regarding the task_struct lists. /* * pointers to (original) parent process, youngest child, younger sibling, * older sibling, respectively. (p->father can be replaced with * p->p_pptr->pid) */ task_t *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr; I'm using these pointers to run through process's children. What I don't understand...

How to get lid state using linux kernel module?

linux,linux-kernel,linux-device-driver
I can read the status of my laptop lid by reading /proc/acpi/button/lid/LID0/state file. Now I want to read it from kernel module. I found the source file drivers/acpi/button.c in kernel source. But still I didn't understand how to use it. It exporting acpi_lid_notifier_register, acpi_lid_notifier_unregiste and acpi_lid_open functions. How to write...

Memory Allocation in Linux Kernel

linux,memory,memory-management,linux-kernel,memory-alignment
I had an interview today and was asked this question. What Kernel Memory allocation strategy would you use, if you were asked to allocate memory of size 2KB and that allocated memory should be page aligned. KMALLOC handles smaller memory allocation strategies but the lowest unit that it supports is...

How to join a thread in Linux kernel?

linux,multithreading,linux-kernel
The main question is: How we can wait for a thread in Linux kernel to complete? I have seen a few post concerned about proper way of handling threads in Linux kernel but i'm not sure how we can wait for a single thread in the main thread to be...

Linux: how to disable Intel DPST (Display Power Saving Technology) - i915 driver

android,linux-kernel,linux-device-driver
I have an Android tablet (Teclast X98) with an extremely annoying feature that it constantly keeps adjusting the brightness of the display all by itself. Initially I thought maybe the tablet has a faulty display unit - the pumping of the brightness is that annoying. After a lot of investigation...

Why Device Tree Structure (DTS) file is needed both in bootloader and kernel source code?

linux-kernel,arm,embedded-linux,u-boot,device-tree
Bootloaders like U-Boot that do not implement the Open Firmware API, are expected to pass to the kernel a binary form of the flattened device tree - LinuxFDTBlob Why are the DTS files present in the kernel as well? Isn't that redundant? As an example, U-boot source code has...

Can I pass a pointer to linux kernel space for a __user parameter?

c,pointers,linux-kernel
I've read about the __user specifier in the Linux kernel being used to tag function parameters for Sparse to check function arguments. In particular, given int foo1( char * buf ); one must not pass a pointer to user space for buf. How about the other way round? In int...

I2C Symbolic Link

c,linux-kernel,i2c,device-tree
In linux you are able to use the ln command to link files/folders together to create symbolic files/folders. Is there a way to do the same thing but with i2c master addresses. Ex: i2c-this -> i2c-06 So that when my code calls on "i2c-this", the address "i2c-06" is the one...

How to share same header files between kernel modules and userspace applications.

linux-kernel,macros,linux-device-driver,header-files,ioctl
I want to implement a simple module in which an ioctl() method is used. In the kernel module, I use kernel macros, such as _IO(), _IOWR(), etc., to define my own ioctl sub-commands. In facts, I don't care the actual values of these definitions for that I will always use...

function of rdi register during sys_exit syscall

assembly,linux-kernel,x86-64,syscall
I have isolated the sys_exit call to the following instruction on my machine xorq %%rdi, %%rdi /* return value */ movq $60, %%rax syscall What is the purpose of the rdi resister in this case? What is this sys call expected to return? ...

Driver mmap operation Page table creation

linux-kernel,linux-device-driver,mmap,virtual-memory,page-tables
I am trying to understand mmap operation in a driver. I know why we are doing mmap. I am confused with the following 2 implementations of mmap: int my_mmap(struct file *filp, struct vm_area_struct *vma) { vma->vm_ops = &mmap_vm_ops; vma->vm_flags |= VM_RESERVED; /* assign the file private data to the vm...

difference between the function performance when passing parameter as compile time constant or variable

c,linux,gcc,optimization,linux-kernel
In Linux kernel code there is a macro used to test bit ( Linux version 2.6.2 ): #define test_bit(nr, addr) \ (__builtin_constant_p((nr)) \ ? constant_test_bit((nr), (addr)) \ : variable_test_bit((nr), (addr))) where constant_test_bit and variable_test_bit are defined as: static inline int constant_test_bit(int nr, const volatile unsigned long *addr ) { return...

Is it true that Tagged initialization allows the reordering of structure members?

linux,gcc,linux-kernel,linux-device-driver,c99
I am currently reading "Linux Device Driver" third ed. Extract: The scull device driver implements only the most important device methods. Its file_operations structure is initialized as follows: struct file_operations scull_fops = { .owner = THIS_MODULE, .llseek = scull_llseek, .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open =...

proc_dir_entry warning: initialization from incompatible pointer type [enabled by default]

c,linux,linux-kernel
I'm trying to build a kernel module, but while compiling it in a make file I got some errors which I can't solve. This is the code for the module: #include <linux/kernel.h> #include <linux/version.h> #include <linux/list.h> #include <linux/module.h> #include <linux/proc_fs.h> #include <linux/uaccess.h> #include "sar_main.h" #define PROCFS_NAME "sarlkm" char procfs_buffer[PROCFS_MAX_SIZE]; static...

Why does the Linux kernel repository have only one branch? [closed]

linux,git,linux-kernel,workflow
I'm a Linux beginner, so forgive me if this is the most obvious question you've ever heard. https://github.com/torvalds/linux/branches/all...

How to divide the L2 cache between the cores on a ARM Cortex-A7?

caching,linux-kernel,arm,cortex-a,l2-cache
Context and goal I'd like to run two fully standalone applications on my Olimex A20 Lime platform that run a ARM Cortex-A7. The goal is to dedicate one core to each application. So far so good. Now I'd like to divide the L2 cache between the cores in the following...

linux kernel driver debug log

linux,linux-kernel,linux-device-driver
I'm writing a Linux kernel driver for a device that has quite a bit going on and a bunch of interaction from user-space. In order to debug and troubleshoot these interactions I'm storing them in a data array in the driver and need to export this data to user-space via...

What fpu_xrstor_checking does? extra commentary?

linux-kernel,linux-device-driver,x86-64
I am doing my own version of do_fork() (for many purposes). So, basically, I am copying the process from one place to another, possibly to another machine. Copying the code and pasting it here would be tough. But this explanation should good enough, I believe. My code works most of...

Why is “echo l > /proc/sysrq-trigger” call trace output always similar?

linux,linux-kernel,call,backtrace,sysctl
According to the official kernel.org documentation echo l > /proc/sysrq-trigger is supposed to give me the current call trace of all CPUs. But when I do this a couple of times and look into dmesg after that the call traces look completely similar. Why is that?

Dynamically find the address at which the kernel is loaded

linux,linux-kernel
I'd like to be able to programmatically find out the address at which the linux kernel is loaded. If there are tools out there that already do that, I'd be willing to use them. However, inspecting the PARAMS_PHYS field in the .config during the kernel build is not an option....

Kernel spin-lock enables preemption before releasing lock

linux,linux-kernel,kernel,locking,scheduling
When I was discussing the behavior of spinlocks in uni- and SMP kernels with some colleagues, we dived into the code and found a line that really surprised us, and we can’t figure out why it’s done this way. short calltrace to show where we’re coming from: spin_lock calls raw_spin_lock,...

What is wmb() in linux driver

linux-kernel,linux-device-driver
In one of the PCI DMA driver i have seen wmb() many times. What actually does wmb() function do? Somewhere its mentioned as "holy water that doesn't hurts". Whats the purpose of that function?

Missing headers for kernel in bzImage loaded on qemu

linux-kernel,kernel,header-files,kernel-module,qemu
I am trying to compile a kernel module of kernel version 3.2.0 on a linux kernel bzImage loaded on a qemu emulator, however I am getting the following error: /lib/modules/3.2.0/build no such file or directory. I tried to look up solutions over the net but nothing specific related to solve...

Why udelay and ndelay is not accurate in linux kernel?

timer,linux-kernel,linux-device-driver,delay
I make a function like this trace_printk("111111"); udelay(4000); trace_printk("222222"); and the log shows it's 4.01 ms , it'OK But when i call like this trace_printk("111111"); ndelay(10000); ndelay(10000); ndelay(10000); ndelay(10000); .... ....//totally 400 ndelay calls trace_printk("222222"); the log will shows 4.7 ms. It's not acceptable. Why the error of ndelay is...

Why linux disables disk write buffer when system ram is greater than 8GB?

linux,linux-kernel,disk
Background: I was trying to setup a ubuntu machine on my desktop computer. The whole process took a whole day, including installing OS and softwares. I didn't thought much about it, though. Then I tried doing my work using the new machine, and it was significantly slower than my laptop,...

difference between one CPU and multiple CPU in schedule routine - Linux kernel

linux-kernel,operating-system,kernel
In Linux kernel (2.6) is there a difference between the performance of the "schedule()" routine in a system that has only one processor than in a system with multiple processors? I have tried to find the answer in the book "Understanding the Linux kernel (3rd ed.)" but no luck finding...

How do I generate loadable modules during Linux kernel build?

linux-kernel,linux-device-driver
I seem to successfully build a kernel image, but I can not generate all the modules I expect. I expect more modules since I see them enabled in the gconfig window. Here is a copy of my make session. Seems like make goes into the devices directories. I can not...

Passing IPC(Instructions/Cycles) continuously to other function or variable

linux,performance,shell,linux-kernel,performancecounter
I am trying to read the performance counters and get the IPC. I need to use IPC to control few machine specific parameters. I am using shell script to do the same. Please see the code below: while true do retval=./perf periodic -e instructions -e cycles -s 50 -d -m...

schedule automate shell script running not as ROOT

python,linux,shell,unix,linux-kernel
I have a shell script that I want to run automatically every day at 08 AM, and I am not authorised to use the crontab because I don't have root permission My home directory is /home/user1/. Any suggestions?...

I want to sleep while holding a mutex

linux,linux-kernel,locking,linux-device-driver
I need to write to and read from a Ethernet chip's FIFO and for that I want to use DMA controller. So I modified an existing driver and made the process to sleep using wait_event_interruptible after triggering DMA transfer and made it woken up by ISR using wake_up_interruptible. My problem...

Creating proc entry under parent folder

linux,file,linux-kernel
I want to create a proc entry under /proc/driver/ path, I am using this code: struct file *fp = filp_open("/proc/driver",O_RDONLY,0); struct proc_dir_entry *parent ; parent = PDE(fp->f_dentry->d_inode); filp_close(fp, NULL); proc_create("leds",0,parent,&proc_fops); But when compile i got error : error: implicit declaration of function ‘PDE’ [-Werror=implicit-function-declaration] How can i fix this problem?...

How to build Linux kernel to support SO_ATTACH_BPF socket option?

c,linux,sockets,linux-kernel,bpf
I want to build a application which supports eBPF on CentOS 7 (the kernel version is 3.10.0): if(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd, sizeof(prog_f)) { ...... } So I download a 4.0.5 version, make the following configurations on: CONFIG_BPF=y CONFIG_BPF_SYSCALL=y Then follow this link to build and install a 4.0.5 kernel. After...

Coding of Admin-Guest login section in an OS

linux,authentication,cmd,linux-kernel,operating-system
I developed an authentication algorithm for user authentication as part of my masters thesis and implemented it in PHP. I intend to know how can I implement the algorithm for operating system login, in which language (for linux)? also where the code will reside because it will not be click...

How to setup YouCompleteMe for kernel and device driver development?

c,vim,linux-kernel,vim-plugin
I would like to setup vim for kernel hacking so I have installed YouCompleteMe for auto completion. However, no matter what I do It looks like I can't configure it properly. It does not do semantic completion properly; It only suggests the semantics already used in the current file not...

unknown field 'ioctl' specified in initializer

linux,linux-kernel,filesystems,ioctl
I implement a simple example to study the usage of ioctl interface according to the book LDD3. When I compiling the codes, unknown field 'ioctl' specified in initializer. is reported. I guess the difference of kernel version between LDD3's and mine causes this error. I'm now using Debian 8 with...

How do I understand and fix error while compiling Linux kernel for embedded system

c,linux-kernel,make,arm,native
While trying to compile the following file: /* * linux/arch/arm/mm/proc-syms.c * * Copyright (C) 2000-2002 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software...

physical memory userspace/kernel split on Linux x86-64

memory,memory-management,linux-kernel,kvm
Is there an explict split between userspace and kernel in physical memory on Linux x86-64? That is, given a physical address, can I tell whether this address is from userspace or not? As far as I know, in virtual address space, the kernel will use the upper half and the...

How the kernel functions work?

linux-kernel,kernel
Normally during a function call the function gets pushed into the stack part of the process and the calling function waits. But the program stack requires a process right? But the kernel is not part of any process (by kernel I mean the part that does file management and interprocess...

Will physical addresses of all paging structures in Linux be mapped in the page tables

linux-kernel,paging,virtualization,kvm
In 64-bit Linux, IA-32E paging is used with 4 levels of paging structures (PML4/PDPT/PD/PT). The entries in the former three structures give the physical address of the corresponding next structure. My question is that will the physical addresses of all these paging structures be mapped in the paging table? If...

Testing modules/drivers of Linux kernel running in any target board

testing,linux-kernel,embedded-linux,kernel-module,device-driver
How do we test the modules and drivers(like USB,I2C,HDMI etc..) of a Linux kernel running in a target board? is there any tools/frameworks doing the job? i found this thread.Can anyone suggest me the best one? thanks in advance...

How do I make syscalls from my C program

c,linux-kernel,syscall
How do I make system calls from my C program. For example, how do I call the following function? What headers would I have to include? asmlinkage long sys_exit(int error_code); ...

Which usb driver is called in order to transfer data?

linux-kernel,usb,linux-device-driver
I would like to change the behaviour of one of my USB flash drive by editing its driver, but i can't find which driver is called. I searched and i found that the drivers/usb/storage/transport.c is responsible for some exchanges beetween the host and the device (configuration), but i want to...

What does it indicate if /proc/PID/maps shows zero for all addresses?

linux,linux-kernel
I'm debugging a problem with a Linux DNS server. Curiously, when I look at /proc/PID/maps for the DNS server process, this is what I get: 00000000-00000000 r-xp 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 rw-p 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 ---p 00000000 00:00 0 00000000-00000000 rw-p 00000000 00:00 0 [heap] 00000000-00000000 rw-p...

How to track memory usage of the networking subsystem in the Linux kernel?

linux,performance,networking,linux-kernel,operating-system
Is there a way to determine how much physical memory is being used by the network subsystem in the Linux kernel at any given point in time? I understand the per-connection memory limits can be specified via sysctl. But is there a tool to peek inside the TCP/IP stack and...

How to monitor the process in a container?

process,linux-kernel,cgroups,linux-containers
I currently look into the LXC container API. I am trying to figure out how can I make the operating system know to which container the currently running process belongs. In this way, OS can allocate resource for processes according to the container.

Link of compressed pages in zsmalloc

linux-kernel,linux-device-driver
I am trying to understand zsmalloc allocator used in zram and zswap but I am stuck in code of init_zspage in zsmalloc.c link = (struct link_free *)kmap_atomic(page) + off / sizeof(*link); Here link is not initialized. The problem is what will be the value of sizeof(*link) if it not initializes....

Return a function while daemon thread is working in the background (c++)

c++,linux,linux-kernel,pthreads,daemon
I want to return function 'A' with some return value(let's say '0') while a daemon thread started running inside this function but may not finished. Is that even possible?

Linux: Reading the output of readlink /proc/pid/exe within a Bash Script

linux,bash,linux-kernel,procfs
So I am writing a bash script which will run through all of the process ids in /proc/[pid] and read the executable that was used to run it. From what I have had a looked at, the /proc filesystem contains the /proc/[pid]/exe symbolic link. Within the bash script I am...

How to offload NAPI poll function to workqueue

c,linux,linux-kernel,linux-device-driver,embedded-linux
I'm working with linux 3.3, Ethernet driver for smsc911x. and I want to move the NAPI poll function to workqueue. My questions are : 1. How do I pass the NAPI poll function arguments to the work_struct? 2. How do I get the NAPI poll function arguments back from the...

Compiling linux module

linux-kernel
I've got homework in Operating Systems course, in which I have to write some module. We use Red Hat 8.0 with customed linux kernel 2.4.18.14. I have a makefile for compiling the module, but I fail getting it to work. the module source code is in snake.c and the makefile...

Why my process has been killed?

linux-kernel,out-of-memory,linuxmint
I have a program, written on C/C++ by myself, that is killed by Linux. The message "killed" appears. Willing to dig out the problem I observed inside the file /var/log/kern.log: Out of memory: Kill process 3915 (my_proj) score 236 or sacrifice child Killed process 3915 (my_proj) total-vm:5503376kB, anon-rss:3857420kB, file-rss:40kB I...

How do I know the last sched time of a process

linux,process,linux-kernel,scheduling
I current run into an issue that a process seems stuck somehow, it just doesn't gets scheduled, the status is always 'S'. I have monitored sched_switch_task trace by debugfs for a while, didn't see the process get scheduled. So I would like to know when is that last time scheduled...

How can I know which type of process of linux will use for these?

linux,linux-kernel,operating-system,scheduled-tasks
if I am listening to an audio file, creating a presentation, and downloading something from the internet...while we know that: an audio file will use real-time creating a presentation will use interactive and downloading will use background but what I cannot know is for example: when an audio file will...

Why do we need to call poll_wait in poll?

linux,linux-kernel,linux-device-driver,system-calls,epoll
In LDD3, i saw such codes static unsigned int scull_p_poll(struct file *filp, poll_table *wait) { struct scull_pipe *dev = filp->private_data; unsigned int mask = 0; /* * The buffer is circular; it is considered full * if "wp" is right behind "rp" and empty if the * two are equal....

ret_from_syscall source code and when it is called

linux,linux-kernel,kernel,linux-device-driver,system-calls
In the below call trace we see function called ret_from_syscall. Which function is this ? When it will called during system call ? Where is the corresponding code for this ? May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddc0] [00009751] 0x9751 (unreliable) May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddd0] [c00469ac] do_syslog+0x198/0x424...

Linux boot commands for memory boot on am335x

linux-kernel,embedded-linux,beagleboneblack,beagleboard,u-boot
I am using am335x based custom board. I have only uart port for loading images to memory. I was able to get u-boot working. What are the load addresses for the linux kernel and the dts file. What will be boot command for running the loaded kernel from memory.

How does the kernel separate threads from processes

linux,multithreading,linux-kernel
Suppose I have a browser process like Firefox, that has pid = 123. Firefox has 5 opened tabs each running in a separate thread, so in total it has 5 threads. So I want to know in depth, how the kernel will separate the process into the thread to execute...

using system call in Linux kernel file

linux-kernel,scheduling,scheduler,system-calls
I am implementing a custom process scheduler in Linux. And I want to use a system call to record my program so that I can debug easily. The file I write is source code : linux-x.x.x/kernel/sched_new_scheduler.c In sched_new_scheduler.c could I use syscall(the id of the system call, parameter); directly? It...

What's the meaning of ?= in a kernel makefile? [duplicate]

linux,makefile,linux-kernel
This question already has an answer here: Makefile variable assignment 4 answers I've started learning about building external Linux kernel modules, and in the documentation examples of kbuild (here) I've come across the line KDIR ?= /lib/modules/$(shell uname -r)/build which is then used in make -C $(KDIR) M=$(PWD) and...

Floating-point computation without syscall?

linux-kernel,floating-point,syscall
I am reading Robert Love's book on Linux kernel (which says no FP computation inside kernel). And I am wondering how floating point computation is done in user space. For instance, does 3.14 + 5.26 (in C) invoke any syscall to do the job?...

Fast kernel recompile

linux,build,linux-kernel,make,incremental-build
I'm trying to automate the process of recompile a upgraded kernel. (I mean version upgrade) What I do: Backup the object files (*.o) with rsync Remove the directory and make mrproper Extract new source and patch Restore object files with rsync But I found it doesn't make sense. Since skip...

Kernel module makefile output name

c,linux,makefile,linux-kernel
I am trying to compile my kernel module. The .c file name is file1.c, but I need the .ko file name to be mod1.ko. How can I do that? My current makefile: obj-m := mod1.o KDIR :=/lib/modules/$(shell uname -r)/build PDW := $(shell pwd) all: $(MAKE) -C $(KDIR) M=$(PDW) modules clean:...

Redhat 7.1 kernel process stack size from 8K to 16KB

c,linux,linux-kernel,redhat
Reading the release note of Redhat 7.1, I read this: Process Stack Size Increased from 8KB to 16KB Since Red Hat Enterprise Linux 7.1, the kernel process stack size has been increased from 8KB to 16KB to help large processes that use stack space. I know the kernel process stack...

how to transfer string(char*) in kernel into user process using copy_to_user

linux-kernel,kernel,system-calls
I'm making code to transfer string in kernel to usermode using systemcall and copy_to_user here is my code kernel #include<linux/kernel.h> #include<linux/syscalls.h> #include<linux/sched.h> #include<linux/slab.h> #include<linux/errno.h> asmlinkage int sys_getProcTagSysCall(pid_t pid, char **tag){ printk("getProcTag system call \n\n"); struct task_struct *task= (struct task_struct*) kmalloc(sizeof(struct task_struct),GFP_KERNEL); read_lock(&tasklist_lock); task = find_task_by_vpid(pid); if(task == NULL ) {...

CPU new features enabled in Linux kernel

linux-kernel,cpu
If the CPU has some new features, how does the Linux kernel handle this ? From what I remembered, PAE does not need to rebuild the entire the system and Linux seems like just installing the driver and things work. Say, if the CPU provides more execution modes, Do we...

How to clone Greg Kroah-Hartman's stagingtree repository for the Linux kernel?

git,linux-kernel,git-clone
I am using git to try and clone Greg Kroah-Hartman's staging tree repository by using following command. $ git clone -b staging-next git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git However, I keep getting this error: Cloning into 'staging'... fatal: unable to connect to git.kernel.org: git.kernel.org[0: 198.145.20.140]: errno=Connection refused git.kernel.org[1: 199.204.44.194]: errno=Connection refused git.kernel.org[2: 149.20.4.72]: errno=Connection refused...

How to directly access Resident Set Size (RSS) of a process from within kernel module?

linux,linux-kernel,kernel-module
I want to directly access the Resident Set Size (RSS) of a process from inside a kernel module (I want to take a real time decision based on RSS, so calculating it every time is a bad option for me). /proc/$PID/status has a VmRSS field which I can use, but...

Are shared library pages anonymous?

c,linux,memory-management,linux-kernel,kernel
From my understanding, memory mapped pages are pages that are backed by files whereas anonumous pages are pages that are allocated without a file or device backing them. According to this definition, memory pages that belong to shared libraries should be marked as memory mapped and should not be marked...

Access android app port directly on mobile network

android,linux,linux-kernel
Is it possible to access an app port on android directly through mobile network. I checked my public ip from my mobile internet provider, but couldn't see it at the os level(using command ifconfig). The ip mentioned there was different on interface rmnet0. Even i couldn't find the IP in...

How does kernel understand, which driver module function handles read/write/etc?

linux,linux-kernel,driver
I found a couple of articles, where it is shown how to make your own hello-world driver. I supposed that function names should be hardcoded (for example, when you read from device, you use read function, etc). But everywhere are used functions names like hello_read (first article) or device_file_read (second...

Error compiling kernel module linux/module.h: No such file or directory found

c,linux,makefile,linux-kernel,kernel-module
I am using a simple example to create a Hello World Kernel module. Link below: http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/ when attempting to run the makefile using "make hello" in the same directory as hello.c. I get the following error: hello.c:1:64: fatal error: linux/module.h: No such file or directory I have successfully installed linux...