The NetBSD Project

CVS log for src/sys/kern/kern_threadpool.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / kern

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.19.2.1 / (download) - annotate - [select for diffs], Sat Apr 3 22:29:00 2021 UTC (3 years ago) by thorpej
Branch: thorpej-futex
Changes since 1.19: +102 -81 lines
Diff to previous 1.19 (colored) next main 1.20 (colored)

Sync with HEAD.

Revision 1.15.6.1 / (download) - annotate - [select for diffs], Mon Jan 25 14:12:50 2021 UTC (3 years, 2 months ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-3-RELEASE, netbsd-9-2-RELEASE
Changes since 1.15: +4 -3 lines
Diff to previous 1.15 (colored) next main 1.16 (colored)

Pull up following revision(s) (requested by riastradh in ticket #1187):

	sys/kern/kern_threadpool.c: revision 1.23

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

Revision 1.23 / (download) - annotate - [select for diffs], Sat Jan 23 16:33:49 2021 UTC (3 years, 2 months ago) by riastradh
Branch: MAIN
CVS Tags: thorpej-ifq-base, thorpej-ifq, thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, thorpej-altq-separation-base, thorpej-altq-separation, netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
Changes since 1.22: +4 -3 lines
Diff to previous 1.22 (colored)

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

Revision 1.22 / (download) - annotate - [select for diffs], Wed Jan 13 07:34:37 2021 UTC (3 years, 3 months ago) by skrll
Branch: MAIN
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

Improve english in a comment

Revision 1.21 / (download) - annotate - [select for diffs], Wed Jan 13 02:20:15 2021 UTC (3 years, 3 months ago) by riastradh
Branch: MAIN
Changes since 1.20: +92 -78 lines
Diff to previous 1.20 (colored)

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.

Revision 1.20 / (download) - annotate - [select for diffs], Wed Jan 13 02:19:08 2021 UTC (3 years, 3 months ago) by riastradh
Branch: MAIN
Changes since 1.19: +10 -4 lines
Diff to previous 1.19 (colored)

threadpool(9): Make threadpool_percpu_ref_remote non-sleepable.

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

Revision 1.19 / (download) - annotate - [select for diffs], Mon Sep 7 01:08:27 2020 UTC (3 years, 7 months ago) by riastradh
Branch: MAIN
Branch point for: thorpej-futex
Changes since 1.18: +11 -22 lines
Diff to previous 1.18 (colored)

threadpool: Simplify job reference-counting logic.

Use atomic_load_relaxed while here.

Revision 1.18 / (download) - annotate - [select for diffs], Sat Apr 25 17:43:23 2020 UTC (3 years, 11 months ago) by thorpej
Branch: MAIN
Changes since 1.17: +8 -3 lines
Diff to previous 1.17 (colored)

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

Revision 1.15.4.3 / (download) - annotate - [select for diffs], Wed Apr 8 14:08:51 2020 UTC (4 years ago) by martin
Branch: phil-wifi
Changes since 1.15.4.2: +181 -101 lines
Diff to previous 1.15.4.2 (colored) to branchpoint 1.15 (colored) next main 1.16 (colored)

Merge changes from current as of 20200406

Revision 1.15.8.1 / (download) - annotate - [select for diffs], Sat Feb 29 20:21:03 2020 UTC (4 years, 1 month ago) by ad
Branch: ad-namecache
Changes since 1.15: +181 -101 lines
Diff to previous 1.15 (colored) next main 1.16 (colored)

Sync with head.

Revision 1.17 / (download) - annotate - [select for diffs], Sun Feb 9 22:57:39 2020 UTC (4 years, 2 months ago) by riastradh
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3
Changes since 1.16: +126 -46 lines
Diff to previous 1.16 (colored)

Switch from ad-hoc logging to dtrace probes.

Revision 1.16 / (download) - annotate - [select for diffs], Sun Feb 9 22:57:26 2020 UTC (4 years, 2 months ago) by riastradh
Branch: MAIN
Changes since 1.15: +57 -57 lines
Diff to previous 1.15 (colored)

Teach threadpool(9) to use percpu_create, mostly.

Revision 1.15.4.2 / (download) - annotate - [select for diffs], Mon Jun 10 22:09:03 2019 UTC (4 years, 10 months ago) by christos
Branch: phil-wifi
Changes since 1.15.4.1: +1082 -0 lines
Diff to previous 1.15.4.1 (colored) to branchpoint 1.15 (colored)

Sync with HEAD

Revision 1.3.2.3 / (download) - annotate - [select for diffs], Fri Jan 18 08:50:57 2019 UTC (5 years, 2 months ago) by pgoyette
Branch: pgoyette-compat
CVS Tags: pgoyette-compat-merge-20190127
Changes since 1.3.2.2: +224 -227 lines
Diff to previous 1.3.2.2 (colored) to branchpoint 1.3 (colored) next main 1.4 (colored)

Synch with HEAD

Revision 1.15.4.1, Thu Jan 17 10:18:52 2019 UTC (5 years, 3 months ago) by christos
Branch: phil-wifi
Changes since 1.15: +0 -1082 lines
FILE REMOVED

file kern_threadpool.c was added on branch phil-wifi on 2019-06-10 22:09:03 +0000

Revision 1.15 / (download) - annotate - [select for diffs], Thu Jan 17 10:18:52 2019 UTC (5 years, 3 months ago) by hannken
Branch: MAIN
CVS Tags: phil-wifi-20191119, phil-wifi-20190609, pgoyette-compat-20190127, pgoyette-compat-20190118, netbsd-9-base, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, isaki-audio2-base, isaki-audio2, ad-namecache-base2, ad-namecache-base1, ad-namecache-base
Branch point for: phil-wifi, netbsd-9, ad-namecache
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

Use PRIu64 for "uint64_t tp_refcnt".

Revision 1.14 / (download) - annotate - [select for diffs], Sat Dec 29 04:39:14 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.13: +53 -5 lines
Diff to previous 1.13 (colored)

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

Revision 1.13 / (download) - annotate - [select for diffs], Fri Dec 28 00:15:57 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.12: +31 -24 lines
Diff to previous 1.12 (colored)

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.

Revision 1.12 / (download) - annotate - [select for diffs], Thu Dec 27 04:45:29 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.11: +22 -11 lines
Diff to previous 1.11 (colored)

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.

Revision 1.11 / (download) - annotate - [select for diffs], Wed Dec 26 22:16:26 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.10: +3 -25 lines
Diff to previous 1.10 (colored)

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

Revision 1.10 / (download) - annotate - [select for diffs], Wed Dec 26 21:43:39 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.9: +3 -3 lines
Diff to previous 1.9 (colored)

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.)

Revision 1.9 / (download) - annotate - [select for diffs], Wed Dec 26 21:25:51 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.8: +20 -19 lines
Diff to previous 1.8 (colored)

Whitespace tweaks.

Revision 1.8 / (download) - annotate - [select for diffs], Wed Dec 26 21:18:51 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.7: +3 -4 lines
Diff to previous 1.7 (colored)

Stylistic tweak to previous.

Revision 1.7 / (download) - annotate - [select for diffs], Wed Dec 26 21:15:50 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.6: +21 -40 lines
Diff to previous 1.6 (colored)

Simplify thread reference counting of the thread pool object.

Revision 1.6 / (download) - annotate - [select for diffs], Wed Dec 26 20:30:36 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.5: +27 -24 lines
Diff to previous 1.5 (colored)

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

Revision 1.5 / (download) - annotate - [select for diffs], Wed Dec 26 20:08:22 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.4: +10 -18 lines
Diff to previous 1.4 (colored)

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).

