[kernel] Clean up dead code related to Thread.
Test: k thread_tests
Change-Id: I75d7a2c6f2a3b3a6b109e6f2124c923543ea8770
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/374200
Reviewed-by: George Kulakowski <kulakowski@google.com>
Reviewed-by: Nick Maniscalco <maniscalco@google.com>
Commit-Queue: Corey Tabaka <eieio@google.com>
Testability-Review: Nick Maniscalco <maniscalco@google.com>
diff --git a/zircon/kernel/include/kernel/thread.h b/zircon/kernel/include/kernel/thread.h
index d32cf24..84238c3 100644
--- a/zircon/kernel/include/kernel/thread.h
+++ b/zircon/kernel/include/kernel/thread.h
@@ -57,10 +57,8 @@
// clang-format off
#define THREAD_FLAG_DETACHED (1 << 0)
#define THREAD_FLAG_FREE_STRUCT (1 << 1)
-#define THREAD_FLAG_REAL_TIME (1 << 2)
-#define THREAD_FLAG_IDLE (1 << 3)
-#define THREAD_FLAG_NO_BOOST (1 << 4)
-#define THREAD_FLAG_VCPU (1 << 5)
+#define THREAD_FLAG_IDLE (1 << 2)
+#define THREAD_FLAG_VCPU (1 << 3)
#define THREAD_SIGNAL_KILL (1 << 0)
#define THREAD_SIGNAL_SUSPEND (1 << 1)
@@ -140,7 +138,6 @@
void SetCurrent();
void SetUsermodeThread(ThreadDispatcher* user_thread);
- zx_status_t SetRealTime();
// Called to mark a thread as schedulable.
void Resume();
@@ -208,28 +205,7 @@
cpu_num_t LastCpu() const TA_EXCL(thread_lock);
// Return true if thread has been signaled.
bool IsSignaled() { return signals_ != 0; }
- bool IsRealtime() const {
- return (flags_ & THREAD_FLAG_REAL_TIME) && base_priority_ > DEFAULT_PRIORITY;
- }
bool IsIdle() const { return !!(flags_ & THREAD_FLAG_IDLE); }
- bool IsRealTimeOrIdle() const { return !!(flags_ & (THREAD_FLAG_REAL_TIME | THREAD_FLAG_IDLE)); }
- // A thread may not participate in the scheduler's boost behavior if it is...
- //
- // 1) flagged as real-time
- // 2) flagged as idle
- // 3) flagged as "no boost"
- //
- // Note that flag #3 should *only* ever be used by kernel test code when
- // attempting to test priority inheritance chain propagation. It is important
- // that these tests maintain rigorous control of the relationship between base
- // priority, inherited priority, and the resulting effective priority. Allowing
- // the scheduler to introduce the concept of dynamic boost priority into the
- // calculation of effective priority makes writing tests like this more
- // difficult which is why we have an internal flag which can be used for
- // disabling this behavior.
- bool CannotBoost() const {
- return !!(flags_ & (THREAD_FLAG_REAL_TIME | THREAD_FLAG_IDLE | THREAD_FLAG_NO_BOOST));
- }
// All of these operations implicitly operate on the current thread.
struct Current {
@@ -428,14 +404,12 @@
// priority: in the range of [MIN_PRIORITY, MAX_PRIORITY], from low to high.
// base_priority is set at creation time, and can be tuned with thread_set_priority().
- // priority_boost is a signed value that is moved around within a range by the scheduler.
// inherited_priority is temporarily set to >0 when inheriting a priority from another
// thread blocked on a locking primitive this thread holds. -1 means no inherit.
- // effective_priority is MAX(base_priority + priority boost, inherited_priority) and is
- // the working priority for run queue decisions.
+ // effective_priority is MAX(base_priority, inherited_priority) and is the working
+ // priority for run queue decisions.
int effec_priority_;
int base_priority_;
- int priority_boost_;
int inherited_priority_;
SchedulerState scheduler_state_;
diff --git a/zircon/kernel/kernel/scheduler.cc b/zircon/kernel/kernel/scheduler.cc
index 1129375..6f531ec 100644
--- a/zircon/kernel/kernel/scheduler.cc
+++ b/zircon/kernel/kernel/scheduler.cc
@@ -320,7 +320,6 @@
thread->base_priority_ = priority;
thread->effec_priority_ = priority;
thread->inherited_priority_ = -1;
- thread->priority_boost_ = 0;
thread->scheduler_state_.expected_runtime_ns_ = kDefaultTargetLatency;
}
@@ -335,7 +334,6 @@
thread->base_priority_ = HIGHEST_PRIORITY;
thread->effec_priority_ = HIGHEST_PRIORITY;
thread->inherited_priority_ = -1;
- thread->priority_boost_ = 0;
thread->scheduler_state_.expected_runtime_ns_ = SchedDuration{params.capacity};
}
@@ -1613,7 +1611,6 @@
// deadline scheduler is available and remove this conversion once the
// kernel uses the abstraction throughout.
const int original_priority_ = thread->effec_priority_;
- thread->priority_boost_ = 0;
thread->base_priority_ = priority;
thread->effec_priority_ = ktl::max(thread->base_priority_, thread->inherited_priority_);
@@ -1648,7 +1645,6 @@
// TODO(eieio): Replace this with actual deadline PI.
const int original_priority_ = thread->effec_priority_;
thread->base_priority_ = HIGHEST_PRIORITY;
- thread->priority_boost_ = 0;
thread->inherited_priority_ = -1;
thread->effec_priority_ = thread->base_priority_;
@@ -1676,7 +1672,6 @@
}
const int original_priority_ = thread->effec_priority_;
- thread->priority_boost_ = 0;
thread->inherited_priority_ = priority;
thread->effec_priority_ = ktl::max(thread->base_priority_, thread->inherited_priority_);
diff --git a/zircon/kernel/kernel/thread.cc b/zircon/kernel/kernel/thread.cc
index a40bf81..22f4b8f 100644
--- a/zircon/kernel/kernel/thread.cc
+++ b/zircon/kernel/kernel/thread.cc
@@ -260,26 +260,6 @@
}
/**
- * @brief Flag a thread as real time
- *
- * @return ZX_OK on success
- */
-zx_status_t Thread::SetRealTime() {
- DEBUG_ASSERT(magic_ == THREAD_MAGIC);
-
- {
- Guard<spin_lock_t, IrqSave> guard{ThreadLock::Get()};
- if (this == Thread::Current::Get()) {
- // if we're currently running, cancel the preemption timer.
- TimerQueue::PreemptCancel();
- }
- flags_ |= THREAD_FLAG_REAL_TIME;
- }
-
- return ZX_OK;
-}
-
-/**
* @brief Make a suspended thread executable.
*
* This function is called to start a thread which has just been
@@ -1374,17 +1354,16 @@
dprintf(INFO, "dump_thread: t %p (%s:%s)\n", t, oname, t->name_);
dprintf(INFO,
"\tstate %s, curr/last cpu %d/%d, hard_affinity %#x, soft_cpu_affinity %#x, "
- "priority %d [%d:%d,%d], remaining time slice %" PRIi64 "\n",
+ "priority %d [%d,%d], remaining time slice %" PRIi64 "\n",
thread_state_to_str(t->state_), (int)t->curr_cpu_, (int)t->last_cpu_, t->hard_affinity_,
- t->soft_affinity_, t->effec_priority_, t->base_priority_, t->priority_boost_,
- t->inherited_priority_, t->remaining_time_slice_);
+ t->soft_affinity_, t->effec_priority_, t->base_priority_, t->inherited_priority_,
+ t->remaining_time_slice_);
dprintf(INFO, "\truntime_ns %" PRIi64 ", runtime_s %" PRIi64 "\n", runtime,
runtime / 1000000000);
t->stack_.DumpInfo(INFO);
- dprintf(INFO, "\tentry %p, arg %p, flags 0x%x %s%s%s%s%s\n", t->entry_, t->arg_, t->flags_,
+ dprintf(INFO, "\tentry %p, arg %p, flags 0x%x %s%s%s%s\n", t->entry_, t->arg_, t->flags_,
(t->flags_ & THREAD_FLAG_DETACHED) ? "Dt" : "",
(t->flags_ & THREAD_FLAG_FREE_STRUCT) ? "Ft" : "",
- (t->flags_ & THREAD_FLAG_REAL_TIME) ? "Rt" : "",
(t->flags_ & THREAD_FLAG_IDLE) ? "Id" : "", (t->flags_ & THREAD_FLAG_VCPU) ? "Vc" : "");
dprintf(INFO, "\twait queue %p, blocked_status %d, interruptable %d, wait queues owned %s\n",
@@ -1396,10 +1375,9 @@
t->user_pid_, t->user_tid_);
arch_dump_thread(t);
} else {
- printf("thr %p st %4s owq %d pri %2d [%d:%d,%d] pid %" PRIu64 " tid %" PRIu64 " (%s:%s)\n", t,
+ printf("thr %p st %4s owq %d pri %2d [%d,%d] pid %" PRIu64 " tid %" PRIu64 " (%s:%s)\n", t,
thread_state_to_str(t->state_), !t->owned_wait_queues_.is_empty(), t->effec_priority_,
- t->base_priority_, t->priority_boost_, t->inherited_priority_, t->user_pid_,
- t->user_tid_, oname, t->name_);
+ t->base_priority_, t->inherited_priority_, t->user_pid_, t->user_tid_, oname, t->name_);
}
}
diff --git a/zircon/kernel/tests/pi_tests.cc b/zircon/kernel/tests/pi_tests.cc
index dd81622..a89b40f 100644
--- a/zircon/kernel/tests/pi_tests.cc
+++ b/zircon/kernel/tests/pi_tests.cc
@@ -241,12 +241,6 @@
// priority inheritance chains, and then evaluate that the effective priorities
// of the threads involved in the graph are what we expect them to be after
// various mutations of the graph have taken place.
-//
-// Threads involved in these tests need to opt out of the scheduler's boosting
-// behavior. In order to achieve this, these are the only threads in the system
-// which should ever set the NO_BOOST flag in their flags. They do this by
-// directly manipulating their flags member after being created, but before
-// being started.
class TestThread {
public:
enum class State : uint32_t {
@@ -385,15 +379,6 @@
ASSERT_NONNULL(thread_);
- // Set the NO_BOOST flag on this thread so that the scheduler does not apply
- // any priority boost and we end up with deterministic effective priority
- // behavior.
- //
- // Note, the pattern here of reaching in and manipulating this flag directly
- // is *not* something to be emulated. The NO_BOOST flag is not something
- // which should have an API, or be used by anything but very specific test
- // code.
- thread_->flags_ |= THREAD_FLAG_NO_BOOST;
state_.store(State::CREATED);
END_TEST;
diff --git a/zircon/kernel/tests/thread_tests.cc b/zircon/kernel/tests/thread_tests.cc
index 0313bcd..b186bcd 100644
--- a/zircon/kernel/tests/thread_tests.cc
+++ b/zircon/kernel/tests/thread_tests.cc
@@ -412,27 +412,6 @@
}
printf("done with preempt test, above time stamps should be very close\n");
-
- /* do the same as above, but mark the threads as real time, which should
- * effectively disable timer based preemption for them. They should
- * complete in order, about a second apart. */
- printf("testing real time preemption\n");
-
- const int num_threads = 5;
- preempt_count = num_threads;
-
- for (int i = 0; i < num_threads; i++) {
- Thread* t = Thread::Create("preempt tester", &preempt_tester, NULL, LOW_PRIORITY);
- t->SetRealTime();
- t->SetCpuAffinity(cpu_num_to_mask(0));
- t->DetachAndResume();
- }
-
- while (preempt_count > 0) {
- Thread::Current::SleepRelative(ZX_SEC(1));
- }
-
- printf("done with real-time preempt test, above time stamps should be 1 second apart\n");
}
static int join_tester(void* arg) {
@@ -893,9 +872,9 @@
}
int spinner(int argc, const cmd_args* argv, uint32_t) {
- if (argc < 2) {
+ if (argc < 1) {
printf("not enough args\n");
- printf("usage: %s <priority> <rt>\n", argv[0].str);
+ printf("usage: %s <priority>\n", argv[0].str);
return -1;
}
@@ -903,9 +882,6 @@
if (!t)
return ZX_ERR_NO_MEMORY;
- if (argc >= 3 && !strcmp(argv[2].str, "rt")) {
- t->SetRealTime();
- }
t->DetachAndResume();
return 0;