From: Witold Kręcicki Date: Thu, 25 Oct 2018 06:31:53 +0000 (+0000) Subject: Document isc_task_sendto properly, make sure that cpu we're sending to is always... X-Git-Tag: v9.13.4~51^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f166cabcae9c11d34bf269dd45435a6c13df6900;p=thirdparty%2Fbind9.git Document isc_task_sendto properly, make sure that cpu we're sending to is always sane --- diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index d3146f51a78..4ee783aedc0 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -212,7 +212,8 @@ isc_task_send(isc_task_t *task, isc_event_t **eventp); void isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int c); /*%< - * Send '*event' to 'task'. + * Send '*event' to 'task', if task is idle try starting it on cpu 'c' + * If 'c' is smaller than 0 then cpu is selected randomly. * * Requires: * @@ -231,7 +232,8 @@ void isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp); /*%< * Send '*event' to '*taskp' and then detach '*taskp' from its - * task. + * task. If task is idle try starting it on cpu 'c' + * If 'c' is smaller than 0 then cpu is selected randomly. * * Requires: * diff --git a/lib/isc/task.c b/lib/isc/task.c index 55418590bf3..e2124dd53c8 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -481,14 +481,13 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) { */ REQUIRE(VALID_TASK(task)); + XTRACE("isc_task_send"); - if (c == -1) { + if (c < 0) { c = atomic_fetch_add_explicit(&task->manager->curq, 1, - memory_order_relaxed) - % task->manager->workers; + memory_order_relaxed); } - - XTRACE("isc_task_send"); + c %= task->manager->workers; /* * We're trying hard to hold locks for as short a time as possible. @@ -532,13 +531,14 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) { REQUIRE(taskp != NULL); task = (isc__task_t *)*taskp; REQUIRE(VALID_TASK(task)); - if (c == -1) { + XTRACE("isc_task_sendanddetach"); + + if (c < 0) { c = atomic_fetch_add_explicit(&task->manager->curq, 1, - memory_order_relaxed) - % task->manager->workers; + memory_order_relaxed); } + c %= task->manager->workers; - XTRACE("isc_task_sendanddetach"); LOCK(&task->lock); idle1 = task_send(task, eventp, c); idle2 = task_detach(task);