History log of /netbsd-src/sys/kern/kern_threadpool.c (Results 1 – 23 of 23)
Revision Date Author Comments
# caa99e8b 23-Jan-2021 riastradh <riastradh@NetBSD.org>

threadpool(9): Fix synchronization between cancel and dispatch.

- threadpool_cancel_job_async tried to prevent
threadpool_dispatcher_thread from taking the job by setting
job->job_thread = NULL

threadpool(9): Fix synchronization between cancel and dispatch.

- threadpool_cancel_job_async tried to prevent
threadpool_dispatcher_thread from taking the job by setting
job->job_thread = NULL and then removing the job from the queue.

- But threadpool_cancel_job_async didn't notice job->job_thread is
null until after it also removes the job from the queue =>
double-remove, *boom*.

The solution is to teach threadpool_dispatcher_thread to wait until
it has acquired the job lock to test whether job->job_thread is still
valid before it decides to remove the job from the queue.

Fixes PR kern/55948.

XXX pullup-9

show more ...


# 16902a87 13-Jan-2021 skrll <skrll@NetBSD.org>

Improve english in a comment


# a1c38838 13-Jan-2021 riastradh <riastradh@NetBSD.org>

threadpool(9): Tidy up thread naming.

- `dispatcher', not `overseer' -- much more appropriate metaphor.
- Just omit `/-1' from unbound thread names.
- Just omit `@-1' from dynamic-priority (PRI_NONE

threadpool(9): Tidy up thread naming.

- `dispatcher', not `overseer' -- much more appropriate metaphor.
- Just omit `/-1' from unbound thread names.
- Just omit `@-1' from dynamic-priority (PRI_NONE) thread names.

show more ...


# 8798207f 13-Jan-2021 riastradh <riastradh@NetBSD.org>

threadpool(9): Make threadpool_percpu_ref_remote non-sleepable.

Needed for threadpool-based workqueue_enqueue to run in interrupt
context.


# 340d2bc5 07-Sep-2020 riastradh <riastradh@NetBSD.org>

threadpool: Simplify job reference-counting logic.

Use atomic_load_relaxed while here.


# 8b5b320e 25-Apr-2020 thorpej <thorpej@NetBSD.org>

Take the ASSERT_SLEEPABLE() out of threadpool_cancel_job() and add a
comment explaining why we can't make that assertion there.


# f7aaf31f 09-Feb-2020 riastradh <riastradh@NetBSD.org>

Switch from ad-hoc logging to dtrace probes.


# 471ee6c6 09-Feb-2020 riastradh <riastradh@NetBSD.org>

Teach threadpool(9) to use percpu_create, mostly.


# d99716da 17-Jan-2019 hannken <hannken@NetBSD.org>

Use PRIu64 for "uint64_t tp_refcnt".


# 03010c6e 29-Dec-2018 thorpej <thorpej@NetBSD.org>

Expose the worker thread idle timeout via sysctl as "kern.threadpool.idle_ms".


# 5ccb236e 28-Dec-2018 thorpej <thorpej@NetBSD.org>

Fix job reference counting:
- threadpool_job_hold() no longer returns failure on overflow; it
asserts that overflow doesn't happen.
- threadpool_job_rele() must be called with the job lock held.
-

Fix job reference counting:
- threadpool_job_hold() no longer returns failure on overflow; it
asserts that overflow doesn't happen.
- threadpool_job_rele() must be called with the job lock held.
- Always grab a reference count on the job in threadpool_schedule_job()
if we're going to do any work.
- Drop that reference count directly in threadpool_job_done(); it's not
safe to dereference the job structure after the job function has called it.
- In the overseer thread, when handing off the job to work thread, hold an
extra reference briefly, as there's a window where we hold neither the
pool lock or the job lock, and without this extra reference, the job could
be snatched away.

show more ...


# 0f894b8c 27-Dec-2018 thorpej <thorpej@NetBSD.org>

Restore curlwp->l_name in threadpool_job_done(), rather than after the
job function has returned. This lays the groundwork for some job object
reference counting change that will be coming in a subs

Restore curlwp->l_name in threadpool_job_done(), rather than after the
job function has returned. This lays the groundwork for some job object
reference counting change that will be coming in a subsequent comment.

show more ...


# 62117aaf 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Rather than performing lazy initialization, statically initialize early
in the respective kernel startup routines.


# 026a00ed 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Adjust the definition of threadpool_job_fn_t to reflect Taylor's original
intent. (The original didn't compile, and I'm not a very good mind reader.)


# 6eaddb81 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Whitespace tweaks.


# d99408ae 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Stylistic tweak to previous.


# bece032b 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Simplify thread reference counting of the thread pool object.


# 518f5aa8 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Make the callers of threadpool_create() and threadpool_destroy()
responsibile for managing their own storage.


# c17b4c93 26-Dec-2018 thorpej <thorpej@NetBSD.org>

Use uint64_t for the unbound and per-cpu thread pool ref counts; they're
always manipulated under a lock. Rather than bother returning EBUSY,
just assert that the ref count never overlows (if it eve

Use uint64_t for the unbound and per-cpu thread pool ref counts; they're
always manipulated under a lock. Rather than bother returning EBUSY,
just assert that the ref count never overlows (if it ever does, you have
bigger problems).

show more ...


# fd471022 26-Dec-2018 thorpej <thorpej@NetBSD.org>

- De-opaque'ify struct threadpool_job.
- De-_t'ify all of the structure types.

No functional chage, no ABI change (verified with old rump unit test
before and after new librump.so).

Per Taylor's re

- De-opaque'ify struct threadpool_job.
- De-_t'ify all of the structure types.

No functional chage, no ABI change (verified with old rump unit test
before and after new librump.so).

Per Taylor's request.

show more ...


# ff4be2cb 25-Dec-2018 thorpej <thorpej@NetBSD.org>

Ho ho ho! We can suppress that warning with __diagused! Merry Christmas!


# 9b60e924 25-Dec-2018 kre <kre@NetBSD.org>

Fix !DIAGNOSTIC builds.


# 2834fa0a 24-Dec-2018 thorpej <thorpej@NetBSD.org>

Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on t

Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
be used, reduce the memory footprint by using linked lists, rather than
2 large (and mostly empty) tables. The performance impact is essentially
nil, since these lists are consulted only when pools are created (and
destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
entries.
- Make threadpool job object, which the caller must allocate storage for,
really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.

show more ...