class Scheduler

Defined at line 13 of file ../../src/graphics/drivers/msd-intel-gen/src/scheduler.h

Public Methods

void CommandBufferQueued (std::weak_ptr<MsdIntelContext> context)

Notifies the scheduler that a command buffer has been scheduled on the given context.

void CommandBufferCompleted (std::shared_ptr<MsdIntelContext> context)

Notifies the scheduler that a command buffer has been completed on the given context.

void ~Scheduler ()

Defined at line 15 of file ../../src/graphics/drivers/msd-intel-gen/src/scheduler.h

std::unique_ptr<Scheduler> CreateFifoScheduler ()

///////////////////////////////////////////////////////////////////////////////////////////////

Defined at line 85 of file ../../src/graphics/drivers/msd-intel-gen/src/scheduler.cc

void Scheduler ()

Defined at line 145 of file ../../zircon/kernel/include/kernel/scheduler.h

void Scheduler (const Scheduler & )

Defined at line 148 of file ../../zircon/kernel/include/kernel/scheduler.h

Scheduler & operator= (const Scheduler & )

Defined at line 149 of file ../../zircon/kernel/include/kernel/scheduler.h

cpu_num_t this_cpu ()

Returns the number of the CPU this scheduler instance is associated with.

Defined at line 164 of file ../../zircon/kernel/include/kernel/scheduler.h

size_t cluster ()

Returns the index of the logical cluster of the CPU this scheduler instance

is associated with.

Defined at line 168 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedDuration exported_queue_time_ns ()

Returns the lock-free value of the estimated queue time for the CPU this

scheduler is associated with.

Defined at line 172 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedUtilization exported_deadline_utilization ()

Returns the lock-free value of the estimated deadline utilization for the

CPU this scheduler is associated with.

Defined at line 176 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedProcessingRate processing_rate_reciprocal ()

Returns the reciprocal processing rate of the CPU this scheduler instance

is associated with.

Defined at line 199 of file ../../zircon/kernel/include/kernel/scheduler.h

bool EnableNewWakeupAccounting ()

Returns true if new scheduler wakeup accounting is enabled either by boot

option or gn arg.

Defined at line 218 of file ../../zircon/kernel/kernel/scheduler.cc

void RescheduleCpus (cpu_mask_t cpu_mask)

Reschedules the given CPU mask, applying any updated bookkeeping that may

affect the currently running threads on those CPUs.

Defined at line 176 of file ../../zircon/kernel/include/kernel/scheduler_inline.h

SchedUtilization exported_clamped_deadline_utilization ()

Returns the lock-free value of the estimated deadline utilization for the

CPU, clamped to the current rate limits, for the CPU this scheduler is

associated with.

Defined at line 183 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedProcessingRate exported_processing_rate ()

Returns the lock-free value of the processing rate for the CPU this

scheduler is associated with.

Defined at line 189 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedProcessingRate processing_rate ()

Returns the processing rate of the CPU this scheduler instance is

associated with.

Defined at line 193 of file ../../zircon/kernel/include/kernel/scheduler.h

int32_t runnable_task_count ()

Defined at line 203 of file ../../zircon/kernel/include/kernel/scheduler.h

Thread * active_thread ()

Returns a pointer to the currently running thread, if any.

TODO(johngro); This is not particularly safe. As soon as we returned this

thread's pointer, it could (in theory) exit. We probably need to require

that the scheduler's queue lock be held in order to peek at the active

thread member.

Defined at line 211 of file ../../zircon/kernel/include/kernel/scheduler.h

void Dump (FILE * output_target, bool queue_state_only)

Dumps the state of the run queue to the specified output target. Note that

interrupts must be disabled in order to call this method.

Defined at line 282 of file ../../zircon/kernel/kernel/scheduler.cc

template <typename Callable>
auto RunInLockedScheduler (cpu_num_t which_cpu, Callable callable)

Defined at line 375 of file ../../zircon/kernel/include/kernel/scheduler.h

template <typename Callable>
auto RunInLockedCurrentScheduler (Callable callable)

Defined at line 388 of file ../../zircon/kernel/include/kernel/scheduler.h

SchedWeight GetTotalWeight ()

Accessors for total weight and number of runnable tasks.

Defined at line 416 of file ../../zircon/kernel/kernel/scheduler.cc

size_t GetRunnableTasks ()

