1 Star 0 Fork 25

SuperSix173/procps-ng

forked from src-openEuler/procps-ng 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-library-implement-guest-total-tics-change-stat-api.patch 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
From e1df029e6c8bb166a6cec05dc12f699d84631bc9 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sat, 22 Jun 2024 00:00:00 -0500
Subject: [PATCH 1/3] library: implement guest/total tics change, <stat> api
This patch removes guest tics from the total lest they
be counted twice. Such tics have already been included
in user/nice values. For proof, just follow this path:
fs/proc/stat.c: show_stat() --->
kernel/sched/cputime.c: kcpustat_cpu_fetch()
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/339
. Sep, 2020 - where guest distortion occurred
commit ec21588be108d092804eb72edbba2ba214bc6190
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
library/include/stat.h | 6 +++---
library/stat.c | 12 ++++++++----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/library/include/stat.h b/library/include/stat.h
index ff7c5b17..d8ca2add 100644
--- a/library/include/stat.h
+++ b/library/include/stat.h
@@ -45,8 +45,8 @@ enum stat_item {
STAT_TIC_IRQ, // ull_int "
STAT_TIC_SOFTIRQ, // ull_int "
STAT_TIC_STOLEN, // ull_int "
- STAT_TIC_GUEST, // ull_int "
- STAT_TIC_GUEST_NICE, // ull_int "
+ STAT_TIC_GUEST, // ull_int " (note: also included in USER)
+ STAT_TIC_GUEST_NICE, // ull_int " (note: also included in NICE)
STAT_TIC_DELTA_USER, // sl_int derived from above
STAT_TIC_DELTA_NICE, // sl_int "
@@ -63,7 +63,7 @@ enum stat_item {
STAT_TIC_SUM_SYSTEM, // ull_int derived from SYSTEM + IRQ + SOFTIRQ tics
STAT_TIC_SUM_IDLE, // ull_int derived from IDLE + IOWAIT tics
STAT_TIC_SUM_BUSY, // ull_int derived from SUM_TOTAL - SUM_IDLE tics
- STAT_TIC_SUM_TOTAL, // ull_int derived from sum of all 10 tics
+ STAT_TIC_SUM_TOTAL, // ull_int derived from sum of all tics, minus 2 GUEST tics
STAT_TIC_SUM_DELTA_USER, // sl_int derived from above
STAT_TIC_SUM_DELTA_SYSTEM, // sl_int "
diff --git a/library/stat.c b/library/stat.c
index 202dfa52..96672431 100644
--- a/library/stat.c
+++ b/library/stat.c
@@ -572,11 +572,15 @@ static inline void stat_derive_unique (
this->new.xidl
= this->new.idle
+ this->new.iowait;
+ /* note: we exclude guest tics from xtot since ...
+ 'user' already includes 'guest'
+ 'nice' already includes 'gnice'
+ ( see linux sources: ./kernel/sched/cputime.c, kcpustat_cpu_fetch ) */
this->new.xtot
- = this->new.xusr + this->new.xsys + this->new.xidl
- + this->new.stolen
- + this->new.guest
- + this->new.gnice;
+ = this->new.xusr
+ + this->new.xsys
+ + this->new.xidl
+ + this->new.stolen;
this->new.xbsy
= this->new.xtot - this->new.xidl;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SuperSix173/procps-ng.git
git@gitee.com:SuperSix173/procps-ng.git
SuperSix173
procps-ng
procps-ng
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385