Revision 1.4 / (download) - annotate - [select for diffs], Wed Dec 26 18:54:19 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
Changes since 1.3: +64 -87 lines
Diff to previous 1.3 (colored)

- 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.

Revision 1.3.2.2 / (download) - annotate - [select for diffs], Wed Dec 26 14:02:04 2018 UTC (5 years, 3 months ago) by pgoyette
Branch: pgoyette-compat
Changes since 1.3.2.1: +1085 -0 lines
Diff to previous 1.3.2.1 (colored) to branchpoint 1.3 (colored)

Sync with HEAD, resolve a few conflicts

Revision 1.3.2.1, Tue Dec 25 05:44:13 2018 UTC (5 years, 3 months ago) by pgoyette
Branch: pgoyette-compat
Changes since 1.3: +0 -1085 lines
FILE REMOVED

file kern_threadpool.c was added on branch pgoyette-compat on 2018-12-26 14:02:04 +0000

Revision 1.3 / (download) - annotate - [select for diffs], Tue Dec 25 05:44:13 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN
CVS Tags: pgoyette-compat-1226
Branch point for: pgoyette-compat
Changes since 1.2: +3 -10 lines
Diff to previous 1.2 (colored)

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

Revision 1.2 / (download) - annotate - [select for diffs], Tue Dec 25 02:17:07 2018 UTC (5 years, 3 months ago) by kre
Branch: MAIN
Changes since 1.1: +11 -4 lines
Diff to previous 1.1 (colored)


Fix !DIAGNOSTIC builds.

Revision 1.1 / (download) - annotate - [select for diffs], Mon Dec 24 16:58:54 2018 UTC (5 years, 3 months ago) by thorpej
Branch: MAIN

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.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>