Skip to content

cmake: fix WITH_SYSTEM_LIBURING and make uring available outside of src/blk#50821

Merged
cbodley merged 11 commits intoceph:mainfrom
cbodley:wip-cmake-uring
Oct 31, 2023
Merged

cmake: fix WITH_SYSTEM_LIBURING and make uring available outside of src/blk#50821
cbodley merged 11 commits intoceph:mainfrom
cbodley:wip-cmake-uring

Conversation

@cbodley
Copy link
Contributor

@cbodley cbodley commented Mar 31, 2023

this is preparation for the use of boost::asio's uring-based file abstractions in #50635

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

@cbodley cbodley requested a review from a team as a code owner March 31, 2023 18:38
@cbodley
Copy link
Contributor Author

cbodley commented Mar 31, 2023

debian builds will continue to build from submodule, because liburing-dev is available for jammy but not focal

@cbodley cbodley requested a review from dang March 31, 2023 18:39
@cbodley cbodley requested a review from a team as a code owner March 31, 2023 18:50
@github-actions github-actions bot added the rgw label Mar 31, 2023
@cbodley cbodley force-pushed the wip-cmake-uring branch 2 times, most recently from 9ba9e38 to 5a6ebe3 Compare March 31, 2023 19:52
@cbodley
Copy link
Contributor Author

cbodley commented Mar 31, 2023

i tried enabling WITH_SYSTEM_LIBURING for centos builds, but that seems to have broken rocksdb builds, so i reverted that

@ktdreyer
Copy link
Contributor

ktdreyer commented Apr 3, 2023

A good example of a speedup we could get from dropping Ubuntu Focal

@cbodley
Copy link
Contributor Author

cbodley commented Apr 11, 2023

jenkins test make check


const size_t OBJECT_SIZE = 4 * 1024 * 1024;
const uint64_t DATA_OFFSET = MockCryptoInterface::DATA_OFFSET;
const uint64_t DATA_OFFSET = MockCryptoInterface::MOCK_CRYPTO_INTERFACE_DATA_OFFSET;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand the rationale:

there's a conflicting BLOCK_SIZE macro defined inside
the liburing headers.

Is there an expectation that a random librbd unit test would end up including liburing.h now? Is it because it would be forced by one of the Boost headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the BOOST_ASIO_HAS_IO_URING define causes boost/asio.hpp to include this header:

In file included from /usr/include/liburing/io_uring.h:11,
                 from /usr/include/liburing.h:25,
                 from /home/cbodley/ceph/build/boost/include/boost/asio/detail/io_uring_operation.hpp:22,
                 from /home/cbodley/ceph/build/boost/include/boost/asio/detail/io_uring_descriptor_read_at_op.hpp:28,
                 from /home/cbodley/ceph/build/boost/include/boost/asio/detail/io_uring_descriptor_service.hpp:28,
                 from /home/cbodley/ceph/build/boost/include/boost/asio/detail/io_uring_file_service.hpp:26,
                 from /home/cbodley/ceph/build/boost/include/boost/asio/basic_file.hpp:39,
                 from /home/cbodley/ceph/build/boost/include/boost/asio.hpp:28,
                 from /home/cbodley/ceph/src/include/neorados/RADOS.hpp:27,
                 from /home/cbodley/ceph/src/test/librbd/mock/MockImageCtx.cc:4:
/home/cbodley/ceph/src/test/librbd/mock/crypto/MockCryptoInterface.h:16:25: error: expected unqualified-id before numeric constant
   16 |   static const uint64_t BLOCK_SIZE = 4096;
      |                         ^~~~~~~~~~

cc @adamemerson we might consider changing neorados/RADOS.hpp to use more granular includes of asio headers to avoid this dependency on liburing (and to reduce compilation times in general)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we might consider changing neorados/RADOS.hpp to use more granular includes of asio headers

i added some more commits for this, along with a SQUASHME commit that reverts the changes to this librbd test

@github-actions github-actions bot added the mon label Apr 26, 2023
@cbodley cbodley force-pushed the wip-cmake-uring branch 5 times, most recently from 49e78a0 to 65945b9 Compare April 26, 2023 20:47
@cbodley
Copy link
Contributor Author

cbodley commented Aug 7, 2023

shaman builds failing with:

[ 13%] Building CXX object src/test/neorados/CMakeFiles/ceph_test_neorados_completions.dir/completions.cc.o
In file included from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio/detail/io_uring_descriptor_read_at_op.hpp:28,
                 from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio/detail/io_uring_descriptor_service.hpp:28,
                 from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio/detail/io_uring_file_service.hpp:26,
                 from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio/basic_file.hpp:39,
                 from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio.hpp:34,
                 from /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/src/test/neorados/completions.cc:2:
