From 75267dd103637d38fa95ecdee0eedb16ba0f662c Mon Sep 17 00:00:00 2001 From: Almudena Garcia Date: Sun, 27 Oct 2019 23:14:15 +0100 Subject: patch: add last_processor to thread info structures * include/mach/thread_info.h (thread info structures): Add new member "last_processor" in thread_sched_info. * kern/thread.c (thread management): Fill new member "last_processor" in thread_info() function. --- include/mach/thread_info.h | 1 + kern/thread.c | 13 +++++++++++-- version.m4 | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/mach/thread_info.h b/include/mach/thread_info.h index 60e8ba7f..569c8c84 100644 --- a/include/mach/thread_info.h +++ b/include/mach/thread_info.h @@ -107,6 +107,7 @@ struct thread_sched_info { integer_t cur_priority; /* current priority */ /*boolean_t*/integer_t depressed; /* depressed ? */ integer_t depress_priority; /* priority depressed from */ + integer_t last_processor; /* last processor used by the thread */ }; typedef struct thread_sched_info thread_sched_info_data_t; diff --git a/kern/thread.c b/kern/thread.c index 73d9b5a4..680e72c2 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1580,8 +1580,11 @@ kern_return_t thread_info( else if (flavor == THREAD_SCHED_INFO) { thread_sched_info_t sched_info; - if (*thread_info_count < THREAD_SCHED_INFO_COUNT) { - return KERN_INVALID_ARGUMENT; + /* Allow *thread_info_count to be one smaller than the + usual amount, because last_processor is a + new member that some callers might not know about. */ + if (*thread_info_count < THREAD_SCHED_INFO_COUNT -1) { + return KERN_INVALID_ARGUMENT; } sched_info = (thread_sched_info_t) thread_info_out; @@ -1609,6 +1612,12 @@ kern_return_t thread_info( sched_info->depressed = (thread->depress_priority >= 0); sched_info->depress_priority = thread->depress_priority; +#if NCPUS > 1 + sched_info->last_processor = thread->last_processor; +#else + sched_info->last_processor = 0; +#endif + thread_unlock(thread); splx(s); diff --git a/version.m4 b/version.m4 index d6696d62..1de75037 100644 --- a/version.m4 +++ b/version.m4 @@ -1,4 +1,4 @@ m4_define([AC_PACKAGE_NAME],[GNU Mach]) -m4_define([AC_PACKAGE_VERSION],[1.8]) +m4_define([AC_PACKAGE_VERSION],[1.8+git20190109]) m4_define([AC_PACKAGE_BUGREPORT],[bug-hurd@gnu.org]) m4_define([AC_PACKAGE_TARNAME],[gnumach]) -- cgit v1.2.3