summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_usrreq.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-11-20 15:45:48 +0000
committerkib <kib@FreeBSD.org>2012-11-20 15:45:48 +0000
commit6d46d7b7ab07b512013ff0bcd075462a461ac124 (patch)
treeb24cae06a4562ff22b2b4e8f97209cb2d95759eb /sys/kern/uipc_usrreq.c
parentf0eb44bc70263f6f188d8f07d367628d2efb6716 (diff)
downloadFreeBSD-src-6d46d7b7ab07b512013ff0bcd075462a461ac124.zip
FreeBSD-src-6d46d7b7ab07b512013ff0bcd075462a461ac124.tar.gz
Schedule garbage collection run for the in-flight rights passed over
the unix domain sockets to the next tick, coalescing the serial calls until the collection fires. The thought is that more work for the collector could arise in the near time, allowing to clean more and not spend too much CPU on repeated collection when there is no garbage. Currently the collection task is fired immediately upon unix domain socket close if there are any rights in flight, which caused excessive CPU usage and too long blocking of the threads waiting for unp_list_lock and unp_link_rwlock in write mode. Robert noted that it would be nice if we could find some heuristic by which we decide whether to run GC a bit more quickly. E.g., if the number of UNIX domain sockets is close to its resource limit, but not quite. Reported and tested by: Markus Gebert <markus.gebert@hostpoint.ch> Reviewed by: rwatson MFC after: 2 weeks
Diffstat (limited to 'sys/kern/uipc_usrreq.c')
-rw-r--r--sys/kern/uipc_usrreq.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 99bca99..c60b177 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -131,7 +131,7 @@ static const struct sockaddr sun_noname = { sizeof(sun_noname), AF_LOCAL };
* reentrance in the UNIX domain socket, file descriptor, and socket layer
* code. See unp_gc() for a full description.
*/
-static struct task unp_gc_task;
+static struct timeout_task unp_gc_task;
/*
* The close of unix domain sockets attached as SCM_RIGHTS is
@@ -672,7 +672,7 @@ uipc_detach(struct socket *so)
if (vp)
vrele(vp);
if (local_unp_rights)
- taskqueue_enqueue(taskqueue_thread, &unp_gc_task);
+ taskqueue_enqueue_timeout(taskqueue_thread, &unp_gc_task, -1);
}
static int
@@ -1784,7 +1784,7 @@ unp_init(void)
LIST_INIT(&unp_shead);
LIST_INIT(&unp_sphead);
SLIST_INIT(&unp_defers);
- TASK_INIT(&unp_gc_task, 0, unp_gc, NULL);
+ TIMEOUT_TASK_INIT(taskqueue_thread, &unp_gc_task, 0, unp_gc, NULL);
TASK_INIT(&unp_defer_task, 0, unp_process_defers, NULL);
UNP_LINK_LOCK_INIT();
UNP_LIST_LOCK_INIT();
OpenPOWER on IntegriCloud