自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 资源 (3)
  • 收藏
  • 关注

原创 sysctl

在kernel/sysctl.c 中有定义sysctl_initint __init sysctl_init(void){ struct ctl_table_header *hdr; hdr = register_sysctl_table(sysctl_base_table); kmemleak_not_leak(hdr); return 0;}这个函数会在proc/sys 目录

2017-08-31 15:59:57 1929

原创 roce和IB注册的flow

RDMA的实现有三种分别是IB/ROCEv1/ROCEv2/iWARP。所以支持RDMA的驱动最终都会调用ib_register_device.分别以ROCE和IB调用ib_register_device为例roce:IB卡:首先看IB的probe函数static struct pci_driver mlx5_core_driver = { .name

2017-08-31 14:37:00 1851

原创 vf通过msi向pf发送中断

在ixgbe_request_msix_irqs 中最后通过    err = request_irq(adapter->msix_entries[vector].vector,              ixgbe_msix_other, 0, netdev->name, adapter);来注册一个中断。当vf向pf通信的时候会调用ixgbevf_set_uc_addr_vf

2017-08-30 15:28:11 1531

原创 lspci | grep -i raid查询系统的raid卡信息

2017-08-30 15:05:41 6095

原创 通过syscall 调用系统调用

syscall 是glib c提供的一个函数,这一直接调用系统调用 #include #include #include #include #include #include int main(int argc, char *argv[]) { pid_t tid; tid = syscall(SYS_gettid);

2017-08-29 17:20:26 2471

原创 init 6 重启

可以通过init 6来关机,当前系统在用system的情况下。linux原本对应的6个runlevel 在systemd下都有对应的target当运行ini 6的时候会运行runlevel6.target最终又调用systemd-reboot.service可见最终通过systemctl --force reboot 来实现重启

2017-08-26 17:38:02 2706

原创 设置内核线程的调度策略

调度策略总共分为三种1:sched_normal 非实时调用,就是常说的cfs,优先值的范围为100~139,有nice值决定2:sched_fifo 实时调用策略,先到先服务,高优先级的可以抢占第优先级的.3:sched_RR 实时调用策略,按照时间片运行,同样高优先级的可以抢占第优先级的.这两种优先级的额凡是是0~MAX_RT_PRI0-1 , 其中MAX_RT_PRI0等于10

2017-08-26 17:23:58 1954

原创 I2C clock设置的过程

一般在drivers/acpi/acpi_apd.c 中注册i2c的device。这次我们重点关注clock的情况static const struct acpi_device_id acpi_apd_device_ids[] = { /* Generic apd devices */、#ifdef CONFIG_ARM64 { "APMC0D0F", APD_ADDR(xg

2017-08-25 14:53:09 4827

原创 dmesg -c 用于清掉已有的log

2017-08-24 15:00:28 4605

原创 通过cat /proc/interrupts | tr -s " " 查看中断的情况

2017-08-21 17:21:51 5463

原创 whereis

whereis命令用来定位指令的二进制程序所在的位置

2017-08-21 16:49:01 401

原创 strings

strings命令在对象文件或二进制文件中查找可打印的字符串,一般和grep 配合使用

2017-08-21 16:47:00 452

原创 raid 3108 的初始化

3108 raid卡驱动路径在drivers/scsi/megaraid。其入口函数在megaraid_sas_base.c中megasas_init。从megasas_init中可以看到首先注册了一个字符设备,用于从user space控制raid卡 /* * Register character device node */ rval = register_chrdev(0, "

2017-08-21 16:02:49 2979

原创 ssh 快速登录

第一步:ssh-keygen -t rsa 命令产生rsa的public key第二步:在.ssh 路径下面建立一个名为config的文件.HOST:表示要登陆的服务器的别名,这个别名是自己定义的。可以为任何字段.HostName:服务器的地址Port:端口号User:登陆的用户名IdentityFile:rsa public 可以的存放路径Iden

2017-08-21 15:21:13 1356

原创 sysctl

sysctl 一般用于改变内核运行的参数,-a 可以显示所有可以改变的参数sysctl 可以修改的参数分为以下六类下面演示通过两种方法改变kernel运行参数,注意两种修改方式变量名称的不同

2017-08-21 15:07:45 517

原创 通过capable给字符设备添加root权限

一般我们通过下面的code 来注册一个字符设备 /* * Register character device node */ rval = register_chrdev(0, "megaraid_sas_ioctl", &megasas_mgmt_fops); if (rval < 0) { printk(KERN_DEBUG "me

2017-08-21 14:53:00 820

原创 假如open的文件是个符号链接

一般我们在user space 通过open打开某个字符设备,例如下面的函数就会打开/dev/i2c-x 这个字符设备int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet){        int file;        snprintf(filename, size, "/dev/i2c-%d

2017-08-21 14:37:22 1456

原创 hw random的实现

我们一般都是通过dev/random 来得到随机数,但是这个随机数其实是伪随机的.因此就有厂商用硬件实现随机数的产生,kernel 一样已经提供了随机数的framework曾.路径在drivers/char/Hw_random/hisi-rng.c ,我们直接看probe函数吧static int hisi_rng_probe(struct platform_device *pdev){

2017-08-16 17:19:11 2279 1

原创 申请memory的鲁棒性建议(物理连续失败后用虚拟连续memory替代)

code中我们的驱动如果不一定要求是物理连续的memory的话,在申请memory的时候,可以先向伙伴系统要物理连续的memory,如果失败的话,可以通过vzalloc来申请虚拟连续的memory。这样在 __get_free_pages失败后,可以通过vzalloc来申请memory。虽然使用vzalloc申请的memory使用性能可能会差一下,但是总比__get_free_pages失败后直接

2017-08-14 16:04:18 1133

原创 cherry-pick

将mailline 更新到最新(至少包含你要的commit id),然后直接切换到你的br 然后直接cherry-pick 主线的commit id 到自己的br,注意这个时候其实是在自己的br

2017-08-14 14:24:50 594

原创 void 可以避免编译警告

下面这个函数被声明返回一个int类型static int hns_nic_net_stop(struct net_device *ndev){ hns_nic_net_down(ndev); return 0;}如果在调用的时候不关心这个返回值的话,可以在函数的调用前家void,这样可以避免编译警告. if (if_running) { (void)hns_nic_net_st

2017-08-10 15:01:29 1015

原创 shell 的expect实践

#!/usr/bin/expect -f set timeout 30 set host "192.168.2.195"set username "root"spawn ssh $username@$hostexpect {         "(yes/no)?" { send "yes\r" ; exp_continue }         "password:" {

2017-08-10 14:28:45 2206

原创 非generic phy的引用计数为0

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/drivers/net/phy/phy_device.c?h=v4.11.12&id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25diff --git a/drivers/net/phy/p

2017-08-10 14:25:40 578

原创 phy device 和 driver

phy的驱动分为platform_driver_register和platform_device_register 两部分。这两部分都是挂在mdio总线上。这里以hns驱动为例。说先定义mido对应的struct mii_bus *new_bus;static int hns_mdio_probe(struct platform_device *pdev){    struct h

2017-08-08 17:44:01 2650

原创 ifenslave 测试

注意bond0,eth0,eth1的HWaddr C0:A8:02:C3:00:04 是一样的,表示bonding成功

2017-08-08 15:37:50 1174

原创 查看当前网卡用的是哪个phy

2017-08-08 15:33:47 1230

原创 BUILD_BUG_ON 检查编译时错误

一般我们在runtime的时候通过BUG_ON 来检查运行时的错误    BUG_ON((reg & 0x3) != 0);例如上例汇总reg & 0x3 应该要等于0,如果不等于0就会出发BUG_ON#ifndef HAVE_ARCH_BUG#define BUG() do { \    printk("BUG: failure at %s:%d/%s()!\n", __FI

2017-08-07 10:34:58 2319

原创 通过debugfs_rename 修改已经存在的debugfs的目录的name

一般我们通过下面的code来创建一个名为bongding的debugfs的入口void bond_create_debugfs(void){    bonding_debug_root = debugfs_create_dir("bonding", NULL);    if (!bonding_debug_root) {        pr_warn("Warning: C

2017-08-04 16:25:40 772

原创 fio 测试

可以通过下面的命令安装编译fio    wget http://brick.kernel.dk/snaps/fio-2.1.10.tar.gz    tar -xvf fio-2.1.10.tar.gz    cd fio-2.1.10    ./configure    make all    make install如果编译过程中遇到engine libai

2017-08-04 09:55:16 5684

原创 手动注册platform_device 测试rtc

在有bios的情况下要测试某个驱动是否可以正常工作的话,经常要改bios比较麻烦,在drivers/rtc/rtc-test.c 中提供了一个方法自己注册platform_device,这样可以避免需修改bios的情况.static int __init test_init(void){    int err;//注册platform_driver    if ((err

2017-08-02 09:20:47 891

原创 通过/sys/class/rtc/rtcX/date 获取rtc的时间

每个rtc的driver都会调用rtc_device_register 来想系统注册rtc的驱动,在rtc_device_register中会自动为每个rtc device建立一个sys的接口    rtc->dev.class = rtc_class;    rtc->dev.groups = rtc_get_dev_attribute_groups();为rtc建立的sys

2017-08-01 16:37:28 1734

原创 lscpu 获取系统的硬件信息

https://github.com/karelzak/util-linux/blob/master/sys-utils/lscpu.c 这是lscpu的源码这里的路径为从源码中可以看到cpu相关的信息

2017-08-01 15:46:33 1332

原创 hostname 修改系统name

这样下次开机就会用195 替换linxu-d54x。也就是用hostname 修改的结果需要下次开机才能生效

2017-08-01 11:21:23 1068

原创 先匹配DSDT 表格中的HID,如果不匹配,再匹配CID ,这样可以解决兼容性问题

设备的信息都是通过ACPI的DSDT表传递给kernel的int __init acpi_ec_dsdt_probe(void){    acpi_status status;    struct acpi_ec *ec;    int ret;    /*     * If a platform has ECDT, there is no need to proc

2017-08-01 11:04:28 1485

原创 grub中的date命令

grub的date命令实现在grub-core/commands/date.c 中GRUB_MOD_INIT(date){  cmd =    grub_register_command ("date", grub_cmd_date,               N_("[[year-]month-day] [hour:minute[:second]]"),        

2017-08-01 08:53:51 712

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除