kernel

Reading a sysfs GPIO input pin (direction as “in”) always print a fixed value (0)

雨燕双飞 提交于 2020-01-06 02:25:06
问题 After enabling the GPIO device support in kernel device driver (Kernel verion 3.10.92 ) I wanted to read the value of an input pin of my GPIO expander through GPIO sysfs. After exporting and setting the direction as "in", on reading, the value is always given as 0 even after the event is happening which will change the pin value as 1 . While the output direction is working fine i.e. I am able to glow a LED by altering the value as 0 or 1 . Base address for my GPIO expander in GPIO sysfs is

Ubuntu性能调整备忘

倖福魔咒の 提交于 2020-01-05 21:24:06
建立開機索引 (profile) 以 dash 取代 sh 增進開機效能 並行啟動程序, 加速開機 降低 SWAP 寫入機會 減少文字模式終端機數量 暫存區使用 ramdisk 使用 Prelink、Preload 節省應用程式啟動時間 停用 IPv6 使用 sysv-rc-conf 管理系統服務 GNOME 作業階段 使用 Real Time (CONFIG_HZ=1000) 版本的 Kernel 以下未提及執行身份的指令均以 root 身份執行 建立開機索引 於 GRUB 選單按 [ e ] → 編輯 kernel /vmlinuz-2.6… 這行, 於最後加上 profile profile 參數係建立開機索引用, 不需存入 menu.lst 於更新 kernel 版本後再執行 profile 即可 停用開機畫面 vi /boot/grub/menu.lst 刪除所有 splash 參數 以 dash 取代 sh 增進開機效能 dpkg-reconfigure dash 並行啟動程序, 加速開機 vi /etc/init.d/rc CONCURRENCY=shell 降低 SWAP 寫入機會 echo "vm.swappiness = 10" >> /etc/sysctl.conf sysctl -p 減少文字模式終端機數量 cd /etc/event.d rename 's

How is procfs created?

梦想的初衷 提交于 2020-01-05 12:32:12
问题 After looking at the proc directory, the size is about 140.7TB What is the /proc mapped to, how are the files present in it created? The proc file system is a pseudo-file system which is used as an interface to kernel data structures. I get that it acts as an interface between the kernel and userspace but I don't quite understand how a pseudo-file system works, and why it's so huge in size. Is the /proc directory recreated by the kernel every boot? How exactly is the /proc directory generated

Is __init attribute used in loadable kernel modules?

自作多情 提交于 2020-01-05 09:23:35
问题 The description at this - http://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm - page (as well as some related answers on SO, for example the answer here - __init and __exit macros usage for built-in and loadable modules ) says The __init macro causes the init function to be discarded and its memory freed once the init function finishes for built-in drivers, but not loadable modules. However, I tried to insert the following module, in which I try to call the init functions with __init attribute

current_thread_info() inline function in Linux kernel?

℡╲_俬逩灬. 提交于 2020-01-05 08:56:25
问题 I learned thread_info is stored in the bottom of stack. While looking in the source code of kernel, I'm trying to understand how to get current thread_info in linux kernel? Source code below is 13bits masking of current_stack_pointer. This is what I cannot get it. I don't understand that the position of thread_info changes. Why is it current stack pointer instead of start of stack? Please help me to understand this code /* * how to get the current stack pointer in C */ register unsigned long

How can I retrieve the mount namespace of the current task in a BPF program using GCP's 4.15 kernel?

自作多情 提交于 2020-01-05 05:46:10
问题 I am trying to retrieve the mount namespace of the current task in a BPF program as follows: task = (struct task_struct *)bpf_get_current_task(); bpf_probe_read(&nsproxy, sizeof(nsproxy), (void *)&task->nsproxy); bpf_probe_read(&mnt_ns, sizeof(mnt_ns), (void *)&nsproxy->mnt_ns); bpf_probe_read(&ns, sizeof(ns), (void *)&mnt_ns->ns); mnt_ns_inum = ns.inum; This works fine using an Ubuntu kernel ( uname -r : 4.15.0-13-generic) and mnt_ns_inum gets a value of 4026531840 for tasks in the host's

Loading a kernel without a filesystem - osdev

萝らか妹 提交于 2020-01-05 04:57:35
问题 I built a bootloader to load my kernel onto the memory. The kernel code is lying on the sectors of the floppy. The 2 stage bootloader reads out raw bytes of memory from the floppy disk and places it on the memory and executes the kernel. This works good on the bochs emulator but fails on the qemu emulator. Some tutorials out there suggest keeping the kernel file on a file system (like FAT12) and then reading the file from it. So, I want to ask that would such a system actually work on a

Centos 5.5 更新网卡驱动 bnx2 version: 2.0.2

北城余情 提交于 2020-01-05 01:34:14
操作系统:CentOS release 5.5 (Final) 故障现象 : 网卡无故自动down掉,使用service network restart 重启后没多久又会自动down , 连接数大概在200个左右,没有arp攻击 ; 网卡信息: [root@qs-wg-web2 ~]# cat /var/log/dmesg |grep eth0 eth0: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem d6000000, IRQ 90, node addr 842b2bfac367 当前网卡驱动: [root@qs-wg-web2 ~]# ethtool -i eth0 driver: bnx2 version: 2.0.2 firmware-version: 5.2.3 NCSI 2.0.10 bus-info: 0000:01:00.0 下载最新网卡驱动: http://www.broadcom.com/support/ethernet_nic/netxtremeii.php 安装更新驱动: [root@qs-wg-web2 ~]# unzip linux-7.4.27.zip Archive: linux-7.4.27.zip creating: Server/Linux

Linux系统NBD驱动安装拓展篇

走远了吗. 提交于 2020-01-05 01:33:33
前言 : 最近在安装中标麒麟机器的时候,发现麒麟的操作系统找不到src.rpm包,且系统内部也没有内核文件,导致正常方法安装NBD驱动无法实施。故这里找了另一种办法帮助此类型操作系统安装NBD驱动。 一、 中标麒麟系统类型及内核信息 系统镜像名称 内核版本 Kylin-4.0-1E-desktop_20160401-final-x86_64-2016-04-01 3.16.0-23-generic NeoKylin-Linux-Advanced-Server-6.7 2.6.32-573.el6.x86_64 NeoKylin-sws-3.2(64) 2.6.32-220.2.1.2.ky3.2.x86_64 YHKylin-4.2-5-x86_64-server 2.6.32-431.29.2.3.ky3.1.x86_64 对于以上4个内核版本的机器,其中3.16.0-23-generic和ubuntu(ubuntu-14.10-desktop-amd64)内核版本一模一样,而且/lib/modules/3.16.0-23-generic/kernel/drivers/block文件夹下已经有编译好的nbd.ko文件,测试发现可以插入到目标机器麒麟系统中。 二、查找相同内核的其他Linux系统: 例如红帽系统: 三、常规安装NBD驱动 在相同内核的系统

Extract all statistic of a process from /proc just before the process exit (Linux)

天涯浪子 提交于 2020-01-04 11:00:27
问题 I need to get some statistic(io, network) of a process during its lifetime. Is there anyway to get those information from /proc just before the process exit ? Linux Kernel API ? 回答1: wait4() and struct rusage A simple way to gather some statistics after child process termination is wait4(2) syscall, which can fill rusage struct. ptrace() If it's not enough, you can probably use ptrace(2) to stop a process just before its termination: PTRACE_O_TRACEEXIT (since Linux 2.5.60) Stop the tracee at