Defined at line 421 of file ../../zircon/kernel/kernel/scheduler.cc

void DumpActiveThread (FILE * output_target)

Dumps info about the currently active thread (if any). Note that

interrupts must be disabled in order to call this method.

Defined at line 388 of file ../../zircon/kernel/kernel/scheduler.cc

template <typename Callable>
auto RunInThreadsSchedulerLocked (Thread * thread, Callable callable)

Run the passed callable while holding the specified thread's scheduler's

lock, if any. Used by SetMigrateFn in thread.cc.

Defined at line 398 of file ../../zircon/kernel/include/kernel/scheduler.h

cpu_mask_t PeekActiveMask ()

Peek at the current active mask for all schedulers.

Note that this is just a lockless atomic load. Baring special

circumstances, the set of active schedulers can change at any time.

Defined at line 423 of file ../../zircon/kernel/include/kernel/scheduler.h

bool PeekIsActive (cpu_num_t cpu)

Peek at the current active mask state for a given CPU's scheduler.

Note that this is just a lockless atomic load. Baring special

circumstances, the set of active schedulers can change at any time.

Defined at line 429 of file ../../zircon/kernel/include/kernel/scheduler.h

void SetIdle (bool is_idle)

Accessors for the "idle" state mask; similar to the active state mask.

Defined at line 435 of file ../../zircon/kernel/include/kernel/scheduler.h

cpu_mask_t PeekIdleMask ()

Defined at line 443 of file ../../zircon/kernel/include/kernel/scheduler.h

bool PeekIsIdle (cpu_num_t cpu)

Defined at line 444 of file ../../zircon/kernel/include/kernel/scheduler.h

PowerDomainSet ExchangePowerDomainSet (const PowerDomainSet & power_domain_set)

Sets the power domain set for this scheduler instance, returning the previous domain set.

Called by kernel tests and sys_system_set_processor_power_domain.

Defined at line 455 of file ../../zircon/kernel/include/kernel/scheduler.h

zx::result<> UpdateActivePowerLevel (uint8_t power_level)

Updates the current power level for this CPU with the value reported by the power level

controller. Called by kernel tests and sys_system_set_processor_power_state.

Defined at line 469 of file ../../zircon/kernel/include/kernel/scheduler.h

ktl::optional<uint8_t> GetActivePowerLevel ()

Returns the current active power level, if any.

Defined at line 475 of file ../../zircon/kernel/include/kernel/scheduler.h

fbl::RefPtr<PowerDomain> GetPowerDomainForTesting ()

Returns the current power domain for this scheduler instance.

Defined at line 488 of file ../../zircon/kernel/include/kernel/scheduler.h

ktl::optional<uint64_t> GetActivePowerCoefficientNwForTesting ()

Returns the current active power coefficient.

Defined at line 494 of file ../../zircon/kernel/include/kernel/scheduler.h

ktl::optional<uint64_t> GetMaxIdlePowerCoefficientNwForTesting ()

Returns the max idle power coefficient.

Defined at line 500 of file ../../zircon/kernel/include/kernel/scheduler.h

std::shared_ptr<MsdIntelContext> ScheduleContext ()

Selects the context whose command buffer will be executed next.

void SetCurrCpuActive (bool is_active)

Set/clears the current cpu's bit in the global mp_active_mask. Holds the

scheduler's queue lock while the bit is changed, enforcing the invariant

that a scheduler's active bit can only ever change while holding that

scheduler's lock.

Defined at line 413 of file ../../zircon/kernel/include/kernel/scheduler.h

const ::lockdep::LockDep<Scheduler, MonitoredSpinLock, 1122, ::lockdep::internal::DefaultLockFlags<>::value> & queue_lock_cap ()

Const accessor for static analysis.

Defined at line 506 of file ../../zircon/kernel/include/kernel/scheduler.h

void InitializeThread (Thread * thread, const SchedulerState::BaseProfile & profile)

See the comment in Thread::CreateEtc for why InitializeThread does not take

a stance on whether or not we should be in an active chain-lock

transaction. On the surface, demanding that we hold a threads lock without

also demanding that we also be involved in an active chain-lock transaction

is an apparent contradiction of some fundamental invariants (how can a

chain lock be held without being in a transaction?), but when used

exclusively from Thread::CreateEtc, it should be OK.

Defined at line 529 of file ../../zircon/kernel/kernel/scheduler.cc

