Skip to content

Crimson/osd: support multicore osd - #51147

Merged
Matan-B merged 7 commits into
ceph:mainfrom
liu-chunmei:multicore-osd
Jul 2, 2023
Merged

Matan-B merged 7 commits into
ceph:mainfrom
liu-chunmei:multicore-osd

Conversation

@liu-chunmei

@liu-chunmei liu-chunmei commented Apr 20, 2023 •

Copy link
Copy Markdown
Contributor

based on multicore-seastore : #48717
based on local_shared_foreign_ptr : #50835

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@liu-chunmei
liu-chunmei force-pushed the multicore-osd branch 2 times, most recently from 6368a8a to a6e9e12 Compare April 26, 2023 06:30
@liu-chunmei

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@athanatos
athanatos self-requested a review May 10, 2023 05:03
Comment thread src/crimson/osd/osd.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conn.get_foreign() cannot guarantee the ordering here, so it may not be caused by invoke_on().

If invoke_on() or smp::submit_to() cannot guarantee fifo in the submitted shard, it would be a larger issue. We probably need to scan all the places that is using them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took a quick look at the smp::submit_to() implementation, looks it is operating a pending_fifo queue explicitly, which strongly implies that it enforces fifo.

So I don't think it worths protecting invoke_on() or smp::submit_to() with additional cross-core unlock mechanisms.

@athanatos @liu-chunmei what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me, leave a comment though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems I only need to guarantee conn.get_foreign() ordering, will modify it.

@liu-chunmei liu-chunmei May 22, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@athanatos @cyx1231st if I only add mutex to guarantee conn.get_foreign() order, still has out-of-ordering problem. see below PR, still has out-of-ordering issue.

