commit a3a441aeabd6c5c3c86b4793a283927507a5cc10
Author: Dave Anderson <anderson@redhat.com>
Date: Mon Sep 22 16:25:16 2014 -0400
Fix for the "ps" command performance degradation patch the was
introduced in crash-7.0.8. Without this patch, it is possible that
the "ps" command may fail prematurely with the error message
"ps: bsearch for tgid failed: task: <address> tgid: <number>"
when running on a live system or against a "live" dumpfile.
(panfy.fnst@cn.fujitsu.com)
diff --git a/memory.c b/memory.c
index 518c917..2376e6f 100644
--- a/memory.c
+++ b/memory.c
@@ -4187,54 +4187,52 @@ get_task_mem_usage(ulong task, struct task_mem_usage *tm)
tg = (struct tgid_context *)bsearch(&tgid, tgid_array, RUNNING_TASKS(),
sizeof(struct tgid_context), sort_by_tgid);
- if (tg == NULL)
- error(FATAL, "bsearch for tgid failed: task: %lx tgid: %ld\n",
- task, tgid.tgid);
-
- /* find the first element which has the same tgid */
- first = tg;
- while ((first > tgid_array) && ((first - 1)->tgid == first->tgid))
- first--;
-
- /* find the last element which have same tgid */
- last = tg;
- while ((last < (tgid_array + (RUNNING_TASKS() - 1))) &&
- (last->tgid == (last + 1)->tgid))
- last++;
-
- while (first <= last)
- {
- /* count 0 -> filepages */
- if (!readmem(first->task +
- OFFSET(task_struct_rss_stat) +
- OFFSET(task_rss_stat_count), KVADDR,
- &sync_rss,
- sizeof(int),
- "task_struct rss_stat MM_FILEPAGES",
- RETURN_ON_ERROR))
- continue;
+ if (tg) {
+ /* find the first element which has the same tgid */
+ first = tg;
+ while ((first > tgid_array) && ((first - 1)->tgid == first->tgid))
+ first--;
+
+ /* find the last element which have same tgid */
+ last = tg;
+ while ((last < (tgid_array + (RUNNING_TASKS() - 1))) &&
+ (last->tgid == (last + 1)->tgid))
+ last++;
+
+ while (first <= last)
+ {
+ /* count 0 -> filepages */
+ if (!readmem(first->task +
+ OFFSET(task_struct_rss_stat) +
+ OFFSET(task_rss_stat_count), KVADDR,
+ &sync_rss,
+ sizeof(int),
+ "task_struct rss_stat MM_FILEPAGES",
+ RETURN_ON_ERROR))
+ continue;
- rss += sync_rss;
-
- /* count 1 -> anonpages */
- if (!readmem(first->task +
- OFFSET(task_struct_rss_stat) +
- OFFSET(task_rss_stat_count) +
- sizeof(int),
- KVADDR, &sync_rss,
- sizeof(int),
- "task_struct rss_stat MM_ANONPAGES",
- RETURN_ON_ERROR))
- continue;
+ rss += sync_rss;
+
+ /* count 1 -> anonpages */
+ if (!readmem(first->task +
+ OFFSET(task_struct_rss_stat) +
+ OFFSET(task_rss_stat_count) +
+ sizeof(int),
+ KVADDR, &sync_rss,
+ sizeof(int),
+ "task_struct rss_stat MM_ANONPAGES",
+ RETURN_ON_ERROR))
+ continue;
- rss += sync_rss;
+ rss += sync_rss;
- if(first == last)
- break;
- first++;
- }
+ if (first == last)
+ break;
+ first++;
+ }
- tt->last_tgid = last;
+ tt->last_tgid = last;
+ }
}
/*
commit 62b294b27ce08decb63b204aeb9c6d3d5ace96b2
Author: Dave Anderson <anderson@redhat.com>
Date: Fri Sep 19 14:20:57 2014 -0400
Fix for the one-time (dumpfile), or as-required (live system),
gathering of tasks from the kernel pid_hash[] in 2.6.24 and later
kernels. Without the patch, if an entry in a pid_hash[] chain is
not related to the "init_pid_ns" pid_namespace structure, any
remaining entries in the hlist chain are skipped.
(vvs@parallels.com)
diff --git a/task.c b/task.c
index b33c96a..66f2e0a 100644
--- a/task.c
+++ b/task.c
@@ -2033,7 +2033,7 @@ do_chained:
* Use init_pid_ns level 0 (PIDTYPE_PID).
*/
if (upid_ns != tt->init_pid_ns)
- continue;
+ goto chain_next;
pid = upid - OFFSET(pid_numbers);