Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164863093
D55579.id172906.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55579.id172906.diff
View Options
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -336,6 +336,15 @@
&splice_receive_stream, 0,
"Use soreceive_stream() for stream splices");
+static int splice_max_wq = -1;
+SYSCTL_INT(_kern_ipc_splice, OID_AUTO, max_wq, CTLFLAG_RDTUN,
+ &splice_max_wq, -1,
+ "Limit the number of splice worker threads (-1 is unlimited)");
+
+static int splice_num_wq;
+SYSCTL_INT(_kern_ipc_splice, OID_AUTO, num_wq, CTLFLAG_RD,
+ &splice_num_wq, 0, "Number of splice worker threads");
+
static uma_zone_t splice_zone;
static struct proc *splice_proc;
struct splice_wq {
@@ -447,24 +456,33 @@
return (0);
}
+ if (splice_max_wq == 0) {
+ splice_init_state = -1;
+ return (ENXIO);
+ } else if (splice_max_wq > 0 && splice_max_wq < mp_ncpus) {
+ splice_num_wq = splice_max_wq;
+ } else {
+ splice_num_wq = mp_ncpus;
+ }
+
splice_zone = uma_zcreate("splice", sizeof(struct so_splice), NULL,
NULL, splice_zinit, splice_zfini, UMA_ALIGN_CACHE, 0);
- splice_wq = mallocarray(mp_maxid + 1, sizeof(*splice_wq), M_TEMP,
+ splice_wq = mallocarray(splice_num_wq, sizeof(*splice_wq), M_TEMP,
M_WAITOK | M_ZERO);
/*
* Initialize the workqueues to run the splice work. We create a
* work queue for each CPU.
*/
- CPU_FOREACH(i) {
+ for (i = 0; i < splice_num_wq; i++) {
STAILQ_INIT(&splice_wq[i].head);
mtx_init(&splice_wq[i].mtx, "splice work queue", NULL, MTX_DEF);
}
/* Start kthreads for each workqueue. */
error = 0;
- CPU_FOREACH(i) {
+ for (i = 0; i < splice_num_wq; i++) {
error = kproc_kthread_add(splice_work_thread, &splice_wq[i],
&splice_proc, &td, 0, 0, "so_splice", "thr_%d", i);
if (error) {
@@ -1631,10 +1649,7 @@
sp->src = NULL;
sp->dst = NULL;
sp->max = max > 0 ? max : -1;
- do {
- sp->wq_index = atomic_fetchadd_32(&splice_index, 1) %
- (mp_maxid + 1);
- } while (CPU_ABSENT(sp->wq_index));
+ sp->wq_index = atomic_fetchadd_32(&splice_index, 1) % splice_num_wq;
sp->state = SPLICE_INIT;
TIMEOUT_TASK_INIT(taskqueue_thread, &sp->timeout, 0, so_splice_timeout,
sp);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 5, 8:58 AM (6 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36025126
Default Alt Text
D55579.id172906.diff (2 KB)
Attached To
Mode
D55579: splice: optionally limit worker queues
Attached
Detach File
Event Timeline
Log In to Comment