181 lines
6.3 KiB
Diff
181 lines
6.3 KiB
Diff
|
From 140ae14a4d6374530c9ab19a29c246abbf6d60b8 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
||
|
Date: Fri, 11 Feb 2022 13:29:03 +0100
|
||
|
Subject: [PATCH] Add extra hp workers parameter
|
||
|
|
||
|
May be needed by dyndb plugins to prepare extra worker threads. If they
|
||
|
use isc_task_send, their threads need to have initialized enough thread
|
||
|
identifiers in isc_hp_init. New parameters allow that.
|
||
|
|
||
|
Allows specification of both relative and absolute number of extra
|
||
|
workers.
|
||
|
|
||
|
Adds new function isc_managers_create2() with extra parameter, call
|
||
|
original function from many tests and tools unchanged.
|
||
|
---
|
||
|
bin/named/include/named/globals.h | 2 ++
|
||
|
bin/named/include/named/main.h | 2 +-
|
||
|
bin/named/main.c | 29 +++++++++++++++++++++++++----
|
||
|
bin/named/named.rst | 9 +++++++++
|
||
|
lib/isc/include/isc/managers.h | 5 +++++
|
||
|
lib/isc/managers.c | 11 ++++++++++-
|
||
|
6 files changed, 52 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h
|
||
|
index 82b632ef04..d46e62b94d 100644
|
||
|
--- a/bin/named/include/named/globals.h
|
||
|
+++ b/bin/named/include/named/globals.h
|
||
|
@@ -53,6 +53,8 @@ EXTERN unsigned int named_g_udpdisp INIT(0);
|
||
|
EXTERN isc_taskmgr_t *named_g_taskmgr INIT(NULL);
|
||
|
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
|
||
|
EXTERN unsigned int named_g_cpus_detected INIT(1);
|
||
|
+EXTERN unsigned int named_g_hp_extra_workers INIT(0);
|
||
|
+EXTERN unsigned int named_g_hp_extra_percent INIT(100);
|
||
|
|
||
|
#ifdef ENABLE_AFL
|
||
|
EXTERN bool named_g_run_done INIT(false);
|
||
|
diff --git a/bin/named/include/named/main.h b/bin/named/include/named/main.h
|
||
|
index 816aeae7a0..9618251f4d 100644
|
||
|
--- a/bin/named/include/named/main.h
|
||
|
+++ b/bin/named/include/named/main.h
|
||
|
@@ -23,7 +23,7 @@
|
||
|
/*
|
||
|
* Commandline arguments for named; also referenced in win32/ntservice.c
|
||
|
*/
|
||
|
-#define NAMED_MAIN_ARGS "46A:c:d:D:E:fFgL:M:m:n:N:p:sS:t:T:U:u:vVx:X:"
|
||
|
+#define NAMED_MAIN_ARGS "46A:c:d:D:E:fFgh:H:L:M:m:n:N:p:sS:t:T:U:u:vVx:X:"
|
||
|
|
||
|
ISC_PLATFORM_NORETURN_PRE void
|
||
|
named_main_earlyfatal(const char *format, ...)
|
||
|
diff --git a/bin/named/main.c b/bin/named/main.c
|
||
|
index 9ad2d0e277..fbe4c8d011 100644
|
||
|
--- a/bin/named/main.c
|
||
|
+++ b/bin/named/main.c
|
||
|
@@ -351,7 +351,8 @@ usage(void) {
|
||
|
"username] [-U listeners]\n"
|
||
|
" [-X lockfile] [-m "
|
||
|
"{usage|trace|record|size|mctx}]\n"
|
||
|
- " [-M fill|nofill]\n"
|
||
|
+ " [-M fill|nofill] [-h extra_workers] "
|
||
|
+ "[-H extra_percent]\n"
|
||
|
"usage: named [-v|-V]\n");
|
||
|
}
|
||
|
|
||
|
@@ -792,6 +793,21 @@ parse_command_line(int argc, char *argv[]) {
|
||
|
named_g_foreground = true;
|
||
|
named_g_logstderr = true;
|
||
|
break;
|
||
|
+ case 'h':
|
||
|
+ named_g_hp_extra_workers =
|
||
|
+ parse_int(isc_commandline_argument,
|
||
|
+ "number of extra workers");
|
||
|
+ break;
|
||
|
+ case 'H':
|
||
|
+ named_g_hp_extra_percent =
|
||
|
+ parse_int(isc_commandline_argument,
|
||
|
+ "percent of extra workers");
|
||
|
+ if (named_g_hp_extra_percent < 100) {
|
||
|
+ named_main_earlyfatal(
|
||
|
+ "percent of extra workers "
|
||
|
+ "cannot be less than 100");
|
||
|
+ }
|
||
|
+ break;
|
||
|
case 'L':
|
||
|
named_g_logfile = isc_commandline_argument;
|
||
|
break;
|
||
|
@@ -904,6 +920,10 @@ create_managers(void) {
|
||
|
if (named_g_cpus == 0) {
|
||
|
named_g_cpus = named_g_cpus_detected;
|
||
|
}
|
||
|
+ if (named_g_hp_extra_percent > 100) {
|
||
|
+ named_g_hp_extra_workers +=
|
||
|
+ named_g_cpus * (named_g_hp_extra_percent - 100) / 100;
|
||
|
+ }
|
||
|
isc_log_write(
|
||
|
named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
|
||
|
ISC_LOG_INFO, "found %u CPU%s, using %u worker thread%s",
|
||
|
@@ -924,11 +944,12 @@ create_managers(void) {
|
||
|
"using %u UDP listener%s per interface", named_g_udpdisp,
|
||
|
named_g_udpdisp == 1 ? "" : "s");
|
||
|
|
||
|
- result = isc_managers_create(named_g_mctx, named_g_cpus, 0, &named_g_nm,
|
||
|
- &named_g_taskmgr);
|
||
|
+ result = isc_managers_create2(named_g_mctx, named_g_cpus, 0,
|
||
|
+ named_g_hp_extra_workers, &named_g_nm,
|
||
|
+ &named_g_taskmgr);
|
||
|
if (result != ISC_R_SUCCESS) {
|
||
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||
|
- "isc_managers_create() failed: %s",
|
||
|
+ "isc_managers_create2() failed: %s",
|
||
|
isc_result_totext(result));
|
||
|
return (ISC_R_UNEXPECTED);
|
||
|
}
|
||
|
diff --git a/bin/named/named.rst b/bin/named/named.rst
|
||
|
index 39c445f5f9..b5bf95398c 100644
|
||
|
--- a/bin/named/named.rst
|
||
|
+++ b/bin/named/named.rst
|
||
|
@@ -75,6 +75,15 @@ Options
|
||
|
``-g``
|
||
|
This option runs the server in the foreground and forces all logging to ``stderr``.
|
||
|
|
||
|
+``-h #workers``
|
||
|
+ This option requests extra worker threads initialized by hazard pointers. Used only for
|
||
|
+ dyndb plugins.
|
||
|
+
|
||
|
+``-H workers%``
|
||
|
+ This option requests extra worker threads initialized by hazard pointers. Value is
|
||
|
+ computed as percent of number of cpus set by ``-n`` parameter. Minimal value is 100%.
|
||
|
+ Used only for dyndb plugins.
|
||
|
+
|
||
|
``-L logfile``
|
||
|
This option sets the log to the file ``logfile`` by default, instead of the system log.
|
||
|
|
||
|
diff --git a/lib/isc/include/isc/managers.h b/lib/isc/include/isc/managers.h
|
||
|
index 0ed17ff31d..712ea3e3ed 100644
|
||
|
--- a/lib/isc/include/isc/managers.h
|
||
|
+++ b/lib/isc/include/isc/managers.h
|
||
|
@@ -25,5 +25,10 @@ isc_result_t
|
||
|
isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
|
||
|
isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp);
|
||
|
|
||
|
+isc_result_t
|
||
|
+isc_managers_create2(isc_mem_t *mctx, size_t workers, size_t quantum,
|
||
|
+ size_t hp_extra, isc_nm_t **netmgrp,
|
||
|
+ isc_taskmgr_t **taskmgrp);
|
||
|
+
|
||
|
void
|
||
|
isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp);
|
||
|
diff --git a/lib/isc/managers.c b/lib/isc/managers.c
|
||
|
index a285e80d8a..daf19c5596 100644
|
||
|
--- a/lib/isc/managers.c
|
||
|
+++ b/lib/isc/managers.c
|
||
|
@@ -21,15 +21,24 @@
|
||
|
isc_result_t
|
||
|
isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
|
||
|
isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp) {
|
||
|
+ return isc_managers_create2(mctx, workers, quantum, 0, netmgrp,
|
||
|
+ taskmgrp);
|
||
|
+}
|
||
|
+
|
||
|
+isc_result_t
|
||
|
+isc_managers_create2(isc_mem_t *mctx, size_t workers, size_t quantum,
|
||
|
+ size_t hp_extra, isc_nm_t **netmgrp,
|
||
|
+ isc_taskmgr_t **taskmgrp) {
|
||
|
isc_result_t result;
|
||
|
isc_taskmgr_t *taskmgr = NULL;
|
||
|
isc_nm_t *netmgr = NULL;
|
||
|
+ size_t hp_workers = 4 * (workers + hp_extra);
|
||
|
|
||
|
/*
|
||
|
* We have ncpus network threads, ncpus old network threads - make
|
||
|
* it 4x just to be on the safe side.
|
||
|
*/
|
||
|
- isc_hp_init(4 * workers);
|
||
|
+ isc_hp_init(hp_workers);
|
||
|
|
||
|
REQUIRE(netmgrp != NULL && *netmgrp == NULL);
|
||
|
isc__netmgr_create(mctx, workers, &netmgr);
|
||
|
--
|
||
|
2.34.1
|
||
|
|