[PATCH] task.c: avoid unnecessary cpu cycles during init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While stkptr_to_task does the job of trying to match a stack pointer
to a task, it runs through each task's stack to find whether the given
SP falls into its range. This can be a very expensive operation, if
the vmcore is from a system running too many tasks. It can get even
worse when the total number of CPUs on the system is in the order of
thousands. Given the expensive nature of the operation, it must be
optimized as much as possible. Possible options to optimize:

  1) Get min & max of the stack range in first pass and use these
     values against the given SP to decide whether or not to proceed
     with stack lookup.
  2) Use multithreading to parallely update irq_tasks.
  3) Skip stkptr_to_task() when SP is 0

Though option 3 is a low hanging fruit, it significantly improved the
time taken between starting crash utility & reaching crash prompt.
Implement option 3 to optimize while listing the other two options
as TODO items for follow-up.

Signed-off-by: Hari Bathini <hbathini@xxxxxxxxxxxxx>
---

On a system with about 1500 CPUs 165K running tasks, it was taking
about a day to get to the crash prompt without this patch, while it
takes only about 5-10 mins with this change.. 


 task.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/task.c b/task.c
index 8dd2b96..423cd45 100644
--- a/task.c
+++ b/task.c
@@ -713,6 +713,7 @@ irqstacks_init(void)
 	} else 
 		error(WARNING, "cannot determine hardirq_ctx addresses\n");
 
+	/* TODO: Use multithreading to parallely update irq_tasks. */
 	for (i = 0; i < NR_CPUS; i++) {
 		if (!(tt->hardirq_ctx[i]))
 			continue;
@@ -5005,6 +5006,10 @@ pid_exists(ulong pid)
 /*
  *  Translate a stack pointer to a task, dealing with possible split.
  *  If that doesn't work, check the hardirq_stack and softirq_stack.
+ *
+ * TODO: This function can be optimized by getting min & max of the
+ *       stack range in first pass and use these values against the
+ *       given SP to decide whether or not to proceed with stack lookup.
  */
 ulong
 stkptr_to_task(ulong sp)
@@ -5013,6 +5018,9 @@ stkptr_to_task(ulong sp)
         struct task_context *tc;
 	struct bt_info bt_info, *bt;
 
+	if (!sp)
+		return NO_TASK;
+
 	bt = &bt_info;
         tc = FIRST_CONTEXT();
         for (i = 0; i < RUNNING_TASKS(); i++, tc++) {


--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux