From: Sridhar Seshasayee Date: Tue, 14 Dec 2021 10:41:14 +0000 (+0530) Subject: osd: Add debug logs and formatted dumps in the mClockScheduler X-Git-Tag: v17.1.0~96^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=26464392367e06c820f5248a71e6ddeed9dd3162;p=ceph-ci.git osd: Add debug logs and formatted dumps in the mClockScheduler Signed-off-by: Sridhar Seshasayee --- diff --git a/src/osd/scheduler/OpSchedulerItem.cc b/src/osd/scheduler/OpSchedulerItem.cc index cced6c9d777..9f834e90778 100644 --- a/src/osd/scheduler/OpSchedulerItem.cc +++ b/src/osd/scheduler/OpSchedulerItem.cc @@ -19,6 +19,11 @@ namespace ceph::osd::scheduler { +std::ostream& operator<<(std::ostream& out, const op_scheduler_class& class_id) { + out << static_cast(class_id); + return out; +} + void PGOpItem::run( OSD *osd, OSDShard *sdata, diff --git a/src/osd/scheduler/OpSchedulerItem.h b/src/osd/scheduler/OpSchedulerItem.h index 7ba59838e94..a70e9820b6e 100644 --- a/src/osd/scheduler/OpSchedulerItem.h +++ b/src/osd/scheduler/OpSchedulerItem.h @@ -36,6 +36,8 @@ enum class op_scheduler_class : uint8_t { client, }; +std::ostream& operator<<(std::ostream& out, const op_scheduler_class& class_id); + class OpSchedulerItem { public: class OrderLocker { diff --git a/src/osd/scheduler/mClockScheduler.cc b/src/osd/scheduler/mClockScheduler.cc index e59ea8f92ab..84871271382 100644 --- a/src/osd/scheduler/mClockScheduler.cc +++ b/src/osd/scheduler/mClockScheduler.cc @@ -351,6 +351,9 @@ void mClockScheduler::set_profile_config() std::to_string(client.wgt)); cct->_conf.set_val("osd_mclock_scheduler_client_lim", std::to_string(client.lim)); + dout(10) << __func__ << " client QoS params: " << "[" + << client.res << "," << client.wgt << "," << client.lim + << "]" << dendl; // Set background recovery client params cct->_conf.set_val("osd_mclock_scheduler_background_recovery_res", @@ -359,6 +362,9 @@ void mClockScheduler::set_profile_config() std::to_string(rec.wgt)); cct->_conf.set_val("osd_mclock_scheduler_background_recovery_lim", std::to_string(rec.lim)); + dout(10) << __func__ << " Recovery QoS params: " << "[" + << rec.res << "," << rec.wgt << "," << rec.lim + << "]" << dendl; // Set background best effort client params cct->_conf.set_val("osd_mclock_scheduler_background_best_effort_res", @@ -367,6 +373,9 @@ void mClockScheduler::set_profile_config() std::to_string(best_effort.wgt)); cct->_conf.set_val("osd_mclock_scheduler_background_best_effort_lim", std::to_string(best_effort.lim)); + dout(10) << __func__ << " Best effort QoS params: " << "[" + << best_effort.res << "," << best_effort.wgt << "," << best_effort.lim + << "]" << dendl; } int mClockScheduler::calc_scaled_cost(int item_cost) @@ -387,6 +396,24 @@ void mClockScheduler::update_configuration() void mClockScheduler::dump(ceph::Formatter &f) const { + // Display queue sizes + f.open_object_section("queue_sizes"); + f.dump_int("immediate", immediate.size()); + f.dump_int("scheduler", scheduler.request_count()); + f.close_section(); + + // client map and queue tops (res, wgt, lim) + std::ostringstream out; + f.open_object_section("mClockClients"); + f.dump_int("client_count", scheduler.client_count()); + out << scheduler; + f.dump_string("clients", out.str()); + f.close_section(); + + // Display sorted queues (res, wgt, lim) + f.open_object_section("mClockQueues"); + f.dump_string("queues", display_queues()); + f.close_section(); } void mClockScheduler::enqueue(OpSchedulerItem&& item) @@ -398,12 +425,29 @@ void mClockScheduler::enqueue(OpSchedulerItem&& item) immediate.push_front(std::move(item)); } else { int cost = calc_scaled_cost(item.get_cost()); + item.set_qos_cost(cost); + dout(20) << __func__ << " " << id + << " item_cost: " << item.get_cost() + << " scaled_cost: " << cost + << dendl; + // Add item to scheduler queue scheduler.add_request( std::move(item), id, cost); } + + dout(20) << __func__ << " client_count: " << scheduler.client_count() + << " queue_sizes: [ imm: " << immediate.size() + << " sched: " << scheduler.request_count() << " ]" + << dendl; + dout(30) << __func__ << " mClockClients: " + << scheduler + << dendl; + dout(30) << __func__ << " mClockQueues: { " + << display_queues() << " }" + << dendl; } void mClockScheduler::enqueue_front(OpSchedulerItem&& item) @@ -436,6 +480,13 @@ WorkItem mClockScheduler::dequeue() } } +std::string mClockScheduler::display_queues() const +{ + std::ostringstream out; + scheduler.display_queues(out); + return out.str(); +} + const char** mClockScheduler::get_tracked_conf_keys() const { static const char* KEYS[] = { diff --git a/src/osd/scheduler/mClockScheduler.h b/src/osd/scheduler/mClockScheduler.h index 32f3851ec05..cb53412c7e0 100644 --- a/src/osd/scheduler/mClockScheduler.h +++ b/src/osd/scheduler/mClockScheduler.h @@ -42,6 +42,13 @@ using profile_id_t = uint64_t; struct client_profile_id_t { client_id_t client_id; profile_id_t profile_id; + + friend std::ostream& operator<<(std::ostream& out, + const client_profile_id_t& client_profile) { + out << " client_id: " << client_profile.client_id + << " profile_id: " << client_profile.profile_id; + return out; + } }; WRITE_EQ_OPERATORS_2(client_profile_id_t, client_id, profile_id) @@ -51,6 +58,13 @@ WRITE_CMP_OPERATORS_2(client_profile_id_t, client_id, profile_id) struct scheduler_id_t { op_scheduler_class class_id; client_profile_id_t client_profile_id; + + friend std::ostream& operator<<(std::ostream& out, + const scheduler_id_t& sched_id) { + out << "{ class_id: " << sched_id.class_id + << sched_id.client_profile_id; + return out << " }"; + } }; WRITE_EQ_OPERATORS_2(scheduler_id_t, class_id, client_profile_id) @@ -172,6 +186,9 @@ public: // Calculate scale cost per item int calc_scaled_cost(int cost); + // Helper method to display mclock queues + std::string display_queues() const; + // Enqueue op in the back of the regular queue void enqueue(OpSchedulerItem &&item) final;