2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Add ISC_TID_MAX with default being 512 threads

The ISC_TID_MAX variable allows other units to declare static arrays
with this as size for per-thread/per-loop variables.
This commit is contained in:
Ondřej Surý 2025-06-04 18:00:01 +02:00
parent 1032681af0
commit dd37fd6a49
3 changed files with 21 additions and 5 deletions

View File

@ -946,6 +946,8 @@ parse_command_line(int argc, char *argv[]) {
static isc_result_t
create_managers(void) {
bool capped = false;
/*
* Set the default named_g_cpus if it was not set from the command line
*/
@ -954,11 +956,19 @@ create_managers(void) {
named_g_cpus = named_g_cpus_detected;
}
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "found %u CPU%s, using %u worker thread%s",
named_g_cpus_detected,
named_g_cpus_detected == 1 ? "" : "s", named_g_cpus,
named_g_cpus == 1 ? "" : "s");
if (named_g_cpus > ISC_TID_MAX) {
capped = true;
named_g_cpus = ISC_TID_MAX;
}
isc_log_write(
NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"found %u CPU%s, using %u worker thread%s%s",
named_g_cpus_detected, named_g_cpus_detected == 1 ? "" : "s",
named_g_cpus, named_g_cpus == 1 ? "" : "s",
capped ? " (recompile with -DISC_TID_MAX=<n> to raise the "
"thread count limit)"
: "");
isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_loopmgr,
&named_g_netmgr);

View File

@ -23,6 +23,10 @@ typedef int32_t isc_tid_t;
#define ISC_TID_UNKNOWN (isc_tid_t) - 1
#ifndef ISC_TID_MAX
#define ISC_TID_MAX 512
#endif /* ISC_TID_MAX */
isc_tid_t
isc_tid_count(void);
/*%<

View File

@ -37,12 +37,14 @@ static isc_tid_t tid_count = 0;
void
isc__tid_init(isc_tid_t tid) {
REQUIRE(isc__tid_local == ISC_TID_UNKNOWN || isc__tid_local == tid);
REQUIRE(tid < ISC_TID_MAX);
isc__tid_local = tid;
}
void
isc__tid_initcount(isc_tid_t count) {
REQUIRE(tid_count == 0 || tid_count == count);
REQUIRE(tid_count < ISC_TID_MAX);
tid_count = count;
}