From 42d81bfc739a8e1cf6d3b5a2c55b79e0a766d72d Mon Sep 17 00:00:00 2001 From: panfengyun Date: Sun, 21 Sep 2014 15:46:17 +0800 Subject: [PATCH] ignore tgid bsearch failures it's not worth canceling the whole command with an error(FATAL...) when such an anomoly occurs on a live system. So it should be imply ignored tgid bsearch failures on live systems, and just use the RSS stats stored in the per-tgid mm_struct. --- crash-7.0.8/memory.c | 91 ++++++++++++++++++++++++------------------------- 1 files changed, 45 insertions(+), 46 deletions(-) diff --git a/crash-7.0.8/memory.c b/crash-7.0.8/memory.c index 518c917..c046b10 100755 --- a/crash-7.0.8/memory.c +++ b/crash-7.0.8/memory.c @@ -4187,54 +4187,53 @@ 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) + if (tg != NULL) { - /* 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; + /* 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; + } } /* -- 1.7.1