void InitializeFirstThread (Thread * thread)

Initialize the first thread to run on the current CPU. Called from

thread_construct_first, this method will initialize the thread's scheduler

state, then mark the thread as being "active" in its cpu's scheduler.

Defined at line 538 of file ../../zircon/kernel/kernel/scheduler.cc

void RemoveFirstThread (Thread * thread)

Remove the impact of a CPUs first thread from the scheduler's bookkeeping.

During initial startup, threads are not _really_ being scheduled, yet they

can still do things like obtain locks and block, resulting in profile

inheritance. In order to hold the scheduler's bookkeeping invariants, we

assign these threads a fair weight, and include it in the total fair weight

tracked by the scheduler instance. When the thread either becomes the idle

thread (as the boot CPU first thread does), or exits (as secondary CPU first

threads do), it is important that we remove this weight from the total

bookkeeping. However, this is not as simple as just changing the thread's

weight via ChangeWeight, as idle threads are special cases who contribute no

weight to the total.

So, this small method simply fixes up the bookkeeping before allowing the

thread to move on to become the idle thread (boot CPU), or simply exiting

(secondary CPU).

Defined at line 585 of file ../../zircon/kernel/kernel/scheduler.cc

void Block (Thread * current_thread)

Defined at line 2647 of file ../../zircon/kernel/kernel/scheduler.cc

void Yield (Thread * current_thread)

Defined at line 2765 of file ../../zircon/kernel/kernel/scheduler.cc

void Preempt ()

No chainlocks should be held when calling preempt. The thread's lock will

be obtained unconditionally in the process.

If holding a spinlock, the preemption will be deferred via self-IPI until

all spinlock are released and interrupts are re-enabled.

Defined at line 2789 of file ../../zircon/kernel/kernel/scheduler.cc

void Reschedule (Thread * current_thread)

Defined at line 2818 of file ../../zircon/kernel/kernel/scheduler.cc

void RescheduleInternal (Thread * current_thread)

Defined at line 2848 of file ../../zircon/kernel/kernel/scheduler.cc

void Unblock (Thread * thread)

Finish unblocking a thread. This function expects the thread to be locked

when called. It will:

1) Select a scheduler compatible with the thread.

2) Place the thread into that scheduler's run queue.

3) Drop the thread's lock.

4) Reschedule if needed/permitted.

Defined at line 2703 of file ../../zircon/kernel/kernel/scheduler.cc

void Unblock (Thread::UnblockList thread_list)

Unblock list expects to receive a list of threads, all of whose

locks are currently held. It will drop each thread's lock after

successfully assigning it to a scheduler.

Defined at line 2714 of file ../../zircon/kernel/kernel/scheduler.cc

void UnblockSynchronous (Thread * thread)

Unblock a thread, but do not reschedule for the thread. A reschedule may

still be issued for power level changes.

Defined at line 2732 of file ../../zircon/kernel/kernel/scheduler.cc

void UnblockIdle (Thread * idle_thread)

UnblockIdle is used in the process of creation of the idle thread. It

simply asserts that the thread is (in fact) flagged as the idle thread, and

that it has hard affinity for exactly one CPU (its CPU). It then sets the

thread to be ready, and ensures that its curr_cpu_ state is correct.

Defined at line 2747 of file ../../zircon/kernel/kernel/scheduler.cc

void MigrateUnpinnedThreads ()

Migrates any threads that can run on other CPUs off of the current CPU.

Defined at line 2853 of file ../../zircon/kernel/kernel/scheduler.cc

void TimerTick (SchedTime now)

TimerTick is called when the preemption timer for a CPU has fired.

This function is logically private and should only be called by timer.cc.

Defined at line 3039 of file ../../zircon/kernel/kernel/scheduler.cc

void TrampolineLockHandoff ()

Releases the lock held by the previous and current threads after a context

switch. This must be called by trampoline routines at some point before

jumping to the current thread's entry point.

Defined at line 2100 of file ../../zircon/kernel/kernel/scheduler.cc

void ThreadBaseProfileChanged (Thread & thread)

Called when the base profile of |thread| has been changed by a program. The

thread must be either running or runnable when this method is called. If

the thread had been blocked instead, the change of the base profile would

have been managed at the WaitQueue level, perhaps eventually propagating to

the scheduler via UpstreamThreadBaseProfileChanged.

