ioevent_init: set max entries for io_uring gracefully
parent
b688973cf9
commit
926cd40114
|
|
@ -907,6 +907,7 @@ static const char *get_address_family_caption(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IOEVENT_USE_URING
|
||||||
static void get_io_uring_configs(const SFContext *sf_context,
|
static void get_io_uring_configs(const SFContext *sf_context,
|
||||||
bool *use_io_uring, bool *use_send_zc)
|
bool *use_io_uring, bool *use_send_zc)
|
||||||
{
|
{
|
||||||
|
|
@ -929,6 +930,7 @@ static void get_io_uring_configs(const SFContext *sf_context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void sf_context_config_to_string(const SFContext *sf_context,
|
void sf_context_config_to_string(const SFContext *sf_context,
|
||||||
char *output, const int size)
|
char *output, const int size)
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ int sf_service_init_ex2(SFContext *sf_context, const char *name,
|
||||||
int result;
|
int result;
|
||||||
int bytes;
|
int bytes;
|
||||||
int extra_events;
|
int extra_events;
|
||||||
|
int max_entries;
|
||||||
int i;
|
int i;
|
||||||
struct worker_thread_context *thread_contexts;
|
struct worker_thread_context *thread_contexts;
|
||||||
struct worker_thread_context *thread_ctx;
|
struct worker_thread_context *thread_ctx;
|
||||||
|
|
@ -200,15 +201,35 @@ int sf_service_init_ex2(SFContext *sf_context, const char *name,
|
||||||
thread_data->arg = NULL;
|
thread_data->arg = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioevent_init(&thread_data->ev_puller, sf_context->name,
|
#if IOEVENT_USE_URING
|
||||||
2 + sf_context->net_buffer_cfg.max_connections,
|
if (sf_context->net_buffer_cfg.max_connections < 16 * 1024) {
|
||||||
net_timeout_ms, extra_events) != 0)
|
max_entries = 2 * sf_context->net_buffer_cfg.max_connections;
|
||||||
|
} else {
|
||||||
|
max_entries = sf_context->net_buffer_cfg.max_connections;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
max_entries = 2 + sf_context->net_buffer_cfg.max_connections;
|
||||||
|
#endif
|
||||||
|
if ((result=ioevent_init(&thread_data->ev_puller, sf_context->name,
|
||||||
|
max_entries, net_timeout_ms, extra_events)) != 0)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : ENOMEM;
|
char prompt[256];
|
||||||
|
#if IOEVENT_USE_URING
|
||||||
|
if (result == EPERM) {
|
||||||
|
strcpy(prompt, " make sure kernel.io_uring_disabled set to 0");
|
||||||
|
} else if (result == EINVAL) {
|
||||||
|
sprintf(prompt, " maybe max_connections: %d is too large",
|
||||||
|
sf_context->net_buffer_cfg.max_connections);
|
||||||
|
} else {
|
||||||
|
*prompt = '\0';
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
*prompt = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"ioevent_init fail, "
|
"ioevent_init fail, errno: %d, error info: %s.%s"
|
||||||
"errno: %d, error info: %s",
|
, __LINE__, result, strerror(result), prompt);
|
||||||
__LINE__, result, strerror(result));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue