]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add debug logs and formatted dumps in the mClockScheduler
authorSridhar Seshasayee <sseshasa@redhat.com>
Tue, 14 Dec 2021 10:41:14 +0000 (16:11 +0530)
committerSridhar Seshasayee <sseshasa@redhat.com>
Tue, 11 Jan 2022 04:30:14 +0000 (10:00 +0530)
Signed-off-by: Sridhar Seshasayee <sseshasa@redhat.com>
src/osd/scheduler/OpSchedulerItem.cc
src/osd/scheduler/OpSchedulerItem.h
src/osd/scheduler/mClockScheduler.cc
src/osd/scheduler/mClockScheduler.h

index cced6c9d77775e24c1ffff53b193ff9f0bee8000..9f834e90778127c3a56f5563ea7daa87e9bb6c31 100644 (file)
 
 namespace ceph::osd::scheduler {
 
+std::ostream& operator<<(std::ostream& out, const op_scheduler_class& class_id) {
+  out << static_cast<size_t>(class_id);
+  return out;
+}
+
 void PGOpItem::run(
   OSD *osd,
   OSDShard *sdata,
index 7ba59838e94814b1c97bb3c785615efb59a2a478..a70e9820b6e5642fec5d10e88d75131b01a8857d 100644 (file)
@@ -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 {
index e59ea8f92ab9dfb9deffedcf5979d478f68aa427..8487127138287a3f28bca8534516f05830ffb032 100644 (file)
@@ -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[] = {
index 32f3851ec0558cf218c17e7b212811390b307070..cb53412c7e0f8f97f9d465fc97860e866d9914a7 100644 (file)
@@ -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;