/home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5334-gd6b233c9/rpm/el8/BUILD/ceph-18.0.0-5334-gd6b233c9/x86_64-redhat-linux-gnu/boost/include/boost/asio/detail/io_uring_operation.hpp:22:10: fatal error: liburing.h: No such file or directory
   22 | #include <liburing.h>
      |          ^~~~~~~~~~~~

@cbodley
Copy link
Contributor Author

cbodley commented Aug 7, 2023

more stuff to work through in the neorados tests:

[ 52%] Building CXX object src/test/neorados/CMakeFiles/ceph_test_neorados_start_stop.dir/start_stop.cc.o
/home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5335-gac24d24a/rpm/el8/BUILD/ceph-18.0.0-5335-gac24d24a/src/test/neorados/start_stop.cc: In function ‘int main(int, char**)’:
/home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-5335-gac24d24a/rpm/el8/BUILD/ceph-18.0.0-5335-gac24d24a/src/test/neorados/start_stop.cc:43:55: error: ‘use_future’ is not a member of ‘boost::asio’
   43 |                                          boost::asio::use_future).get();
      |                                                       ^~~~~~~~~~

@cbodley cbodley force-pushed the wip-cmake-uring branch 2 times, most recently from 809afa1 to 21d4d85 Compare August 21, 2023 15:53
@cbodley
Copy link
Contributor Author

cbodley commented Oct 16, 2023

jenkins test make check

@cbodley
Copy link
Contributor Author

cbodley commented Oct 16, 2023

@cbodley cbodley added needs-qa and removed TESTED labels Oct 16, 2023
@idryomov
Copy link
Contributor

Hrm, run-rbd-unit-tests-61.sh failed again. Not sure what the previous failure was, this one is a crash:

[ RUN      ] TestLibRBD.TestDataPoolIO
/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/run-rbd-unit-tests.sh: line 20: 3005947 Segmentation fault      RBD_FEATURES=$i unittest_librbd
...
The following tests FAILED:
	 32 - run-rbd-unit-tests-61.sh (Failed)

@idryomov
Copy link
Contributor

jenkins test make check

@idryomov
Copy link
Contributor

Hrm, run-rbd-unit-tests-61.sh failed again. Not sure what the previous failure was, this one is a crash:

Nothing to go on here, filed https://tracker.ceph.com/issues/63222 just for tracking purposes.

@github-actions
Copy link

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

liburing-devel package provides `/usr/lib64/liburing.so`. without this
fix, `find_package(uring)` failed with this `CMAKE_FIND_DEBUG_MODE`
output:
```
  find_library considered the following locations:

    /home/cbodley/ceph/build/virtualenv/bin//(lib)liburing.a(\.so|\.a)
    /home/cbodley/ceph/build/virtualenv/bin/(lib)liburing.a(\.so|\.a)
    /usr/local/bin//(lib)liburing.a(\.so|\.a)
    /usr/local/bin/(lib)liburing.a(\.so|\.a)
    /usr/local/sbin//(lib)liburing.a(\.so|\.a)
    /usr/local/sbin/(lib)liburing.a(\.so|\.a)
    /usr/bin//(lib)liburing.a(\.so|\.a)
    /usr/bin/(lib)liburing.a(\.so|\.a)
    /usr/sbin//(lib)liburing.a(\.so|\.a)
    /usr/sbin/(lib)liburing.a(\.so|\.a)
    /usr/local/lib64//(lib)liburing.a(\.so|\.a)
    /usr/local/lib64/(lib)liburing.a(\.so|\.a)
    /usr/local/lib//(lib)liburing.a(\.so|\.a)
    /usr/local/lib/(lib)liburing.a(\.so|\.a)
    /usr/local//(lib)liburing.a(\.so|\.a)
    /usr/local/(lib)liburing.a(\.so|\.a)
    /usr/lib64//(lib)liburing.a(\.so|\.a)
    /usr/lib64/(lib)liburing.a(\.so|\.a)
    /usr/lib//(lib)liburing.a(\.so|\.a)
    /usr/lib/(lib)liburing.a(\.so|\.a)
    /usr//(lib)liburing.a(\.so|\.a)
    /usr/(lib)liburing.a(\.so|\.a)
    /lib64//(lib)liburing.a(\.so|\.a)
    /lib64/(lib)liburing.a(\.so|\.a)
    /lib//(lib)liburing.a(\.so|\.a)
    /lib/(lib)liburing.a(\.so|\.a)
    /opt//(lib)liburing.a(\.so|\.a)
    /opt/(lib)liburing.a(\.so|\.a)
    /usr/lib64/X11//(lib)liburing.a(\.so|\.a)
    /usr/lib64/X11/(lib)liburing.a(\.so|\.a)
```

Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
this added a dependency on uring headers where it wasn't necessary.
pick_address.cc was relying on that for the IFF_UP define

