library: restore the proper main thread tics valuation
fix issue: https://gitee.com/src-openeuler/procps-ng/issues/I7K6HH Signed-off-by: Fengfei Xi <xi.fengfei@h3c.com>
This commit is contained in:
parent
46424d9aec
commit
5e1b8d9b8a
@ -0,0 +1,95 @@
|
||||
From bc688d630aeeeda5e003d35bbcfcdba08f21b399 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed, 31 May 2023 00:00:00 -0500
|
||||
Subject: [PATCH] library: restore the proper main thread tics valuation
|
||||
|
||||
The issue cited below revealed an earlier commit, also
|
||||
shown below, resulted in an incorrect tics value for a
|
||||
thread group leader. That change was made so the group
|
||||
leader would have a proper autogroup id, not a -1 that
|
||||
was shown with sibling threads which lacked that file.
|
||||
|
||||
So this patch will just restore pre version 4 behavior
|
||||
while not upsetting LIBPROC_HIDE_KERNEL functionality.
|
||||
|
||||
[ this change means that when THREAD mode is active, ]
|
||||
[ the autogroup id & nice values won't be available. ]
|
||||
[ they were only shown for the group leaders anyway. ]
|
||||
|
||||
Reference(s):
|
||||
https://gitlab.com/procps-ng/procps/-/issues/280
|
||||
. Aug, 2021 - thread group leader change
|
||||
commit a37526260917bac624ae6b75fd9f4ea7287d81ad
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
library/readproc.c | 23 ++++++++++++-----------
|
||||
1 files changed, 12 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/library/readproc.c b/library/readproc.c
|
||||
index 94030e94..2dfe4c9e 100644
|
||||
--- a/library/readproc.c
|
||||
+++ b/library/readproc.c
|
||||
@@ -1361,7 +1361,14 @@ static proc_t *simple_readtask(PROCTAB *restrict const PT, proc_t *restrict cons
|
||||
if (flags & PROC_FILLAUTOGRP) // value the 2 autogroup fields
|
||||
autogroup_fill(path, t);
|
||||
|
||||
- if (rc == 0) return t;
|
||||
+ // openproc() ensured that a ppid will be present when needed ...
|
||||
+ if (rc == 0) {
|
||||
+ if (PT->hide_kernel && (t->ppid == 2 || t->tid == 2)) {
|
||||
+ free_acquired(t);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return t;
|
||||
+ }
|
||||
errno = ENOMEM;
|
||||
next_task:
|
||||
return NULL;
|
||||
@@ -1463,7 +1470,6 @@ proc_t *readproc(PROCTAB *restrict const PT, proc_t *restrict p) {
|
||||
free_acquired(p);
|
||||
|
||||
for(;;){
|
||||
- if (errno == ENOMEM) goto out;
|
||||
// fills in the path, plus p->tid and p->tgid
|
||||
if (!PT->finder(PT,p)) goto out;
|
||||
|
||||
@@ -1484,7 +1490,7 @@ out:
|
||||
proc_t *readeither (PROCTAB *restrict const PT, proc_t *restrict x) {
|
||||
static __thread proc_t skel_p; // skeleton proc_t, only uses tid + tgid
|
||||
static __thread proc_t *new_p; // for process/task transitions
|
||||
- static __thread int canary, leader;
|
||||
+ static __thread int canary;
|
||||
char path[PROCPATHLEN];
|
||||
proc_t *ret;
|
||||
|
||||
@@ -1498,23 +1504,18 @@ proc_t *readeither (PROCTAB *restrict const PT, proc_t *restrict x) {
|
||||
next_proc:
|
||||
new_p = NULL;
|
||||
for (;;) {
|
||||
- if (errno == ENOMEM) goto end_procs;
|
||||
// fills in the PT->path, plus skel_p.tid and skel_p.tgid
|
||||
if (!PT->finder(PT,&skel_p)) goto end_procs; // simple_nextpid
|
||||
- leader = skel_p.tid;
|
||||
if (!task_dir_missing) break;
|
||||
if ((ret = PT->reader(PT,x))) return ret; // simple_readproc
|
||||
}
|
||||
|
||||
next_task:
|
||||
// fills in our path, plus x->tid and x->tgid
|
||||
- if (!(PT->taskfinder(PT,&skel_p,x,path))) // simple_nexttid
|
||||
+ if ((!(PT->taskfinder(PT,&skel_p,x,path))) // simple_nexttid
|
||||
+ || (!(ret = PT->taskreader(PT,x,path)))) { // simple_readtask
|
||||
goto next_proc;
|
||||
- /* to avoid loss of some thread group leader data,
|
||||
- we must check its base dir, not its 'task' dir! */
|
||||
- if (x->tid == leader) ret = PT->reader(PT,x); // simple_readproc
|
||||
- else ret = PT->taskreader(PT,x,path); // simple_readtask
|
||||
- if (!ret) goto next_proc;
|
||||
+ }
|
||||
if (!new_p) {
|
||||
new_p = ret;
|
||||
canary = new_p->tid;
|
||||
--
|
||||
GitLab
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: procps-ng
|
||||
Version: 4.0.2
|
||||
Release: 6
|
||||
Release: 7
|
||||
Summary: Utilities that provide system information.
|
||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||
URL: https://sourceforge.net/projects/procps-ng/
|
||||
@ -18,6 +18,7 @@ Patch6: backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patc
|
||||
Patch7: backport-top-lessen-summary-cpu-distortions-with-first-displa.patch
|
||||
Patch8: backport-pmap-Increase-memory-allocation-failure-judgment.patch
|
||||
Patch9: backport-top-added-guest-tics-when-multiple-cpus-were-merged.patch
|
||||
Patch10: backport-library-restore-the-proper-main-thread-tics-valuation.patch
|
||||
|
||||
BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel
|
||||
|
||||
@ -100,6 +101,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
||||
%{_mandir}/man*
|
||||
|
||||
%changelog
|
||||
* Tue Jul 11 2023 Xi Fnegfei <xi.fengfei@h3c.com> - 4.0.2-7
|
||||
- library: restore the proper main thread tics valuation
|
||||
|
||||
* Wed Jun 28 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-6
|
||||
- top: added guest tics when multiple cpus were merged
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user