From: Aishwarya Mathuria Date: Tue, 27 Feb 2024 18:21:58 +0000 (+0000) Subject: osd: Add function to get osd_bandwidth_cost_per_io X-Git-Tag: v20.0.0~1775^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ef1cfd7fa3ad7bd9e367dd293b335ba160c52e32;p=ceph.git osd: Add function to get osd_bandwidth_cost_per_io 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 --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 39a0fb30d424..dfb2134f3ff3 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 *c, diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 8c03e0192033..99fd0818765d 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -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; diff --git a/src/osd/scheduler/OpScheduler.h b/src/osd/scheduler/OpScheduler.h index 570a2a162900..cb6ff69f2fea 100644 --- a/src/osd/scheduler/OpScheduler.h +++ b/src/osd/scheduler/OpScheduler.h @@ -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() {}; }; diff --git a/src/osd/scheduler/mClockScheduler.h b/src/osd/scheduler/mClockScheduler.h index 16e7f911ff95..7d3eb64afa40 100644 --- a/src/osd/scheduler/mClockScheduler.h +++ b/src/osd/scheduler/mClockScheduler.h @@ -261,6 +261,10 @@ public: const char** get_tracked_conf_keys() const final; void handle_conf_change(const ConfigProxy& conf, const std::set &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);