Skip to content

umbrella: mclock_common, mClockScheduler: Bound high_priority drain to prevent starvation - #72179

Merged
batrick merged 2 commits into
ceph:umbrellafrom
sseshasa:wip-80429-umbrella
Oct 7, 2026
Merged

batrick merged 2 commits into
ceph:umbrellafrom
sseshasa:wip-80429-umbrella

Conversation

@sseshasa

Copy link
Copy Markdown
Contributor

…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)
…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)
@github-actions

Copy link
Copy Markdown

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.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@github-actions github-actions Bot added the releng-audit-pass Release engineering: passed backport verification audit. label Sep 29, 2026
@sseshasa

Copy link
Copy Markdown
Contributor Author

/config check ok

@sseshasa
sseshasa requested a review from rzarzynski September 29, 2026 05:08
@sseshasa sseshasa modified the milestones: umbrella, v21.1.2 Sep 29, 2026
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test api

@batrick

batrick commented Sep 29, 2026

Copy link
Copy Markdown
Member

@batrick

batrick commented Oct 1, 2026

Copy link
Copy Markdown
Member

jenkins test make check

@batrick

batrick commented Oct 1, 2026

Copy link
Copy Markdown
Member

jenkins test windows

@batrick

batrick commented Oct 1, 2026

Copy link
Copy Markdown
Member

jenkins test api

@batrick
batrick merged commit 6c33cf4 into ceph:umbrella Oct 7, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants