clearlinux
Clear Linux OS 调研开篇先放置一个性能测试对比, 可以看到早期 Clear Linux 足足比 Ubuntu 的性能快了 2.3 倍. 源自: https://openbenchmarking.org/ , 这里可以找到更多的对比图 2025.7.18 Intel 官方社区明确停止 Clear Linux OS 停止维护、停止安全补丁与更新. 为什么要做这次调研? 笔者的理解是: 尽管停止了支持(貌似是因为成本原因), 但我们不能否认, 这是一款相较于其他发行版性能爆炸的 OS, 其到现在仍然能够提供一定的指导意义. Clear Linux OS 是一个怎么样的 OS 发行版? 第一节将总体介绍到. Clear Linux OS 中有哪些值得被借鉴的理念和项目? 调研一下这个发行版有没有什么优秀的 project 能够被继承或者衍生.第二和第三节将讨论, 二三节的工具和内容是贯穿始终的 Clear Linux OS 的底层设计思想是否能够应用到其他架构? 对于 riscv 架构在后续是否也能够提供一个 “riscv performance OS”?...
二进制文件篇-手写ELF加载器
1 概述这是一个从0开始手写的 ELF 加载器. 项目链接: https://github.com/Jvlegod/uELF 今天我们来看 ELF Header 的结构. 12345678910111213141516typedef struct { unsigned char e_ident[16]; // 魔数 + 文件类型 uint16_t e_type; // 文件类型 (ET_EXEC, ET_DYN, ET_REL) uint16_t e_machine; // 架构类型 (EM_X86_64, EM_RISCV, etc.) uint32_t e_version; // ELF 版本 (一般是 1) uint64_t e_entry; // 程序入口地址 uint64_t e_phoff; // Program Header Table 偏移 uint64_t e_shoff; // Section Header Table 偏移 ...
Linux篇-proc文件系统
1 概述/proc 文件系统(procfs, process filesystem)是 Linux 内核对外暴露内核与进程信息的一种虚拟文件系统.它不是一个真正存在于磁盘上的文件系统,而是由内核在运行时动态生成的,用于让用户空间(用户、程序、脚本等)读取甚至控制内核状态. 目录结构. 1234567891011121314151617181920/proc├── 1/ # 进程号目录 (PID=1)│ ├── cmdline # 启动命令行参数│ ├── environ # 环境变量│ ├── fd/ # 打开的文件描述符│ ├── maps # 内存映射信息│ ├── stat # 进程状态│ ├── status # 状态信息│ └── exe -> /sbin/init│├── cpuinfo # CPU 信息├── meminfo # 内存信息├──...
Linux篇-insmod观察
1 概述本篇为 Linux 调试篇,主要是观察 Linux 常见的各种调用过程. 这里我简单书写了一个内核模块. 123456789101112131415161718192021// helloworld.c#include <linux/init.h>#include <linux/module.h>MODULE_LICENSE("GPL");MODULE_AUTHOR("Jvle");MODULE_DESCRIPTION("Hello World Kernel Module for Linux 6.6.109");static int __init hello_init(void){ pr_info("Hello, kernel world!\n"); return 0;}static void __exit hello_exit(void){ pr_info("Goodbye, kernel...
Linux篇-platform
1 数据结构1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071// 通过 platform_bus_init 函数进行注册const struct bus_type platform_bus_type = { .name = "platform", .dev_groups = platform_dev_groups, .match = platform_match, .uevent = platform_uevent, .probe = platform_probe, .remove = platform_remove, .shutdown = platform_shutdown, .dma_configure = platform_dma_configure, .dma_cleanup =...
Linux篇-设备树
1 概念 DTS: 设备树的源文件,以 .dts 结尾. DTSI: 设备树源文件的头文件, .dtsi 为扩展名. DTC: 设备树的编译器,将 DTS 和 DTSI 生成 DTB 文件. DTB: 二进制文件,以 .dtb 结尾. Linux 内核启动的时候会在 /proc/device-tree 目录下根据节点的名字创建不同的文件夹. 一般存放在 arch/<arch>/boot/dts/ 中. 编译方式. 123# 以 arm64 为例# 结果在: arch/<arch>/boot/dts/*.dtbmake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs 也可以使用 dtc 直接编译. 1234# 编译dtc -I dts -O dtb -o output.dtb input.dts# 反编译dtc -I dtb -O dts -o output.dts input.dtb 2 节点介绍2.1 根节点根节点是整个设备树的起点. 123/ {...} 2.2...
Linux篇-driver设备模型
1 概念123456789101112131415161718192021222324252627struct device_driver { const char *name; const struct bus_type *bus; // 必须指定 bus_type struct module *owner; const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ enum probe_type probe_type; const struct of_device_id *of_match_table; const struct acpi_device_id *acpi_match_table; int (*probe) (struct device *dev); void (*sync_state)(struct device *dev); int (*remove) (struct...
Linux篇-device设备模型
1 概念123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110struct device { struct kobject kobj; struct device *parent; struct device_private *p; const char *init_name; /* initial name of the device */ const struct device_type *type; const struct bus_type *bus; /* type of bus device is on */ struct device_driver...
Linux篇-bus设备模型
1 概念总线是设备模型当中的基础组件,简化了驱动的编写和维护,总线可以是物理总线(如PCI,USB)或虚拟总线. 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455struct bus_type { const char *name; // 总线类型名称 const char *dev_name; // 老版本内核这里可能不一样 const struct attribute_group **bus_groups; // 总线属性 const struct attribute_group **dev_groups; // 设备属性 const struct attribute_group **drv_groups; // 驱动属性 int (*match)(struct device *dev, const struct device_driver *drv); // 匹配检查 int...
Linux篇-sysfs
概念sysfs 是 Linux 提供的一种虚拟文件系统,他以一种层次的方式组织数据,向用户空间提供内核中的信息,让用户可以通过文件系统接口访问和操作内核对象的属性. 他提供了一种统一管理的接口,通常在 /sys 目录下挂载. /sys/class: 包含了设备类别的子目录. 123456789jvle@jvle-ThinkPad-X1-Carbon-Gen-8:~/Desktop/works/temp/linux_files/modules/kobjs$ ls /sys/class/accel bsg drm hwmon lirc nd platform-profile pwm scsi_device tpm vcata_device devcoredump drm_dp_aux_dev i2c-dev mdio_bus net ...