Defined at line 841 of file ../../zircon/kernel/kernel/scheduler_pi.cc

template <typename TargetType>
void UpstreamThreadBaseProfileChanged (const Thread & upstream, TargetType & target)

Called when the base profile of a thread (|upstream|) which exists upstream

of |target| has changed its base profile. It is possible for the rules

regarding scheduling penalties base profile changes to be slightly

different for when a thread's effective profile changes as a result of its

own base profile changing, vs the base profile of a thread which exists

upstream of it in a PI graph. Because of this, the two scenarios are

handled separately using two different methods.

Defined at line 847 of file ../../zircon/kernel/kernel/scheduler_pi.cc

template <typename UpstreamType, typename TargetType>
void JoinNodeToPiGraph (const UpstreamType & upstream, TargetType & target)

Called when a thread (|upstream|) blocks in an OwnedWaitQueue, and the

target of that OWQ (|target|) is running or runnable. At the point that

this method is called, propagation of the static profile pressure

parameters (weight, deadline utilization, and minimum deadline) should have

already been propagated to |target|, and its EffectiveProfile should be

dirty. This method is called in order to update the dynamic scheduling

parameters (start time, finish time, time slice remaining) of |target| as

needed because of the join operation.

Defined at line 854 of file ../../zircon/kernel/kernel/scheduler_pi.cc

template <typename UpstreamType, typename TargetType>
void SplitNodeFromPiGraph (const UpstreamType & upstream, TargetType & target)

Called when a thread (|upstream|) unblocks from an OwnedWaitQueue and

leaves the PI graph whose running or runnable target is |target|.

At the point that this method is called, propagation of the static profile

pressure parameters (weight, deadline utilization, and minimum deadline)

should have already been propagated to |target|, and its EffectiveProfile

should be dirty. This method is called in order to update the dynamic

scheduling parameters (start time, finish time, time slice remaining) in

both |target| and |upstream| as needed because of the split operation.

Defined at line 861 of file ../../zircon/kernel/kernel/scheduler_pi.cc

void UpdateProcessingRates (ktl::span<zx_cpu_performance_info_t> info)

Updates the performance scales of the requested CPUs and returns the

effective values in place, which may be different than the requested values

if they are below the minimum safe values for the respective CPUs.

Requires info.size()

<

= num CPUs.

Defined at line 3051 of file ../../zircon/kernel/kernel/scheduler.cc

void GetPerformanceScales (ktl::span<zx_cpu_performance_info_t> info)

Gets the performance scales of up to info.size() CPUs. Returns the last

values requested by userspace, even if they have not yet taken effect.

Requires info.size()

<

= num CPUs.

Defined at line 3074 of file ../../zircon/kernel/kernel/scheduler.cc

void GetDefaultPerformanceScales (ktl::span<zx_cpu_performance_info_t> info)

Gets the default performance scales of up to info.size() CPUs. Returns the

initial values determined by the system topology, or 1.0 when no topology

is available.

Requires info.size()

<

= num CPUs.

Defined at line 3085 of file ../../zircon/kernel/kernel/scheduler.cc

void UpdateProcessingLimits (ktl::span<zx_cpu_perf_limit_t> limits)

Updates the performance limits of the requested CPUs.

Requires limits.size()

<

= num CPUs.

Defined at line 3096 of file ../../zircon/kernel/kernel/scheduler.cc

void GetProcessingLimits (ktl::span<zx_cpu_perf_limit_t> limits)

Gets the processing limits of up to limits.size() CPUs.

Requires limits.size()

<

= num CPUs.

Defined at line 3145 of file ../../zircon/kernel/kernel/scheduler.cc

cpu_mask_t SetCpuAffinity (Thread & thread, cpu_mask_t affinity, AffinityType affinity_type)

Get the mask of valid CPUs that thread may run on. If a new mask

is set, the thread will be migrated to satisfy the new constraint.

Defined at line 3161 of file ../../zircon/kernel/kernel/scheduler.cc

bool RequestPowerLevelForTesting (uint8_t power_level)

Sends a power level request through this scheduler's power level controller for testing. This

method is called from thread and IRQ context to ensure that the underlying machinery can be

safely called within Block, Unblock, and other scheduling operations.

Returns true if the request was sent, false otherwise.

Defined at line 3339 of file ../../zircon/kernel/kernel/scheduler.cc

Records