From d70ab44bb4b570c5de5fc3c9ad6b79b5c40d4b19 Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Mon, 28 Oct 2024 10:20:33 -0400 Subject: [PATCH] i#6938 sched migrate: Add steals + rebalances to schedule stats (#7056) Adds two statistics reported by the scheduler to the schedule_stats report: work steals and rebalances. Tests that something is printed out, but checks of the actual values are left to existing scheduler tests. Issue: #6938 --- clients/drcachesim/tests/core_serial.templatex | 2 ++ clients/drcachesim/tests/schedule_stats_nopreempt.templatex | 2 ++ clients/drcachesim/tools/schedule_stats.cpp | 6 ++++++ clients/drcachesim/tools/schedule_stats.h | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/clients/drcachesim/tests/core_serial.templatex b/clients/drcachesim/tests/core_serial.templatex index 8b8520b5225..d26e99d8e88 100644 --- a/clients/drcachesim/tests/core_serial.templatex +++ b/clients/drcachesim/tests/core_serial.templatex @@ -16,6 +16,8 @@ Total counts: 0 switches nop-ed 0 quantum_preempts 0 migrations + 0 work steals + 0 rebalances 161 system calls 2 maybe-blocking system calls 0 direct switch requests diff --git a/clients/drcachesim/tests/schedule_stats_nopreempt.templatex b/clients/drcachesim/tests/schedule_stats_nopreempt.templatex index 29a7eb3291b..226ca3609b3 100644 --- a/clients/drcachesim/tests/schedule_stats_nopreempt.templatex +++ b/clients/drcachesim/tests/schedule_stats_nopreempt.templatex @@ -16,6 +16,8 @@ Total counts: 0 switches nop-ed 0 quantum_preempts 0 migrations + 0 work steals + 1 rebalances 161 system calls 2 maybe-blocking system calls 0 direct switch requests diff --git a/clients/drcachesim/tools/schedule_stats.cpp b/clients/drcachesim/tools/schedule_stats.cpp index 333ac926960..f2dcfdd7979 100644 --- a/clients/drcachesim/tools/schedule_stats.cpp +++ b/clients/drcachesim/tools/schedule_stats.cpp @@ -160,6 +160,10 @@ schedule_stats_t::get_scheduler_stats(memtrace_stream_t *stream, counters_t &cou stream->get_schedule_statistic(memtrace_stream_t::SCHED_STAT_QUANTUM_PREEMPTS)); counters.migrations = static_cast( stream->get_schedule_statistic(memtrace_stream_t::SCHED_STAT_MIGRATIONS)); + counters.steals = static_cast( + stream->get_schedule_statistic(memtrace_stream_t::SCHED_STAT_RUNQUEUE_STEALS)); + counters.rebalances = static_cast(stream->get_schedule_statistic( + memtrace_stream_t::SCHED_STAT_RUNQUEUE_REBALANCES)); // XXX: Currently, schedule_stats is measuring swap-ins to a real input. If we // want to match what "perf" targeting this app would record, which is swap-outs, @@ -417,6 +421,8 @@ schedule_stats_t::print_counters(const counters_t &counters) std::cerr << std::setw(12) << counters.switches_nop << " switches nop-ed\n"; std::cerr << std::setw(12) << counters.quantum_preempts << " quantum_preempts\n"; std::cerr << std::setw(12) << counters.migrations << " migrations\n"; + std::cerr << std::setw(12) << counters.steals << " work steals\n"; + std::cerr << std::setw(12) << counters.rebalances << " rebalances\n"; std::cerr << std::setw(12) << counters.syscalls << " system calls\n"; std::cerr << std::setw(12) << counters.maybe_blocking_syscalls diff --git a/clients/drcachesim/tools/schedule_stats.h b/clients/drcachesim/tools/schedule_stats.h index 61e175a4c5e..0ee481173e7 100644 --- a/clients/drcachesim/tools/schedule_stats.h +++ b/clients/drcachesim/tools/schedule_stats.h @@ -147,6 +147,8 @@ class schedule_stats_t : public analysis_tool_t { switches_nop += rhs.switches_nop; quantum_preempts += rhs.quantum_preempts; migrations += rhs.migrations; + steals += rhs.steals; + rebalances += rhs.rebalances; instrs += rhs.instrs; total_switches += rhs.total_switches; voluntary_switches += rhs.voluntary_switches; @@ -173,6 +175,8 @@ class schedule_stats_t : public analysis_tool_t { int64_t switches_nop = 0; int64_t quantum_preempts = 0; int64_t migrations = 0; + int64_t steals = 0; + int64_t rebalances = 0; // Our own statistics. int64_t instrs = 0; int64_t total_switches = 0;