]> git.apps.os.sepia.ceph.com Git - ceph-ci.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>
Wed, 3 Apr 2024 03:56:08 +0000 (03:56 +0000)
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>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/scheduler/OpScheduler.h
src/osd/scheduler/mClockScheduler.h

index 39a0fb30d424ae31c53f5e96b3dfa855bdfb5f24..dfb2134f3ff39fe96e5b39d696c82d54d65ceed8 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 8c03e0192033992b48943da8d9c6c308c79ca574..99fd0818765d5a216b2128b7854da8259aa8f2bf 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);