+        return op_mutex.lock().then([=, this] {
+          return conn.get_foreign().then([this, m = std::move(m),
+            core = insert_iter->second](auto f_conn) {
+            op_mutex.unlock();
+            return shard_dispatchers.invoke_on(core,
+              [f_conn = std::move(f_conn), m = std::move(m)]
+              (auto &local_dispatcher) mutable ->seastar::future<>{
+              return local_dispatcher.ms_dispatch(std::move(f_conn), m);
+            });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this ordering with only lock conn.get_foreign, the same problem as without any lock here.
primary core ms_dispatch sequence
---osd::ms_dispatch version = 0'0---reqid = 11735
---osd::ms_dispatch version = 0'0---reqid = 11736

shardDispatcher: handle_rep_op seqeunce
---osd::handle_rep_op version = 19'98---reqid = 11736---shard id = 1
---osd::handle_rep_op version = 19'97---reqid = 11735---shard id = 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print location:

   in osd::ms_dispatch: 
     switch (m->get_type()) {
+      case MSG_OSD_REPOP:
+std::cout<<"---osd::ms_dispatch version = "<<boost::static_pointer_cast<MOSDRepOp>(m)->version<<"---reqid = "<<boost::static_pointer_cast<MOSDRepOp>(m)->reqid.tid<<std::endl;
+      [[fallthrough]];

OSD::ShardDispatcher::handle_rep_op(
   m->finish_decode();
+std::cout<<"---osd::handle_rep_op version = "<<m->version<<"---reqid = "<<m->reqid.tid<<"---shard id = "<<seastar::this_shard_id()<<std::endl;
   std::ignore = pg_shard_manager.start_pg_operation<RepRequest>(
     std::move(conn),
     std::move(m));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a semaphore in invoke_on()/submit_to(), which cannot grarantee the FIFO order at wait(), quoted "Waits are serviced in FIFO order, though if several are awakened at once, they may be reordered by the scheduler."

So we shouldn't expect the target core gets called in the same order. I have also observed the same issue during multi-core messenger testing, which needs to be addressed separately.

Another impact is that we need to chain the future returned by Connection::send() wherever there is an ordering requirement.

@liu-chunmei

liu-chunmei commented Jun 2, 2023 •

Copy link
Copy Markdown
Contributor Author

@liu-chunmei

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Comment thread src/crimson/osd/osd.h Resolved
Comment thread src/crimson/osd/osd.cc Resolved
Comment thread src/crimson/osd/pg_map.h Resolved
Comment thread src/crimson/osd/pg_shard_manager.h Resolved
Comment thread src/crimson/osd/osd.cc Resolved
Comment thread src/crimson/osd/state.h Resolved
Comment thread src/crimson/osd/state.h Resolved
Comment thread src/crimson/osd/state.h Resolved
Comment thread src/crimson/osd/state.h Resolved
Comment thread src/crimson/common/operation.h Resolved
@liu-chunmei

Copy link
Copy Markdown
Contributor Author

@athanatos updated, please review again.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Comment thread src/crimson/common/operation.h Resolved
chunmei added 5 commits June 23, 2023 03:18
Previously, all accesses (incuding loookups) had to occur on core 0.  Now that
we want to be able to dispatch from all cores, we need PGShardManager to be
accessible from all cores.  To that end, we now proxy updates to core 0, but maintain
local copies of the map so that cores can perform local lookups.

Signed-off-by: chunmei <[email protected]>
… on PRIMARY_CORE

Proxy uses of osd_singleton_state to PRIMARY_CORE as needed.

Signed-off-by: chunmei <[email protected]>
Shortly, we will need to be able to pass a ConnectionRef from another core.

Signed-off-by: chunmei <[email protected]>
put them into PerShardState to avoid cross core calling for normal cases.

Signed-off-by: chunmei <[email protected]>
chunmei added 2 commits June 23, 2023 04:25
in debug build, if wait_barrier is seastar::now, will cause reactor
schedule the following continuation away, but can't schedule them back
in the same order as by which they are scheduled away, so the continuations
are out of order here.

Signed-off-by: chunmei <[email protected]>
@liu-chunmei

Copy link
Copy Markdown
Contributor Author

@athanatos updated, please review again.

@liu-chunmei

Copy link
Copy Markdown
Contributor Author

main branch + this PR + #51916 + the following modification, can do multicore-osd-msg-seastore testing.

diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc
index 1e817415d03..2d1b712c6a5 100644
--- a/src/crimson/osd/main.cc
+++ b/src/crimson/osd/main.cc
@@ -187,14 +187,20 @@ int main(int argc, const char* argv[])
           crimson::net::MessengerRef cluster_msgr, client_msgr;
           crimson::net::MessengerRef hb_front_msgr, hb_back_msgr;
           for (auto [msgr, name] : {make_pair(std::ref(cluster_msgr), "cluster"s),
-                                    make_pair(std::ref(client_msgr), "client"s),
-                                    make_pair(std::ref(hb_front_msgr), "hb_front"s),
+                                    make_pair(std::ref(client_msgr), "client"s)}) {
+            msgr = crimson::net::Messenger::create(entity_name_t::OSD(whoami),
+                                                   name,
+                                                   nonce,
+                                                   false);
+          }
+          for (auto [msgr, name] : {make_pair(std::ref(hb_front_msgr), "hb_front"s),
                                     make_pair(std::ref(hb_back_msgr), "hb_back"s)}) {
             msgr = crimson::net::Messenger::create(entity_name_t::OSD(whoami),
                                                    name,
                                                    nonce,
                                                    true);
           }
+
           auto store = crimson::os::FuturizedStore::create(
             local_conf().get_val<std::string>("osd_objectstore"),
             local_conf().get_val<std::string>("osd_data"),

@athanatos athanatos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@athanatos

athanatos commented Jun 28, 2023 •

Copy link
Copy Markdown
Contributor

I'll kick off a test run in the next few hours (branch wip-sjust-crimson-multicore-testing-2023-06-28)

@Matan-B
Matan-B merged commit 6bd7cd4 into ceph:main Jul 2, 2023

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments and questions towards really enabling multi-core message dispatching.

Comment thread src/crimson/osd/pg_map.h
return container().invoke_on(0,[pgid, core]
(auto &primary_mapping) {
auto [insert_iter, inserted] = primary_mapping.pg_to_core.emplace(pgid, core);
ceph_assert_always(inserted);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it true that multiple shards won't create the same pgid at the same time? Same for remove_pg().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/crimson/osd/osd.cc
case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY:
{
return conn.get_foreign().then([this, m = std::move(m)](auto f_conn) {
return shard_dispatchers.local().ms_dispatch(std::move(f_conn), std::move(m));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local dispatching doesn't need a foreign copy, the asynchronous foreign copy can also reorder the message unexpectedly. Fixed in #52306

Comment thread src/crimson/osd/osd.cc
default:
dispatched = false;
return seastar::now();
return container().invoke_on(PRIMARY_CORE,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message may be reordered at cross-core invoke, will it be a problem ?

Added FIXME comment in #52306

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.

4 participants