From owner-svn-src-head@FreeBSD.ORG Tue Feb 17 02:35:07 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6FF8666A; Tue, 17 Feb 2015 02:35:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5AD5D8C0; Tue, 17 Feb 2015 02:35:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H2Z7cP005700; Tue, 17 Feb 2015 02:35:07 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H2Z6eC005697; Tue, 17 Feb 2015 02:35:06 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201502170235.t1H2Z6eC005697@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 17 Feb 2015 02:35:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278879 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 02:35:07 -0000 Author: adrian Date: Tue Feb 17 02:35:06 2015 New Revision: 278879 URL: https://svnweb.freebsd.org/changeset/base/278879 Log: Implement taskqueue_start_threads_cpuset(). This is a more generic version of taskqueue_start_threads_pinned() which only supports a single cpuid. This originally came from John Baldwin who implemented it as part of a push towards NUMA awareness in drivers. I started implementing something similar for RSS and NUMA, then found he already did it. I'd like to axe taskqueue_start_threads_pinned() so it doesn't become part of a longer-term API. (Read: hps@ wants to MFC things, and if I don't do this soon, he'll MFC what's here. :-) I have a follow-up commit which converts the intel drivers over to using the cpuset version of this function, so we can eventually nuke the the pinned version. Tested: * igb, ixgbe Obtained from: jhbbsd 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 Tue Feb 17 01:45:38 2015 (r278878) +++ head/sys/kern/subr_taskqueue.c Tue Feb 17 02:35:06 2015 (r278879) @@ -571,8 +571,9 @@ taskqueue_swi_giant_run(void *dummy) static int _taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, - cpuset_t *mask, const char *ktname) + cpuset_t *mask, const char *name, va_list ap) { + char ktname[MAXCOMLEN + 1]; struct thread *td; struct taskqueue *tq; int i, error; @@ -580,6 +581,7 @@ _taskqueue_start_threads(struct taskqueu if (count <= 0) return (EINVAL); + vsnprintf(ktname, sizeof(ktname), name, ap); tq = *tqp; tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE, @@ -635,27 +637,35 @@ int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, const char *name, ...) { - char ktname[MAXCOMLEN + 1]; va_list ap; + int error; va_start(ap, name); - vsnprintf(ktname, sizeof(ktname), name, ap); + error = _taskqueue_start_threads(tqp, count, pri, NULL, name, ap); va_end(ap); - - return (_taskqueue_start_threads(tqp, count, pri, NULL, ktname)); + return (error); } int -taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri, - int cpu_id, const char *name, ...) +taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri, + cpuset_t *mask, const char *name, ...) { - char ktname[MAXCOMLEN + 1]; va_list ap; - cpuset_t mask; + int error; va_start(ap, name); - vsnprintf(ktname, sizeof(ktname), name, ap); + error = _taskqueue_start_threads(tqp, count, pri, mask, name, ap); va_end(ap); + return (error); +} + +int +taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri, + int cpu_id, const char *name, ...) +{ + cpuset_t mask; + va_list ap; + int error; /* * In case someone passes in NOCPU, just fall back to the @@ -666,8 +676,11 @@ taskqueue_start_threads_pinned(struct ta CPU_SET(cpu_id, &mask); } - return (_taskqueue_start_threads(tqp, count, pri, - cpu_id == NOCPU ? NULL : &mask, ktname)); + va_start(ap, name); + error = _taskqueue_start_threads(tqp, count, pri, + cpu_id == NOCPU ? NULL : &mask, name, ap); + va_end(ap); + return (error); } static inline void Modified: head/sys/sys/taskqueue.h ============================================================================== --- head/sys/sys/taskqueue.h Tue Feb 17 01:45:38 2015 (r278878) +++ head/sys/sys/taskqueue.h Tue Feb 17 02:35:06 2015 (r278879) @@ -36,6 +36,7 @@ #include #include #include +#include struct taskqueue; struct thread; @@ -71,6 +72,8 @@ struct taskqueue *taskqueue_create(const void *context); int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, const char *name, ...) __printflike(4, 5); +int taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, + int pri, cpuset_t *mask, const char *name, ...) __printflike(5, 6); int taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri, int cpu_id, const char *name, ...) __printflike(5, 6);