Update README.md

This commit is contained in:
gxm-newtonf 2020-01-06 21:21:35 +08:00 committed by GitHub
parent 81b4291d63
commit f9a96d3888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -1,4 +1,4 @@
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/tencentos-logo.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/tencentos-logo.png)
# TencetOS Server kernel
@ -87,17 +87,17 @@ TencentOS server的内核和用户态包的更新也会持续同步至腾讯软
隔离方案如图所示
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/docker-isolation.jpg)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/docker-isolation.jpg)
tlinux内核在cgroup的memorycpuset等子系统中分别添加对应的文件输出然后由用户通过mount bind操作将同名文件绑定到container的proc中。Mount bind操作可以在docker启动container的流程中添加。
例如在memeory子系统对应的container目录中添加meminfo和vmstat文件。
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/docker_isolation_img1.jpg)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/docker_isolation_img1.jpg)
在cpu子系统对应的container下实现cpuinfostat文件。
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/docker_isolation_img2.jpg)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/docker_isolation_img2.jpg)
**3.** **文件接口说明**
@ -137,7 +137,7 @@ tlinux内核在cgroup的memorycpuset等子系统中分别添加对应的文
- blkio.diskstats的通过blkcg_diskstats对象统计当前blkcg对特定设备的io量由于单个blkcg可以访问多个设备因此blkcg会维护一个blkcg_diskstats队列。由于实际blkcg_diskstats队列长度较短同时为了提高blkcg_diskstats搜索效率我们设置了一个cache点用于缓存最近命中的blkcg_diskstats对象的地址。Io统计的基本流程是io提交阶段我们会将bio与blkcg进行绑定因为end_of_io函数的运行上下文非提交io进程的上下文因此我们需要通过bio确定相应的blkcg。如果当前bio可以与plug队列设备dispatch队列或者io调度器内部队列的request合并此时进行io_merged的统计Io完成的时候我们对io_sectorsio_serviced, io_wait_time的统计。in_flightio_ticks, time_in_queue这三个字段与物理设备的处理能力相关因此我们不单独进行统计全部填0然后追加了两个字段将母机侧的io_ticks, time_in_queue的值透传到容器里面。值得注意的是blkio.diskstats入口默认是关闭的用户需要通过echo 1 > blkio.diskstats打开方可获取当前cgroup的io统计。基本框架如下所示
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/docker_blkcg_img1.jpg)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/docker_blkcg_img1.jpg)
@ -259,7 +259,7 @@ NSsid: 1 11126
- page cache在系统中的大致位置如下图所示
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/page_cache_img1.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/page_cache_img1.png)
@ -346,7 +346,7 @@ NSsid: 1 11126
内核热补丁技术是一种无需重启服务器即可实现修改内核运行时代码的技术。基于该技术可以在不影响业务正常运行的情况下修复内核bug或者安全漏洞以提高运营效率、底层平台的稳定性和可用性并使得业务运营体验有效提升。
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img1.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img1.png)
@ -364,12 +364,12 @@ arm64热补丁功能实现包括内核、编译器、用户态工具几部分。
kpatch在内核中是基于ftrace实现内核函数的替换类似于ftrace的动态探测点不过不是统计某些运行数据而是修改函数的运行序列在函数运行某些额外的代码之后略过旧函数代码并跳转至新函数。框架如下图所示
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img2.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img2.png)
针对arm64架构整个流程可以细化为下图所示
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img3.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img3.png)
@ -377,7 +377,7 @@ kpatch在内核中是基于ftrace实现内核函数的替换类似于ftrace
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img4.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img4.png)
@ -393,18 +393,18 @@ kpatch在内核中是基于ftrace实现内核函数的替换类似于ftrace
**x86机器上**
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img5.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img5.png)
x86机器上如果使用-mfentryelf文件中ftrace跳转指令位于prologue前面在由旧函数跳转到新函数后执行指令流程不会出错。如果使用mcount则在新函数前需要添加stub函数用于处理栈信息等。**arm64机器上**
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img6.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img6.png)
Arm64只支持mcount功能但是arm64 prologue会对寄存器做修改所以无法使用stub函数来适配。所以采用gcc patchable-function-entry来实现类似于mfentry的功能。使用了GCC 8.2.1版本来编译内核rpm包链接地址https://tlinux-mirror.tencent-cloud.com/tlinux/2.4/arm64/tlinux-sclo/aarch64/tl/devtoolset-8/devtoolset-8-gcc-8.2.1-3.tl2.aarch64.rpm 。
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img7.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img7.png)
@ -412,7 +412,7 @@ Arm64只支持mcount功能但是arm64 prologue会对寄存器做修改
热补丁中涉及到修改regs参数所以在ftrace跳转时需要将寄存器入栈所以针对arm64实现了ftrace with regs功能为热补丁功能做准备。x0 ~ x30入栈操作如下
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img8.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img8.png)
@ -421,7 +421,7 @@ Arm64只支持mcount功能但是arm64 prologue会对寄存器做修改
包括ftrace_ops注册删除、模块载入时数据重定位等功能。
重定位简要代码如下:
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img9.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img9.png)
@ -505,7 +505,7 @@ filling_function 在不同的架构下规则不同在arm64架构中主要
首先需要载入kpatch模块然后载入用户态工具生成的新函数模块。通过lsmod查看模块是否载入成功。同时kpatch提供了sysfs接口可以查看载入新函数模块的信息包括新旧函数地址等。可以通过`/sys/kernel/kpatch/xxx/enabled`来卸载模块,恢复执行原函数。
简要操作流程如下:
![img](https://github.com/gxm-newton/TencentOS-kernel/blob/master/images/hot_patch_img10.png)
![img](https://github.com/Tencent/TencentOS-kernel/blob/master/images/hot_patch_img10.png)