From owner-svn-src-all@freebsd.org Thu Oct 17 06:32:35 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE16316FD13; Thu, 17 Oct 2019 06:32:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46tzqR3pf7z3Mwm; Thu, 17 Oct 2019 06:32:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6761A1C933; Thu, 17 Oct 2019 06:32:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9H6WZHP038905; Thu, 17 Oct 2019 06:32:35 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9H6WZUv038903; Thu, 17 Oct 2019 06:32:35 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910170632.x9H6WZUv038903@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 17 Oct 2019 06:32:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353678 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 353678 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Oct 2019 06:32:35 -0000 Author: avg Date: Thu Oct 17 06:32:34 2019 New Revision: 353678 URL: https://svnweb.freebsd.org/changeset/base/353678 Log: provide a way to assign taskqueue threads to a kernel process This can be used to group all threads belonging to a single logical entity under a common kernel process. I am planning to use the new interface for ZFS threads. MFC after: 4 weeks Modified: head/sys/kern/subr_taskqueue.c head/sys/sys/taskqueue.h Modified: head/sys/kern/subr_taskqueue.c ============================================================================== --- head/sys/kern/subr_taskqueue.c Thu Oct 17 06:21:09 2019 (r353677) +++ head/sys/kern/subr_taskqueue.c Thu Oct 17 06:32:34 2019 (r353678) @@ -654,7 +654,7 @@ taskqueue_swi_giant_run(void *dummy) static int _taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, - cpuset_t *mask, const char *name, va_list ap) + cpuset_t *mask, struct proc *p, const char *name, va_list ap) { char ktname[MAXCOMLEN + 1]; struct thread *td; @@ -676,10 +676,10 @@ _taskqueue_start_threads(struct taskqueue **tqp, int c for (i = 0; i < count; i++) { if (count == 1) - error = kthread_add(taskqueue_thread_loop, tqp, NULL, + error = kthread_add(taskqueue_thread_loop, tqp, p, &tq->tq_threads[i], RFSTOPPED, 0, "%s", ktname); else - error = kthread_add(taskqueue_thread_loop, tqp, NULL, + error = kthread_add(taskqueue_thread_loop, tqp, p, &tq->tq_threads[i], RFSTOPPED, 0, "%s_%d", ktname, i); if (error) { @@ -729,12 +729,25 @@ taskqueue_start_threads(struct taskqueue **tqp, int co int error; va_start(ap, name); - error = _taskqueue_start_threads(tqp, count, pri, NULL, name, ap); + error = _taskqueue_start_threads(tqp, count, pri, NULL, NULL, name, ap); va_end(ap); return (error); } int +taskqueue_start_threads_in_proc(struct taskqueue **tqp, int count, int pri, + struct proc *proc, const char *name, ...) +{ + va_list ap; + int error; + + va_start(ap, name); + error = _taskqueue_start_threads(tqp, count, pri, NULL, proc, name, ap); + va_end(ap); + return (error); +} + +int taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri, cpuset_t *mask, const char *name, ...) { @@ -742,7 +755,7 @@ taskqueue_start_threads_cpuset(struct taskqueue **tqp, int error; va_start(ap, name); - error = _taskqueue_start_threads(tqp, count, pri, mask, name, ap); + error = _taskqueue_start_threads(tqp, count, pri, mask, NULL, name, ap); va_end(ap); return (error); } Modified: head/sys/sys/taskqueue.h ============================================================================== --- head/sys/sys/taskqueue.h Thu Oct 17 06:21:09 2019 (r353677) +++ head/sys/sys/taskqueue.h Thu Oct 17 06:32:34 2019 (r353678) @@ -42,6 +42,7 @@ struct taskqueue; struct taskqgroup; +struct proc; struct thread; struct timeout_task { @@ -75,7 +76,9 @@ struct taskqueue *taskqueue_create(const char *name, i taskqueue_enqueue_fn enqueue, void *context); int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, - const char *name, ...) __printflike(4, 5); + const char *name, ...) __printflike(4, 5); +int taskqueue_start_threads_in_proc(struct taskqueue **tqp, int count, + int pri, struct proc *p, const char *name, ...) __printflike(5, 6); int taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri, cpuset_t *mask, const char *name, ...) __printflike(5, 6); int taskqueue_enqueue(struct taskqueue *queue, struct task *task);