Repository navigation
tentacle: mclock_common, mClockScheduler: Bound high_priority drain to prevent starvation - #72029
Conversation
…starvation Under sustained client I/O on EC pools, mClockScheduler::dequeue() drains the strict-priority high_priority queue (immediate class, e.g. client-driven EC subop reads/writes/replies) unconditionally before ever calling scheduler.pull_request(), the entry point that services mClock managed queue items. Since high_priority can stay continuously non-empty under heavy load, this can starve mClock managed queue items -- in the trackers case most visibly deep-scrub's chunk-continuation events (PGScrubGetNextChunk, PGScrubChunkIsFree, PGScrubResched, etc.) -- for tens of seconds at a time, regardless of their configured mclock reservation. Add a bounded check: once the mclock-managed queue has gone unserviced for osd_mclock_max_starve_time while high_priority keeps refilling, force one dequeue attempt from it before resuming the high_priority drain. No-op when the mclock queue is empty, so normal operation is unaffected. Bound the starvation window on flash to 50ms via an internal constant -- scheduler_max_starve_time_ssd, and not a configuration option as this was tested on real hardware. But since no HDD test hardware has been available for this investigation, rather than ship an unvalidated hardcoded constant with no adjustment path, a configurable called osd_mclock_max_starve_time_hdd is introduced. Default 0.25s, bounded to [0.1s, 0.5s]. A modern 7200 RPM HDD's average random-access time is roughly 10-15ms, so the configurable range remains a real, meaningful multiple of that even at the tightest allowed setting. This allows an operator some flexibility in case a given HDD fleet needs a different value. Tests (src/test/osd/TestMClockScheduler.cc): Add Unit Tests to exercise the starvation logic for SSD and HDD. Documentation (doc/rados/configuration/mclock-config-ref.rst): Add a new "mClock Queue Starvation Prevention" section explaining the immediate/high-priority-vs-mclock-managed-queue starvation mechanism, the bounded forced-yield fix, the device-aware threshold split and add osd_mclock_max_starve_time_hdd to the list of config options. Fixes: https://tracker.ceph.com/issues/69078 Signed-off-by: Sridhar Seshasayee <[email protected]> (cherry picked from commit 5847d11) Conflicts: src/common/mclock_common.cc src/common/mclock_common.h - not in tentacle. MclockConfig was never backported, so the mclock config code still lives in mClockScheduler. Moved scheduler_max_starve_time and scheduler_max_starve_time_ssd there instead. src/osd/scheduler/mClockScheduler.cc - set scheduler_max_starve_time in set_osd_capacity_params_from_config(), where main sets it in MclockConfig::set_from_config(). - added osd_mclock_max_starve_time_hdd to get_tracked_keys(), and reload it in handle_conf_change(). Tentacle handles each key separately instead of reloading everything on any change. - kept _put_mclock_counter(), because tentacle does not have the per-op-type counters used by put_mclock_counter(). src/osd/scheduler/mClockScheduler.h - read scheduler_max_starve_time directly instead of mclock_conf.get_scheduler_max_starve_time(). src/test/osd/TestMClockScheduler.cc - use op_scheduler_class, because tentacle does not have the SchedulerClass alias. - pass monc to the mClockScheduler constructor, which tentacle still takes.
…er aborts The starvation-bound forced yield added to dequeue() could let a client-class item still sitting in the mclock-managed queue get scheduled ahead of a same-client item that had been pulled out of its normal queue position via enqueue_front() (PG map-wait release, rwordered-dependency requeue, or a PG-slot wake). In other words, this is a requeued item now in the high_priority queue. enqueue_front() has no way to preserve such an item's position relative to same-client siblings still in the mclock queue, since mClock does not support inserting at the front of its own queue. So the item would be redirected into high_priority instead, where a forced yield due to starvation could release its sibling first, producing a client visible tid inversion and resulting in "bad op order" abort. Fix: Give client class items enqueued via enqueue_front() a reserved high_priority queue (requeued_class_priority, set to SchedulerClass::client's own value purely so it documents itself) instead of priority 0, and gate the starvation-bound forced yield so it never pulls from the mclock-managed queue while requeued class priority queue is non-empty. The other high_priority queues(MAX, >=cutoff_priority) and their drain remain unchanged. The usage of the requeued-item high priority queue is scoped only for client items that get requeued via enqueue_front(). Other classes like background-recovery / background-best-effort that are not bound by tid-ordering invariant get requeued as before in the priority 0 queue. Gating the force yield on the presence of requeued client ops is expected to be rare and bursty rather than sustained and therefore is not expected to dilute the effectiveness of the starvation mechanism. Tests: src/test/osd/TestMclockScheduler.cc - Add unit tests to validate the requeued_class_priority mechanics and maintaining op order invariant. Fixes: https://tracker.ceph.com/issues/69078 Signed-off-by: Sridhar Seshasayee <[email protected]> (cherry picked from commit cf5e5db) Conflicts: src/osd/scheduler/mClockScheduler.cc - kept _put_mclock_counter(), because tentacle does not have the per-op-type counters used by put_mclock_counter(). Kept the new log line for items released from requeued_class_priority. - use op_scheduler_class::client instead of SchedulerClass::client. src/osd/scheduler/mClockScheduler.h src/test/osd/TestMClockScheduler.cc - use op_scheduler_class, because tentacle does not have the SchedulerClass alias. For the classic OSD, SchedulerClass is an alias of op_scheduler_class, so requeued_class_priority keeps the same value (3).
Config Diff Tool Output+ added: osd_mclock_max_starve_time_hdd (osd.yaml.in)
The above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
There was a problem hiding this comment.
Ceph Release Engineering Audit Report
Commit Parity Visualizer
| BACKPORT PR #72029 | SOURCE PR |
SOURCE STATUS |
|---|---|---|
| 98dbacd mclock_common, mClockScheduler: Bound high_priority drain to prevent starvation | PR #71205 | 5847d11 mclock_common, mClockScheduler: Bound high_priority drain to prevent starvation |
| 94a2b76 mClockScheduler: Reserve a requeued-item prio queue to prevent op-order aborts | cf5e5db mClockScheduler: Reserve a requeued-item prio queue to prevent op-order aborts |
Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations
A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.
This does not necessarily indicate an issue but a maintainer should review.
**Click to expand conflict summaries.**
Deviation in Backport 98dbacd (cherry-pick of 5847d11)
Affected File(s)
src/common/mclock_common.ccsrc/common/mclock_common.hsrc/osd/scheduler/mClockScheduler.cc
Range Diff
Click to expand
--- Original (5847d110)
+++ Backport (98dbacd1)
@@ -38,3 +38,29 @@
Fixes: https://tracker.ceph.com/issues/69078
Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit 5847d1100248b9c4880dbdda9f3cd9ec70801e36)
+
+Conflicts:
+ src/common/mclock_common.cc
+ src/common/mclock_common.h
+ - not in tentacle. MclockConfig was never backported, so the mclock
+ config code still lives in mClockScheduler. Moved
+ scheduler_max_starve_time and scheduler_max_starve_time_ssd there
+ instead.
+ src/osd/scheduler/mClockScheduler.cc
+ - set scheduler_max_starve_time in
+ set_osd_capacity_params_from_config(), where main sets it in
+ MclockConfig::set_from_config().
+ - added osd_mclock_max_starve_time_hdd to get_tracked_keys(), and
+ reload it in handle_conf_change(). Tentacle handles each key
+ separately instead of reloading everything on any change.
+ - kept _put_mclock_counter(), because tentacle does not have the
+ per-op-type counters used by put_mclock_counter().
+ src/osd/scheduler/mClockScheduler.h
+ - read scheduler_max_starve_time directly instead of
+ mclock_conf.get_scheduler_max_starve_time().
+ src/test/osd/TestMClockScheduler.cc
+ - use op_scheduler_class, because tentacle does not have the
+ SchedulerClass alias.
+ - pass monc to the mClockScheduler constructor, which tentacle
+ still takes.
================================================================================
RANGE DIFF
================================================================================
1: 5847d110024 ! 1: 98dbacd1034 mclock_common, mClockScheduler: Bound high_priority drain to prevent starvation
@@ Commit message
Fixes: https://tracker.ceph.com/issues/69078
Signed-off-by: Sridhar Seshasayee <[email protected]>
+ (cherry picked from commit 5847d1100248b9c4880dbdda9f3cd9ec70801e36)
+
+ Conflicts:
+ src/common/mclock_common.cc
+ src/common/mclock_common.h
+ - not in tentacle. MclockConfig was never backported, so the mclock
+ config code still lives in mClockScheduler. Moved
+ scheduler_max_starve_time and scheduler_max_starve_time_ssd there
+ instead.
+ src/osd/scheduler/mClockScheduler.cc
+ - set scheduler_max_starve_time in
+ set_osd_capacity_params_from_config(), where main sets it in
+ MclockConfig::set_from_config().
+ - added osd_mclock_max_starve_time_hdd to get_tracked_keys(), and
+ reload it in handle_conf_change(). Tentacle handles each key
+ separately instead of reloading everything on any change.
+ - kept _put_mclock_counter(), because tentacle does not have the
+ per-op-type counters used by put_mclock_counter().
+ src/osd/scheduler/mClockScheduler.h
+ - read scheduler_max_starve_time directly instead of
+ mclock_conf.get_scheduler_max_starve_time().
+ src/test/osd/TestMClockScheduler.cc
+ - use op_scheduler_class, because tentacle does not have the
+ SchedulerClass alias.
+ - pass monc to the mClockScheduler constructor, which tentacle
+ still takes.
## doc/rados/configuration/mclock-config-ref.rst ##
@@ doc/rados/configuration/mclock-config-ref.rst: change to the default HDD OSD shard configuration is made:
@@ doc/rados/configuration/mclock-config-ref.rst: mClock Config Options
.. _the dmClock algorithm: https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Gulati.pdf
- ## src/common/mclock_common.cc ##
-@@ src/common/mclock_common.cc: void MclockConfig::set_from_config()
- << osd_bandwidth_capacity_per_shard << " bytes/second"
- << dendl;
-
-+ scheduler_max_starve_time = is_rotational
-+ ? cct->_conf.get_val<double>("osd_mclock_max_starve_time_hdd")
-+ : scheduler_max_starve_time_ssd;
-+
- auto mclock_profile = cct->_conf.get_val<std::string>("osd_mclock_profile");
- if (mclock_profile == "high_client_ops") {
- current_profile = HIGH_CLIENT_OPS;
-@@ src/common/mclock_common.cc: uint32_t MclockConfig::calc_scaled_cost(int item_cost)
- return std::max<uint32_t>(cost, cost_per_io);
- }
-
-+double MclockConfig::get_scheduler_max_starve_time() const {
-+ return scheduler_max_starve_time;
-+}
-+
- void MclockConfig::handle_conf_change(const ConfigProxy& conf,
- const std::set<std::string> &changed)
- {
-
- ## src/common/mclock_common.h ##
-@@ src/common/mclock_common.h: private:
- // currently active profile, will be overridden from config on startup
- // and upon config change
- profile_t current_profile = BALANCED;
-+
-+ /**
-+ * scheduler_max_starve_time / scheduler_max_starve_time_ssd
-+ *
-+ * Upper bound (secs) on how long the mClock managed queue may go unserviced
-+ * while high_priority drain keeps being refilled, before yielding it one
-+ * forced dequeue attempt. Without this, a sustained stream of high_priority
-+ * traffic can starve the various mClock managed classes.
-+ *
-+ * Device-specific starve times: A HDD's own natural service time is multi-
-+ * millisecond, and so the default 250ms bound is a modest multiple of that.
-+ * See 'osd_mclock_max_starve_time_hdd' for more details. Flash devices
-+ * complete a normal op much faster (sub millisecond), so the bound is
-+ * tightened to a much shorter window of 50ms. This has been validated by
-+ * real hardware testing and stays as an internal constant.
-+ *
-+ * But validation is not done on HDD test hardware and therefore it's exposed
-+ * as a config option mentioned above with a default of 250ms and bound to
-+ * [100ms, 500ms] rather than hardcode it. Thus is to allow an operator some
-+ * flexibility in case a given HDD fleet needs a different value.
-+ */
-+ double scheduler_max_starve_time = 0.0;
-+ static constexpr double scheduler_max_starve_time_ssd = 0.05; // 50 msec
- public:
- MclockConfig(CephContext *cct, ClientRegistry& creg,
- uint32_t num_shards, bool is_rotational, int shard_id,
-@@ src/common/mclock_common.h: public:
- utime_t time_queued);
- double get_cost_per_io() const;
- double get_capacity_per_shard() const;
-+ double get_scheduler_max_starve_time() const;
- void handle_conf_change(const ConfigProxy& conf,
- const std::set<std::string> &changed) final;
- std::vector<std::string> get_tracked_keys() const noexcept final {
-@@ src/common/mclock_common.h: public:
- "osd_mclock_max_capacity_iops_ssd"s,
- "osd_mclock_max_sequential_bandwidth_hdd"s,
- "osd_mclock_max_sequential_bandwidth_ssd"s,
-- "osd_mclock_profile"s
-+ "osd_mclock_profile"s,
-+ "osd_mclock_max_starve_time_hdd"s
- };
- }
- uint32_t calc_scaled_cost(int item_cost);
-
## src/common/options/osd.yaml.in ##
@@ src/common/options/osd.yaml.in: options:
- osd_mclock_max_capacity_iops_ssd
@@ src/common/options/osd.yaml.in: options:
# decode the object, any error will be reported.
## src/osd/scheduler/mClockScheduler.cc ##
+@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::set_osd_capacity_params_from_config()
+ << ", osd_bandwidth_capacity_per_shard "
+ << osd_bandwidth_capacity_per_shard << " bytes/second"
+ << dendl;
++
++ scheduler_max_starve_time = is_rotational
++ ? cct->_conf.get_val<double>("osd_mclock_max_starve_time_hdd")
++ : scheduler_max_starve_time_ssd;
+ }
+
+ /**
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_high(unsigned priority,
WorkItem mClockScheduler::dequeue()
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_high(unsigne
+ return (p == immediate_class_priority) ? "MAX" : std::to_string(p);
+ };
+ dout(10) << __func__ << " mclock queue starved for at least "
-+ << mclock_conf.get_scheduler_max_starve_time()
++ << scheduler_max_starve_time
+ << "s behind high_priority backlog (priority queues: "
+ << high_priority.size();
+ for (const auto& [prio, queue] : high_priority) {
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_high(unsigne
+ mclock_queue_t::PullReq result = scheduler.pull_request();
+ if (result.is_retn()) {
+ auto &retn = result.get_retn();
-+
-+ scheduler_op_type_t op_type = scheduler_op_type_t::unknown;
-+ utime_t time_queued = utime_t();
-+ if (retn.request) {
-+ op_type = get_scheduler_op_type(*retn.request);
-+ time_queued = retn.request->get_time_queued();
-+ }
-+ mclock_conf.put_mclock_counter(retn.client, op_type, time_queued);
++ _put_mclock_counter(retn.client);
+ last_mclock_service_time = crimson::dmclock::get_time();
+
+ return std::move(*retn.request);
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_high(unsigne
auto iter = high_priority.begin();
// invariant: high_priority entries are never empty
@@ src/osd/scheduler/mClockScheduler.cc: WorkItem mClockScheduler::dequeue()
- time_queued = retn.request->get_time_queued();
- }
- mclock_conf.put_mclock_counter(retn.client, op_type, time_queued);
-+ last_mclock_service_time = crimson::dmclock::get_time();
+ auto &retn = result.get_retn();
+ _put_mclock_counter(retn.client);
++ last_mclock_service_time = crimson::dmclock::get_time();
return std::move(*retn.request);
}
+ }
+@@ src/osd/scheduler/mClockScheduler.cc: std::vector<std::string> mClockScheduler::get_tracked_keys() const noexcept
+ "osd_mclock_max_capacity_iops_ssd"s,
+ "osd_mclock_max_sequential_bandwidth_hdd"s,
+ "osd_mclock_max_sequential_bandwidth_ssd"s,
+- "osd_mclock_profile"s
++ "osd_mclock_profile"s,
++ "osd_mclock_max_starve_time_hdd"s
+ };
+ }
+
+@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::handle_conf_change(
+ client_registry.update_from_config(
+ conf, osd_bandwidth_capacity_per_shard);
+ }
++ if (changed.count("osd_mclock_max_starve_time_hdd")) {
++ set_osd_capacity_params_from_config();
++ }
+ if (changed.count("osd_mclock_profile")) {
+ set_config_defaults_from_profile();
+ client_registry.update_from_config(
## src/osd/scheduler/mClockScheduler.h ##
-@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler {
+@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler, md_config_obs_t {
+ */
+ double osd_bandwidth_capacity_per_shard;
+
++ /**
++ * scheduler_max_starve_time / scheduler_max_starve_time_ssd
++ *
++ * Upper bound (secs) on how long the mClock managed queue may go unserviced
++ * while high_priority drain keeps being refilled, before yielding it one
++ * forced dequeue attempt. Without this, a sustained stream of high_priority
++ * traffic can starve the various mClock managed classes.
++ *
++ * Device-specific starve times: A HDD's own natural service time is multi-
++ * millisecond, and so the default 250ms bound is a modest multiple of that.
++ * See 'osd_mclock_max_starve_time_hdd' for more details. Flash devices
++ * complete a normal op much faster (sub millisecond), so the bound is
++ * tightened to a much shorter window of 50ms. This has been validated by
++ * real hardware testing and stays as an internal constant.
++ *
++ * But validation is not done on HDD test hardware and therefore it's exposed
++ * as a config option mentioned above with a default of 250ms and bound to
++ * [100ms, 500ms] rather than hardcode it. Thus is to allow an operator some
++ * flexibility in case a given HDD fleet needs a different value.
++ *
++ * Set in set_osd_capacity_params_from_config in the constructor and upon
++ * config change.
++ */
++ double scheduler_max_starve_time = 0.0;
++ static constexpr double scheduler_max_starve_time_ssd = 0.05; // 50 msec
++
+ class ClientRegistry {
+ std::array<
+ crimson::dmclock::ClientInfo,
+@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler, md_config_obs_t {
SubQueue high_priority;
priority_t immediate_class_priority = std::numeric_limits<priority_t>::max();
@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler
+ bool mclock_queue_is_starved() const {
+ return !scheduler.empty() &&
+ (crimson::dmclock::get_time() - last_mclock_service_time) >=
-+ mclock_conf.get_scheduler_max_starve_time();
++ scheduler_max_starve_time;
+ }
+
static scheduler_id_t get_scheduler_id(const OpSchedulerItem &item) {
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestHighPriorit
+ // mclock queue populated would force an mclock-queue pull ahead of
+ // high_priority, which is not what this test is checking -- that
+ // behavior gets its own dedicated tests below.
-+ q.enqueue(create_item(0, client1, SchedulerClass::client));
++ q.enqueue(create_item(0, client1, op_scheduler_class::client));
+ get_item(q.dequeue());
+ ASSERT_TRUE(q.empty());
+
// Insert ops into the mClock queue
for (unsigned i = 100; i < 102; ++i) {
- q.enqueue(create_item(i, client1, SchedulerClass::client));
+ q.enqueue(create_item(i, client1, op_scheduler_class::client));
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue) {
}
ASSERT_TRUE(q.empty());
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+
+// Tests for tracker 69078's starvation-bound fix: dequeue() forces one
+// mclock-managed-queue pull once it has gone unserviced for at least
-+// mclock_conf's scheduler_max_starve_time while high_priority keeps
++// scheduler_max_starve_time while high_priority keeps
+// refilling. The fixture is non-rotational (SSD/NVMe), so the bound is
+// the fixed internal constant (50ms);
+TEST_F(mClockSchedulerTest, TestNoForcedYieldBeforeThreshold) {
+ ASSERT_TRUE(q.empty());
+
+ // Set up last_mclock_service_time (see TestAllQueuesEnqueueDequeue).
-+ q.enqueue(create_item(0, client1, SchedulerClass::client));
++ q.enqueue(create_item(0, client1, op_scheduler_class::client));
+ get_item(q.dequeue());
+ ASSERT_TRUE(q.empty());
+
-+ q.enqueue(create_item(1, client1, SchedulerClass::background_best_effort));
-+ q.enqueue(create_high_prio_item(200, 200, client2, SchedulerClass::immediate));
++ q.enqueue(create_item(1, client1, op_scheduler_class::background_best_effort));
++ q.enqueue(create_high_prio_item(200, 200, client2, op_scheduler_class::immediate));
+
+ // Well under the 50ms SSD/NVMe threshold -- ordinary priority order
+ // (high_priority before the mclock queue) is unaffected, confirming
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+ ASSERT_TRUE(q.empty());
+
+ // Set up last_mclock_service_time.
-+ q.enqueue(create_item(0, client1, SchedulerClass::client));
++ q.enqueue(create_item(0, client1, op_scheduler_class::client));
+ get_item(q.dequeue());
+ ASSERT_TRUE(q.empty());
+
+ // One item sits pending in the mclock-managed queue throughout.
-+ q.enqueue(create_item(1, client1, SchedulerClass::background_best_effort));
++ q.enqueue(create_item(1, client1, op_scheduler_class::background_best_effort));
+
+ // Keep high_priority continuously refilled for longer than the 50ms
+ // SSD/NVMe threshold, without calling dequeue() in between -- mirrors
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+ // indefinitely.
+ for (unsigned i = 0; i < 60; ++i) {
+ q.enqueue(create_high_prio_item(100 + i, 100 + i, client2,
-+ SchedulerClass::immediate));
++ op_scheduler_class::immediate));
+ }
+ std::this_thread::sleep_for(60ms);
+
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+
+TEST(mClockSchedulerHDDTest, TestStarveTimeLiveReconfig) {
+ // Rotational path: osd_mclock_max_starve_time_hdd is read at
-+ // construction (MclockConfig::set_from_config(), called from its own
++ // construction (set_osd_capacity_params_from_config(), called from the
+ // constructor) and re-read live via the existing handle_conf_change()
+ // observer on any subsequent config change -- the same path every
+ // other mclock scheduler option already uses. Uses a standalone
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+ mClockScheduler q(g_ceph_context, /*whoami=*/0, /*num_shards=*/1,
+ /*shard_id=*/0, /*is_rotational=*/true,
+ /*cutoff_priority=*/12,
-+ 2ms, 2ms, 1ms, /*init_perfcounter=*/true);
++ 2ms, 2ms, 1ms, /*monc=*/nullptr,
++ /*init_perfcounter=*/true);
+ uint64_t client1 = 1001;
+ uint64_t client2 = 9999;
+
-+ q.enqueue(create_item(0, client1, SchedulerClass::client));
++ q.enqueue(create_item(0, client1, op_scheduler_class::client));
+ get_item(q.dequeue());
+ ASSERT_TRUE(q.empty());
+
-+ q.enqueue(create_item(1, client1, SchedulerClass::background_best_effort));
++ q.enqueue(create_item(1, client1, op_scheduler_class::background_best_effort));
+
+ // At the 250ms default, ~150ms of continuous high_priority refill is
+ // not enough to force a yield -- confirms the option's initial,
+ // construction-time value.
+ for (unsigned i = 0; i < 150; ++i) {
+ q.enqueue(create_high_prio_item(100 + i, 100 + i, client2,
-+ SchedulerClass::immediate));
++ op_scheduler_class::immediate));
+ }
+ std::this_thread::sleep_for(150ms);
+ auto r = get_item(q.dequeue());
@@ src/test/osd/TestMClockScheduler.cc: TEST_F(mClockSchedulerTest, TestSlowDequeue
+ // unmodified default.
+ for (unsigned i = 0; i < 150; ++i) {
+ q.enqueue(create_high_prio_item(300 + i, 300 + i, client2,
-+ SchedulerClass::immediate));
++ op_scheduler_class::immediate));
+ }
+ std::this_thread::sleep_for(150ms);
+ ASSERT_FALSE(q.empty());Deviation in Backport 94a2b76 (cherry-pick of cf5e5db)
Affected File(s)
src/osd/scheduler/mClockScheduler.cc
Range Diff
Click to expand
--- Original (cf5e5db4)
+++ Backport (94a2b760)
@@ -35,3 +35,17 @@
Fixes: https://tracker.ceph.com/issues/69078
Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit cf5e5db41db165cc81ddd1a6c80147a32a8bb3c3)
+
+Conflicts:
+ src/osd/scheduler/mClockScheduler.cc
+ - kept _put_mclock_counter(), because tentacle does not have the
+ per-op-type counters used by put_mclock_counter(). Kept the new
+ log line for items released from requeued_class_priority.
+ - use op_scheduler_class::client instead of SchedulerClass::client.
+ src/osd/scheduler/mClockScheduler.h
+ src/test/osd/TestMClockScheduler.cc
+ - use op_scheduler_class, because tentacle does not have the
+ SchedulerClass alias. For the classic OSD, SchedulerClass is an
+ alias of op_scheduler_class, so requeued_class_priority keeps the
+ same value (3).
================================================================================
RANGE DIFF
================================================================================
1: cf5e5db41db ! 1: 94a2b760d5a mClockScheduler: Reserve a requeued-item prio queue to prevent op-order aborts
@@ Commit message
Fixes: https://tracker.ceph.com/issues/69078
Signed-off-by: Sridhar Seshasayee <[email protected]>
+ (cherry picked from commit cf5e5db41db165cc81ddd1a6c80147a32a8bb3c3)
+
+ Conflicts:
+ src/osd/scheduler/mClockScheduler.cc
+ - kept _put_mclock_counter(), because tentacle does not have the
+ per-op-type counters used by put_mclock_counter(). Kept the new
+ log line for items released from requeued_class_priority.
+ - use op_scheduler_class::client instead of SchedulerClass::client.
+ src/osd/scheduler/mClockScheduler.h
+ src/test/osd/TestMClockScheduler.cc
+ - use op_scheduler_class, because tentacle does not have the
+ SchedulerClass alias. For the classic OSD, SchedulerClass is an
+ alias of op_scheduler_class, so requeued_class_priority keeps the
+ same value (3).
## src/osd/scheduler/mClockScheduler.cc ##
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_front(OpSchedulerItem&& item)
enqueue_high(immediate_class_priority, std::move(item), true);
} else if (priority >= cutoff_priority) {
enqueue_high(priority, std::move(item), true);
-+ } else if (SchedulerClass::client == id.class_id) {
++ } else if (op_scheduler_class::client == id.class_id) {
+ // mClock does not support enqueue at front, so we redirect into the
+ // reserved requeued_class_priority bucket instead. dequeue() must
+ // never pull from the mclock-managed queue via the starvation-bound
@@ src/osd/scheduler/mClockScheduler.cc: void mClockScheduler::enqueue_high(unsigne
@@ src/osd/scheduler/mClockScheduler.cc: WorkItem mClockScheduler::dequeue()
auto iter = high_priority.begin();
// invariant: high_priority entries are never empty
- ceph_assert(!iter->second.empty());
+ assert(!iter->second.empty());
+ const priority_t popped_priority = iter->first;
WorkItem ret{std::move(iter->second.back())};
iter->second.pop_back();
@@ src/osd/scheduler/mClockScheduler.cc: WorkItem mClockScheduler::dequeue()
// maintain invariant, high priority entries are never empty
high_priority.erase(iter);
}
-@@ src/osd/scheduler/mClockScheduler.cc: WorkItem mClockScheduler::dequeue()
+- ceph_assert(std::get_if<OpSchedulerItem>(&ret));
++ auto *item_ptr = std::get_if<OpSchedulerItem>(&ret);
++ ceph_assert(item_ptr);
+
+ scheduler_id_t id = scheduler_id_t {
+ op_scheduler_class::immediate,
+ client_profile_id_t()
};
- scheduler_op_type_t op_type = get_scheduler_op_type(*item_ptr);
- mclock_conf.put_mclock_counter(id, op_type, item_ptr->get_time_queued());
+ _put_mclock_counter(id);
+
+ // Log when a requeued_class_priority item is released.
+ if (popped_priority == requeued_class_priority) {
@@ src/osd/scheduler/mClockScheduler.cc: WorkItem mClockScheduler::dequeue()
mclock_queue_t::PullReq result = scheduler.pull_request();
## src/osd/scheduler/mClockScheduler.h ##
-@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler {
+@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler, md_config_obs_t {
SubQueue high_priority;
priority_t immediate_class_priority = std::numeric_limits<priority_t>::max();
+ /**
+ * requeued_class_priority
+ *
-+ * Reserved high_priority bucket for SchedulerClass::client items
++ * Reserved high_priority bucket for op_scheduler_class::client items
+ * pulled out of their normal queue position via enqueue_front() (e.g.
+ * PG::requeue_map_waiters()/requeue_op(), OSDShard::_wake_pg_slot()).
+ * mClock does not support inserting at the front of its own
@@ src/osd/scheduler/mClockScheduler.h: class mClockScheduler : public OpScheduler
+ *
+ * Kept well below every real high_priority value (cutoff_priority >= 64).
+ * The starvation-bound forced yield must never pull from the mclock-managed
-+ * queue while this bucket is non-empty.Set to SchedulerClass::client's own
++ * queue while this bucket is non-empty.Set to op_scheduler_class::client's own
+ * integer value purely so it self-documents in dumps/logs.
+ */
+ priority_t requeued_class_priority =
-+ static_cast<priority_t>(SchedulerClass::client);
++ static_cast<priority_t>(op_scheduler_class::client);
+
/**
* last_mclock_service_time
@@ src/test/osd/TestMClockScheduler.cc: TEST(mClockSchedulerHDDTest, TestStarveTime
+
+ // Step 1: Two ops from the same client, both sub-cutoff (client class) -
+ // simulates tids 10 and 11 arriving in order.
-+ q.enqueue(create_item(10, client1, SchedulerClass::client));
-+ q.enqueue(create_item(11, client1, SchedulerClass::client));
++ q.enqueue(create_item(10, client1, op_scheduler_class::client));
++ q.enqueue(create_item(11, client1, op_scheduler_class::client));
+
+ // Step 2: The first op is pulled from the mclock-managed queue for
+ // processing, then requeued via enqueue_front() -- simulates a PG-level
@@ src/test/osd/TestMClockScheduler.cc: TEST(mClockSchedulerHDDTest, TestStarveTime
+ // Step 1. Enqueued and redirected in isolation, before anything else
+ // exists in the scheduler. This dequeue() also sets up
+ // last_mclock_service_time (see TestAllQueuesEnqueueDequeue).
-+ q.enqueue(create_item(50, client2, SchedulerClass::client));
++ q.enqueue(create_item(50, client2, op_scheduler_class::client));
+ auto redirected = get_item(q.dequeue());
+ ASSERT_EQ(50u, redirected.get_map_epoch());
+ q.enqueue_front(std::move(redirected));
@@ src/test/osd/TestMClockScheduler.cc: TEST(mClockSchedulerHDDTest, TestStarveTime
+ // queue -- this is the one the starvation-bound forced yield would
+ // normally rescue once enough time has elapsed (see
+ // TestStarvationForcesYield).
-+ q.enqueue(create_item(1, client1, SchedulerClass::background_best_effort));
++ q.enqueue(create_item(1, client1, op_scheduler_class::background_best_effort));
+
+ // Let the mclock-queue item age past the 50ms SSD/NVMe starvation
+ // threshold -- ordinarily this alone is enough to force a yield (see
@@ src/test/osd/TestMClockScheduler.cc: TEST(mClockSchedulerHDDTest, TestStarveTime
+ // Step 1: Enqueue a non-client background_best_effort item, dequeue it and
+ // redirect it to the requeued_class_priority queue. The dequeue()
+ // also sets up last_mclock_service_time.
-+ q.enqueue(create_item(50, client2, SchedulerClass::background_best_effort));
++ q.enqueue(create_item(50, client2, op_scheduler_class::background_best_effort));
+ auto redirected = get_item(q.dequeue());
+ ASSERT_EQ(50u, redirected.get_map_epoch());
+ q.enqueue_front(std::move(redirected));
+
+ // Step 2: A different client's item now sits pending in the mclock-managed
+ // queue.
-+ q.enqueue(create_item(1, client1, SchedulerClass::background_best_effort));
++ q.enqueue(create_item(1, client1, op_scheduler_class::background_best_effort));
+
+ // Step 3: Age the mclock item past the 50ms starvation threshold.
+ std::this_thread::sleep_for(60ms);How to proceed:
- Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git
Conflicts:block intact) and include an explanation for changes. - Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
- Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting
/audit override.
Be familiar with the rules and guidelines for writing backports.
🛟 Need Help?
If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.
📋 Component Lead / Release Manager
To override the audit failure, apply releng-audit-override label or comment /audit override.
When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.
sseshasa
left a comment
There was a problem hiding this comment.
LGTM. Thanks for creating this backport!
|
/config check ok |
|
@tchaikov Please note that @rzarzynski would have to override the backport audit flag in order to get this merged. |
|
This PR has been added to wip-bharath28-testing-20260924.103245-tentacle. |
|
@rzarzynski Please review and override the backport audit flag. From my side, I verified that the conflicts resolution is correct. |
|
/audit override |
|
✅ Audit Override Applied by @rzarzynski. |
backport tracker: https://tracker.ceph.com/issues/80428
backport of #71205
parent tracker: https://tracker.ceph.com/issues/69078
this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh