mirror of
https://github.com/matrix-construct/construct
synced 2024-05-23 13:23:46 +02:00
construct: Interpose IORING_SETUP_COOP_TASKRUN where supported.
This commit is contained in:
parent
9154233db5
commit
137824eb77
|
@ -32,6 +32,7 @@ AM_LDFLAGS = \
|
|||
-Wl,--rosegment \
|
||||
-Wl,-z,noexecstack \
|
||||
-Wl,--wrap=epoll_wait \
|
||||
-Wl,--wrap=io_uring_queue_init \
|
||||
-L$(top_srcdir)/ircd \
|
||||
-L$(top_srcdir)/modules \
|
||||
$(PLATFORM_LDFLAGS) \
|
||||
|
|
|
@ -50,6 +50,7 @@ const char *bootstrap;
|
|||
const char *diagnostic;
|
||||
bool nobanner;
|
||||
bool silentmode;
|
||||
bool noiouct;
|
||||
|
||||
lgetopt opts[]
|
||||
{
|
||||
|
@ -87,6 +88,7 @@ lgetopt opts[]
|
|||
{ "diagnostic", &diagnostic, lgetopt::STRING, "Specify a diagnostic type in conjunction with other commands" },
|
||||
{ "nobanner", &nobanner, lgetopt::BOOL, "Terminal log enabled only in runlevel RUN" },
|
||||
{ "silent", &silentmode, lgetopt::BOOL, "Like quiet mode without console output either" },
|
||||
{ "noiouct", &noiouct, lgetopt::BOOL, "Disable experimental IORING_SETUP_COOP_TASKRUN" },
|
||||
{ nullptr, nullptr, lgetopt::STRING, nullptr },
|
||||
};
|
||||
|
||||
|
@ -671,3 +673,59 @@ __wrap_epoll_wait(int __epfd,
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is where we interpose additional features for io_uring not yet
|
||||
// leveraged by ASIO.
|
||||
//
|
||||
#if IRCD_USE_ASIO_IO_URING
|
||||
|
||||
extern "C" int
|
||||
__real_io_uring_queue_init(unsigned,
|
||||
struct io_uring *,
|
||||
unsigned flags);
|
||||
|
||||
extern "C" int
|
||||
__wrap_io_uring_queue_init(unsigned entries,
|
||||
struct io_uring *ring,
|
||||
unsigned flags)
|
||||
{
|
||||
namespace info = ircd::info;
|
||||
|
||||
const bool have_coop_taskrun
|
||||
{
|
||||
info::kernel_version[0] > 5 ||
|
||||
(info::kernel_version[0] >= 5 && info::kernel_version[1] >= 19)
|
||||
};
|
||||
|
||||
#if defined(IORING_SETUP_COOP_TASKRUN)
|
||||
if(have_coop_taskrun && !noiouct)
|
||||
flags |= IORING_SETUP_COOP_TASKRUN;
|
||||
#endif
|
||||
|
||||
struct io_uring_params params
|
||||
{
|
||||
.flags = flags,
|
||||
};
|
||||
|
||||
int ret;
|
||||
if constexpr((true))
|
||||
ret = ::io_uring_queue_init_params
|
||||
(
|
||||
entries,
|
||||
ring,
|
||||
¶ms
|
||||
);
|
||||
else
|
||||
ret = __real_io_uring_queue_init
|
||||
(
|
||||
entries,
|
||||
ring,
|
||||
flags
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue