summaryrefslogtreecommitdiff
path: root/debian/patches/tune-struct-thread.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/tune-struct-thread.patch')
-rw-r--r--debian/patches/tune-struct-thread.patch185
1 files changed, 185 insertions, 0 deletions
diff --git a/debian/patches/tune-struct-thread.patch b/debian/patches/tune-struct-thread.patch
new file mode 100644
index 0000000..5dedc00
--- /dev/null
+++ b/debian/patches/tune-struct-thread.patch
@@ -0,0 +1,185 @@
+commit 160d07d776a8163914ff74acab1887b035ea3691
+Author: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue Sep 30 09:08:44 2014 +0200
+
+ XXX reduce struct thread size
+
+diff --git a/kern/ipc_sched.c b/kern/ipc_sched.c
+index cc1672d..be82971 100644
+--- a/kern/ipc_sched.c
++++ b/kern/ipc_sched.c
+@@ -268,7 +268,7 @@ thread_handoff(
+ */
+ old->wake_active = FALSE;
+ thread_unlock(old);
+- thread_wakeup((event_t)&old->wake_active);
++ thread_wakeup(TH_EV_WAKE_ACTIVE(old));
+ goto after_old_thread;
+ }
+ } else
+diff --git a/kern/sched_prim.c b/kern/sched_prim.c
+index 376217a..d7792ae 100644
+--- a/kern/sched_prim.c
++++ b/kern/sched_prim.c
+@@ -615,7 +615,7 @@ boolean_t thread_invoke(
+ thread_lock(new_thread);
+ new_thread->state &= ~TH_UNINT;
+ thread_unlock(new_thread);
+- thread_wakeup(&new_thread->state);
++ thread_wakeup(TH_EV_STATE(new_thread));
+
+ if (continuation != (void (*)()) 0) {
+ (void) spl0();
+@@ -637,7 +637,7 @@ boolean_t thread_invoke(
+
+ new_thread->state &= ~(TH_SWAPPED | TH_UNINT);
+ thread_unlock(new_thread);
+- thread_wakeup(&new_thread->state);
++ thread_wakeup(TH_EV_STATE(new_thread));
+
+ #if NCPUS > 1
+ new_thread->last_processor = current_processor();
+@@ -676,7 +676,7 @@ boolean_t thread_invoke(
+ if (old_thread->wake_active) {
+ old_thread->wake_active = FALSE;
+ thread_unlock(old_thread);
+- thread_wakeup((event_t)&old_thread->wake_active);
++ thread_wakeup(TH_EV_WAKE_ACTIVE(old_thread));
+
+ goto after_old_thread;
+ }
+@@ -767,7 +767,7 @@ boolean_t thread_invoke(
+
+ new_thread->state &= ~(TH_SWAPPED | TH_UNINT);
+ thread_unlock(new_thread);
+- thread_wakeup(&new_thread->state);
++ thread_wakeup(TH_EV_STATE(new_thread));
+
+ /*
+ * Thread is now interruptible.
+@@ -932,7 +932,7 @@ void thread_dispatch(
+ if (thread->wake_active) {
+ thread->wake_active = FALSE;
+ thread_unlock(thread);
+- thread_wakeup((event_t)&thread->wake_active);
++ thread_wakeup(TH_EV_WAKE_ACTIVE(thread));
+ return;
+ }
+ break;
+diff --git a/kern/thread.c b/kern/thread.c
+index 8474950..f49811e 100644
+--- a/kern/thread.c
++++ b/kern/thread.c
+@@ -968,7 +968,7 @@ kern_return_t thread_halt(
+ * operation can never cause a deadlock.)
+ */
+ if (cur_thread->ast & AST_HALT) {
+- thread_wakeup_with_result((event_t)&cur_thread->wake_active,
++ thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(cur_thread),
+ THREAD_INTERRUPTED);
+ thread_unlock(thread);
+ thread_unlock(cur_thread);
+@@ -1006,7 +1006,7 @@ kern_return_t thread_halt(
+ */
+ while ((thread->ast & AST_HALT) && (!(thread->state & TH_HALTED))) {
+ thread->wake_active = TRUE;
+- thread_sleep((event_t) &thread->wake_active,
++ thread_sleep(TH_EV_WAKE_ACTIVE(thread),
+ simple_lock_addr(thread->lock), TRUE);
+
+ if (thread->state & TH_HALTED) {
+@@ -1045,7 +1045,7 @@ kern_return_t thread_halt(
+ s = splsched();
+ thread_lock(thread);
+ thread_ast_clear(thread, AST_HALT);
+- thread_wakeup_with_result((event_t)&thread->wake_active,
++ thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(thread),
+ THREAD_INTERRUPTED);
+ thread_unlock(thread);
+ (void) splx(s);
+@@ -1284,7 +1284,7 @@ thread_dowait(
+ * Check for failure if interrupted.
+ */
+ thread->wake_active = TRUE;
+- thread_sleep((event_t) &thread->wake_active,
++ thread_sleep(TH_EV_WAKE_ACTIVE(thread),
+ simple_lock_addr(thread->lock), TRUE);
+ thread_lock(thread);
+ if ((current_thread()->wait_result != THREAD_AWAKENED) &&
+@@ -1308,7 +1308,7 @@ thread_dowait(
+ (void) splx(s);
+
+ if (need_wakeup)
+- thread_wakeup((event_t) &thread->wake_active);
++ thread_wakeup(TH_EV_WAKE_ACTIVE(thread));
+
+ return ret;
+ }
+@@ -1346,7 +1346,7 @@ kern_return_t thread_suspend(
+ thread_lock(thread);
+ /* Wait for thread to get interruptible */
+ while (thread->state & TH_UNINT) {
+- assert_wait(&thread->state, TRUE);
++ assert_wait(TH_EV_STATE(thread), TRUE);
+ thread_unlock(thread);
+ thread_block(NULL);
+ thread_lock(thread);
+diff --git a/kern/thread.h b/kern/thread.h
+index d088c27..fbb7912 100644
+--- a/kern/thread.h
++++ b/kern/thread.h
+@@ -70,6 +70,21 @@ struct thread {
+ task_t task; /* Task to which I belong */
+ queue_chain_t thread_list; /* list of threads in task */
+
++ /* Flags */
++ /* The flags are grouped here, but documented at the original
++ position. */
++ union {
++ struct {
++ unsigned state:16;
++ unsigned wake_active:1;
++ unsigned vm_privilege:1;
++ unsigned active:1;
++ };
++ event_t event_key;
++#define TH_EV_WAKE_ACTIVE(t) ((event_t) (&(t)->event_key + 0))
++#define TH_EV_STATE(t) ((event_t) (&(t)->event_key + 1))
++ };
++
+ /* Thread bookkeeping */
+ queue_chain_t pset_threads; /* list of all threads in proc set*/
+
+@@ -92,9 +107,10 @@ struct thread {
+ kern_return_t wait_result; /* outcome of wait -
+ may be examined by this thread
+ WITHOUT locking */
+- boolean_t wake_active; /* someone is waiting for this
++ /* Defined above */
++ /* boolean_t wake_active; someone is waiting for this
+ thread to become suspended */
+- int state; /* Thread state: */
++ /* int state; Thread state: */
+ /*
+ * Thread states [bits or'ed]
+ */
+@@ -129,7 +145,8 @@ struct thread {
+ /* VM global variables */
+
+ vm_offset_t recover; /* page fault recovery (copyin/out) */
+- boolean_t vm_privilege; /* Can use reserved memory? */
++ /* Defined above */
++ /* boolean_t vm_privilege; Can use reserved memory? */
+
+ /* User-visible scheduling state */
+ int user_stop_count; /* outstanding stops */
+@@ -194,7 +211,8 @@ struct thread {
+ timer_elt_data_t depress_timer; /* timer for priority depression */
+
+ /* Ast/Halt data structures */
+- boolean_t active; /* how alive is the thread */
++ /* Defined above */
++ /* boolean_t active; how alive is the thread */
+ int ast; /* ast's needed. See ast.h */
+
+ /* Processor data structures */