diff --git a/README.md b/README.md index 61b663fd6..f6a738e09 100644 --- a/README.md +++ b/README.md @@ -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的memory,cpuset等子系统中分别添加对应的文件输出,然后由用户通过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下实现cpuinfo,stat文件。 -![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的memory,cpuset等子系统中分别添加对应的文 - 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_sectors,io_serviced, io_wait_time的统计。in_flight,io_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机器上,如果使用-mfentry,elf文件中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)