diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | proc/info.c | 8 | ||||
-rw-r--r-- | procfs/process.c | 12 |
3 files changed, 23 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index d0d03e8d..afa7e1e5 100644 --- a/configure.ac +++ b/configure.ac @@ -347,6 +347,10 @@ AS_IF([test "x$with_libdaemon" != xno], [ AC_SUBST([libdaemon_LIBS]) AC_SUBST([libdaemon_CFLAGS]) + +AC_CHECK_MEMBERS([struct thread_sched_info.last_processor],,, + [#include <mach/thread_info.h]) + PKG_CHECK_MODULES([libblkid], [blkid], [AC_DEFINE([HAVE_BLKID], [1], [Use libblkid])], [true]) diff --git a/proc/info.c b/proc/info.c index f2e60114..2ea2a114 100644 --- a/proc/info.c +++ b/proc/info.c @@ -713,6 +713,14 @@ S_proc_getprocinfo (struct proc *callerp, *flags &= ~PI_FETCH_THREAD_SCHED; err = 0; } + +#ifdef HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR + /* If the structure read doesn't include last_processor field, assume + CPU 0. */ + if (thcount < 8) + thds[i]->last_processor = 0; +#endif + } /* Note that there are thread wait entries only for those threads diff --git a/procfs/process.c b/procfs/process.c index 59653b24..f6d3a730 100644 --- a/procfs/process.c +++ b/procfs/process.c @@ -221,6 +221,7 @@ process_file_gc_stat (struct proc_stat *ps, char **contents) struct procinfo *pi = proc_stat_proc_info (ps); task_basic_info_t tbi = proc_stat_task_basic_info (ps); thread_basic_info_t thbi = proc_stat_thread_basic_info (ps); + thread_sched_info_t thsi = proc_stat_thread_sched_info (ps); const char *fn = args_filename (proc_stat_args (ps)); vm_address_t start_code = 1; /* 0 would make killall5.c consider it @@ -229,6 +230,15 @@ process_file_gc_stat (struct proc_stat *ps, char **contents) vm_address_t end_code = 1; process_t p; error_t err = proc_pid2proc (ps->context->server, ps->pid, &p); + + long unsigned last_processor; + +#ifdef HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR + last_processor = thsi->last_processor; +#else + last_processor = 0; +#endif + if (! err) { boolean_t essential = 0; @@ -286,7 +296,7 @@ process_file_gc_stat (struct proc_stat *ps, char **contents) (long unsigned) proc_stat_thread_rpc (ps), /* close enough */ 0L, 0L, 0, - 0, + last_processor, 0, 0, 0LL); } |