]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add function to get osd_bandwidth_cost_per_io
authorAishwarya Mathuria <amathuri@redhat.com>
Tue, 27 Feb 2024 18:21:58 +0000 (18:21 +0000)
committerAishwarya Mathuria <amathuri@redhat.com>
Thu, 13 Jun 2024 03:38:19 +0000 (09:08 +0530)
In order to expose osd_bandwidth_cost_per_io, we add a new function get_cost_per_io. The intention is to use this value for better cost estimation for operations being queued in the mClock scheduler.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
(cherry picked from commit ef1cfd7fa3ad7bd9e367dd293b335ba160c52e32)

src/osd/OSD.cc
src/osd/OSD.h
src/osd/scheduler/OpScheduler.h
src/osd/scheduler/mClockScheduler.h

index e740958a074fd15c4c916bb3765dec3871c19fdd..e2f360223685f018a58c0271ef8c6687c5367ee8 100644 (file)
@@ -1682,6 +1682,11 @@ void OSDService::enqueue_front(OpSchedulerItem&& qi)
   osd->op_shardedwq.queue_front(std::move(qi));
 }
 
+double OSDService::get_cost_per_io() const
+{
+  return osd->op_shardedwq.get_cost_per_io();
+}
+
 void OSDService::queue_recovery_context(
   PG *pg,
   GenContext<ThreadPool::TPHandle&> *c,
index b294aba7e0f02ff66cd85a4a3a86f50236185121..4d232d6643b0be70ab15a6af5bec9b545750301d 100644 (file)
@@ -118,6 +118,8 @@ public:
 
   void enqueue_back(OpSchedulerItem&& qi);
   void enqueue_front(OpSchedulerItem&& qi);
+  /// scheduler cost per io, only valid for mclock, asserts for wpq
+  double get_cost_per_io() const;
 
   void maybe_inject_dispatch_delay() {
     if (g_conf()->osd_debug_inject_dispatch_delay_probability > 0) {
@@ -1620,6 +1622,11 @@ protected:
        p->complete(0);
       }
     }
+
+    double get_cost_per_io() const {
+      auto &sdata = osd->shards[0];
+      return sdata->scheduler->get_cost_per_io();
+    }
   } op_shardedwq;
 
 
index 570a2a162900a9ee85d0dbc8695801936ec190d2..cb6ff69f2fea5a382c6ef980029cf1a24f577ab3 100644 (file)
@@ -22,6 +22,8 @@
 #include "mon/MonClient.h"
 #include "osd/scheduler/OpSchedulerItem.h"
 
+#include "include/ceph_assert.h"
+
 namespace ceph::osd::scheduler {
 
 using client = uint64_t;
@@ -58,6 +60,11 @@ public:
   // Get the scheduler type set for the queue
   virtual op_queue_type_t get_type() const = 0;
 
+  virtual double get_cost_per_io() const {
+    ceph_assert(0 == "impossible for wpq");
+    return 0.0;
+  }
+
   // Destructor
   virtual ~OpScheduler() {};
 };
index 16e7f911ff95426cbba3503ec90e364157fba5d8..7d3eb64afa40f110fc056bc1fd67c84e43b65f55 100644 (file)
@@ -261,6 +261,10 @@ public:
   const char** get_tracked_conf_keys() const final;
   void handle_conf_change(const ConfigProxy& conf,
                          const std::set<std::string> &changed) final;
+
+  double get_cost_per_io() const {
+    return osd_bandwidth_cost_per_io;
+  }
 private:
   // Enqueue the op to the high priority queue
   void enqueue_high(unsigned prio, OpSchedulerItem &&item, bool front = false);