Signed-off-by: Casey Bodley <cbodley@redhat.com>
the use of boost::asio::posix::stream_descriptor requires the
concrete header instead of posix/basic_stream_descriptor.hpp

Signed-off-by: Casey Bodley <cbodley@redhat.com>
avoid the boost/asio.hpp convenience header, as it pulls in a dependency
on liburing

Signed-off-by: Casey Bodley <cbodley@redhat.com>
and use the updated class name io_context

Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
@NitzanMordhai
Copy link
Contributor

@cbodley cbodley merged commit d5792f0 into ceph:main Oct 31, 2023
@cbodley
Copy link
Contributor Author

cbodley commented Oct 31, 2023

thanks @yuriw @ljflores @NitzanMordhai

@idryomov
Copy link
Contributor

idryomov commented Dec 4, 2023

@cbodley This has caused a regression in librbd in the place where it uses ASIO to connect and fetch an image via HTTP:
https://tracker.ceph.com/issues/63682.

Here is the job in question on main (+ unrelated RBD PR), ran 10 times:
https://pulpito.ceph.com/dis-2023-12-03_21:40:18-rbd-wip-dis-testing-distro-default-smithi/

And here is the same job with 05c341b and f479bbc from this PR reverted:
https://pulpito.ceph.com/dis-2023-12-03_22:06:02-rbd-wip-dis-testing-revert-distro-default-smithi/

I think the issue is that header file reshuffling in librados lead to 29ee772 (Jason's workaround for what is arguably a bug in ASIO, see chriskohlhoff/asio#642) to break. Some of the static initialization no longer occurs in librados and therefore is no longer covered by that global snippet in src/librados/librados.map.

tchaikov added a commit to tchaikov/ceph that referenced this pull request Mar 5, 2026
BOOST_ASIO_HAS_IO_URING is a user-defined macro that enables io_uring
support in Boost.Asio for specific operations that explicitly opt in,
such as file I/O via basic_file (BOOST_ASIO_HAS_FILE) and buffer
registration. Unlike BOOST_ASIO_HAS_IO_URING_AS_DEFAULT, it does NOT
replace epoll as the default event loop. Currently, Ceph does not use
Boost.Asio to perform file I/O, so this macro only affects compilation,
not runtime behavior.

When BOOST_ASIO_HAS_IO_URING is defined, the umbrella header
boost/asio.hpp pulls in <liburing.h> via:

  boost/asio.hpp
    -> boost/asio/basic_file.hpp  (guarded by BOOST_ASIO_HAS_FILE)
      -> boost/asio/detail/io_uring_file_service.hpp
        -> boost/asio/detail/io_uring_descriptor_service.hpp
          -> boost/asio/detail/io_uring_service.hpp
            -> <liburing.h>

PR ceph#50821 introduced BOOST_ASIO_HAS_IO_URING (commit 05c341b) as
preparation for uring-based file I/O in rgw/posix. To avoid pulling
liburing headers (which define macros like BLOCK_SIZE and DATA_OFFSET
that conflict with Ceph code) into unrelated translation units, that PR
also converted many files to use granular Boost.Asio includes instead of
the umbrella boost/asio.hpp.

However, BOOST_ASIO_HAS_IO_URING was added as a global compile
definition, and individual targets linked uring::uring directly. This
has two problems:

1. The uring::uring CMake target only exists when WITH_LIBURING=ON, so
   targets that link it unconditionally break when WITH_LIBURING=OFF.
2. The global definition causes all translation units to see
   BOOST_ASIO_HAS_IO_URING, even those that don't need io_uring.

Since neither CMake's FindBoost module nor Boost's CMake config file
defines a Boost::asio target, introduce one as an INTERFACE IMPORTED
library. When WITH_LIBURING=ON, the Boost::asio target carries the
BOOST_ASIO_HAS_IO_URING definition and uring::uring dependency; when
WITH_LIBURING=OFF, it is an empty interface. Targets that don't need
io_uring should use Boost::headers or Boost::boost instead.

This also improves code organization:

- Scope the BOOST_ASIO_HAS_IO_URING compile definition to Boost::asio
  instead of adding it globally, so only targets that actually use
  Boost.Asio with io_uring see the definition.
- Place the uring-in-Boost::asio configuration next to where we
  build/detect Boost libraries for better readability.
- Set the Boost::asio properties in a single place for better
  maintainability.

See also
- 05c341b
- f479bbc

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
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.

6 participants