15 Star 11 Fork 109

src-openEuler/systemd
关闭

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-cgtop-Do-not-rewrite-P-or-k-options.patch 2.40 KB
一键复制 编辑 原始数据 按行查看 历史
wangyuhang 提交于 2023-10-09 20:11 +08:00 . sync patch from systemd community
From 598260221c8184a92098a750bba32aeb56ca2872 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Fri, 25 Nov 2022 17:50:27 +0100
Subject: [PATCH] cgtop: Do not rewrite -P or -k options
--recursive=no will overwrite possible -P or -k option hence making the
recursive disabling impossible.
Check what counting types the system supports (encoded in the ordering
of our enum) of and pick whatever user requests but is also supported.
Fixes: #25248
(cherry picked from commit 48600b3524afe05d0faa8a5c88b5aaa53b801199)
(cherry picked from commit b97c1c427c2156495e141c736babbccabba7265d)
Conflict:NA
Reference:https://github.com/systemd/systemd-stable/commit/598260221c8184a92098a750bba32aeb56ca2872
---
src/cgtop/cgtop.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index b023e71757..29454cd1eb 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -55,6 +55,12 @@ typedef struct Group {
uint64_t io_input_bps, io_output_bps;
} Group;
+typedef enum PidsCount {
+ COUNT_USERSPACE_PROCESSES,
+ COUNT_ALL_PROCESSES,
+ COUNT_PIDS,
+} PidsCount;
+
static unsigned arg_depth = 3;
static unsigned arg_iterations = UINT_MAX;
static bool arg_batch = false;
@@ -65,11 +71,7 @@ static char* arg_root = NULL;
static bool arg_recursive = true;
static bool arg_recursive_unset = false;
-static enum {
- COUNT_PIDS,
- COUNT_USERSPACE_PROCESSES,
- COUNT_ALL_PROCESSES,
-} arg_count = COUNT_PIDS;
+static PidsCount arg_count = COUNT_PIDS;
static enum {
ORDER_PATH,
@@ -913,6 +915,7 @@ static int run(int argc, char *argv[]) {
usec_t last_refresh = 0;
bool quit = false, immediate_refresh = false;
_cleanup_free_ char *root = NULL;
+ PidsCount possible_count;
CGroupMask mask;
int r;
@@ -926,7 +929,8 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to determine supported controllers: %m");
- arg_count = (mask & CGROUP_MASK_PIDS) ? COUNT_PIDS : COUNT_USERSPACE_PROCESSES;
+ possible_count = (mask & CGROUP_MASK_PIDS) ? COUNT_PIDS : COUNT_ALL_PROCESSES;
+ arg_count = MIN(possible_count, arg_count);
if (arg_recursive_unset && arg_count == COUNT_PIDS)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/systemd.git
git@gitee.com:src-openeuler/systemd.git
src-openeuler
systemd
systemd
3b23f9ffafa40dc89ef6591685566269cb9a88ee

搜索帮助