Hello Pan, The patch looks to run OK. Here are my comments and suggestions: # make warn cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_7_6 memory.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security memory.c: In function 'get_task_mem_usage': memory.c:4157:10: warning: variable 'tgid' set but not used [-Wunused-but-set-variable] ... And speaking of tgid, I don't see why it's necessary to keep two copies of the tgid:? @@ -758,13 +758,23 @@ struct task_context { /* context stored for each task */ int processor; ulong ptask; ulong mm_struct; + ulong tgid; + ulong tgid_task_context_index; struct task_context *tc_next; }; +struct tgid_task_context{ /* context and tgid stored for each task */ + ulong tgid; + struct task_context *tc; +}; + These 3 functions are always called together, in task_init(), and in exec_command() if (ct->flags & REFRESH_TASK_TABLE): tt->refresh_task_table() -> calls store_context() sort_context_array() set_tgid_context_array() It would seem that store_context(), which reads the tgid value, could call a new function, say, something like: store_tgid_context(struct task_context *tc, ulong tgid); The store_tgid_context() function could determine the index into the tt->context_array from the address "tc", and therefore could populate both fields of each tgid_task_context array entry. Then, the set_tgid_context_array() function could be renamed to sort_tgid_context_array() and it could just do the sorting operation on the array that has already been initialized. Unfortunately I can't see a obvious way to remove the new tc->tgid_context_index field... Another question: why is it necessary to call sort_tgid_context_array() both here: @ -2916,7 +2981,10 @@ cmd_ps(void) cmd_usage(pc->curcmd, SYNOPSIS); if (flag & (PS_LAST_RUN|PS_MSECS)) + { sort_context_array_by_last_run(); + set_tgid_context_array(); + } and here: @@ -5966,7 +6034,10 @@ foreach(struct foreach_data *fd) } } if (fd->flags & (FOREACH_l_FLAG|FOREACH_m_FLAG)) + { sort_context_array_by_last_run(); + set_tgid_context_array(); + The "ps -l" and "ps -m" options don't need anything in the tgid_context_array, and everything will get re-sorted when the next "ps" command is attempted. Lastly, the tgid_task_context array should be dumped at the end of the "help -T" display after the task_context array. Dave -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility