From 2207f8d7318ba219f071fa1fa2f1cb553b7e06c2 Mon Sep 17 00:00:00 2001 From: Sridhar Seshasayee Date: Thu, 21 Jul 2022 21:31:55 +0530 Subject: [PATCH] osd: Handle oncommits and wait for future work items from mClock queue When a worker thread with the smallest thread index waits for future work items from the mClock queue, oncommit callbacks are called. But after the callback, the thread has to continue waiting instead of returning back to the ShardedThreadPool::shardedthreadpool_worker() loop. Returning results in the threads with the smallest index across all shards to busy loop causing very high CPU utilization. The fix involves reacquiring the shard_lock and waiting on sdata_cond until notified or until time period lapses. After this, the smallest thread index repopulates the oncommit queue from the context_queue if there were any additions. Fixes: https://tracker.ceph.com/issues/56530 Signed-off-by: Sridhar Seshasayee (cherry picked from commit 180a5a7bffd4d96c472cc39447717958dd51bbd9) --- src/osd/OSD.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 141326d45d639..c1b2a6503bf5a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -10877,7 +10877,7 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) if (is_smallest_thread_index) { sdata->shard_lock.unlock(); handle_oncommits(oncommits); - return; + sdata->shard_lock.lock(); } std::unique_lock wait_lock{sdata->sdata_wait_lock}; auto future_time = ceph::real_clock::from_double(*when_ready); @@ -10893,6 +10893,11 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) // Reapply default wq timeouts osd->cct->get_heartbeat_map()->reset_timeout(hb, timeout_interval, suicide_interval); + // Populate the oncommits list if there were any additions + // to the context_queue while we were waiting + if (is_smallest_thread_index) { + sdata->context_queue.move_to(oncommits); + } } } // while -- 2.39.5