Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jan 2014 14:35:21 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r260744 - in stable/8/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/uts/common/fs/zfs contrib/opensolaris/uts/common/fs/zfs/sys contrib/opensolaris/uts/co...
Message-ID:  <201401161435.s0GEZLZO036787@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Jan 16 14:35:20 2014
New Revision: 260744
URL: http://svnweb.freebsd.org/changeset/base/260744

Log:
  MFC r258630: 734 taskq_dispatch_prealloc() desired

Deleted:
  stable/8/sys/cddl/compat/opensolaris/sys/taskq.h
Modified:
  stable/8/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
  stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/taskq.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/cddl/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/8/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
==============================================================================
--- stable/8/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c	Thu Jan 16 14:35:06 2014	(r260743)
+++ stable/8/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c	Thu Jan 16 14:35:20 2014	(r260744)
@@ -46,7 +46,7 @@ static void
 system_taskq_init(void *arg)
 {
 
-	taskq_zone = uma_zcreate("taskq_zone", sizeof(struct ostask),
+	taskq_zone = uma_zcreate("taskq_zone", sizeof(taskq_ent_t),
 	    NULL, NULL, NULL, NULL, 0, 0);
 	system_taskq = taskq_create("system_taskq", mp_ncpus, 0, 0, 0, 0);
 }
@@ -104,9 +104,9 @@ taskq_member(taskq_t *tq, kthread_t *thr
 static void
 taskq_run(void *arg, int pending __unused)
 {
-	struct ostask *task = arg;
+	taskq_ent_t *task = arg;
 
-	task->ost_func(task->ost_arg);
+	task->tqent_func(task->tqent_arg);
 
 	uma_zfree(taskq_zone, task);
 }
@@ -114,7 +114,7 @@ taskq_run(void *arg, int pending __unuse
 taskqid_t
 taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags)
 {
-	struct ostask *task;
+	taskq_ent_t *task;
 	int mflag, prio;
 
 	if ((flags & (TQ_SLEEP | TQ_NOQUEUE)) == TQ_SLEEP)
@@ -131,26 +131,26 @@ taskq_dispatch(taskq_t *tq, task_func_t 
 	if (task == NULL)
 		return (0);
 
-	task->ost_func = func;
-	task->ost_arg = arg;
+	task->tqent_func = func;
+	task->tqent_arg = arg;
 
-	TASK_INIT(&task->ost_task, prio, taskq_run, task);
-	taskqueue_enqueue(tq->tq_queue, &task->ost_task);
+	TASK_INIT(&task->tqent_task, prio, taskq_run, task);
+	taskqueue_enqueue(tq->tq_queue, &task->tqent_task);
 
 	return ((taskqid_t)(void *)task);
 }
 
 static void
-taskq_run_safe(void *arg, int pending __unused)
+taskq_run_ent(void *arg, int pending __unused)
 {
-	struct ostask *task = arg;
+	taskq_ent_t *task = arg;
 
-	task->ost_func(task->ost_arg);
+	task->tqent_func(task->tqent_arg);
 }
 
-taskqid_t
-taskq_dispatch_safe(taskq_t *tq, task_func_t func, void *arg, u_int flags,
-    struct ostask *task)
+void
+taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, u_int flags,
+    taskq_ent_t *task)
 {
 	int prio;
 
@@ -160,11 +160,9 @@ taskq_dispatch_safe(taskq_t *tq, task_fu
 	 */
 	prio = !!(flags & TQ_FRONT);
 
-	task->ost_func = func;
-	task->ost_arg = arg;
+	task->tqent_func = func;
+	task->tqent_arg = arg;
 
-	TASK_INIT(&task->ost_task, prio, taskq_run_safe, task);
-	taskqueue_enqueue(tq->tq_queue, &task->ost_task);
-
-	return ((taskqid_t)(void *)task);
+	TASK_INIT(&task->tqent_task, prio, taskq_run_ent, task);
+	taskqueue_enqueue(tq->tq_queue, &task->tqent_task);
 }

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Jan 16 14:35:06 2014	(r260743)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Jan 16 14:35:20 2014	(r260744)
@@ -823,7 +823,7 @@ static taskq_t *
 spa_taskq_create(spa_t *spa, const char *name, enum zti_modes mode,
     uint_t value)
 {
-	uint_t flags = TASKQ_PREPOPULATE;
+	uint_t flags = 0;
 	boolean_t batch = B_FALSE;
 
 	switch (mode) {

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
==============================================================================
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h	Thu Jan 16 14:35:06 2014	(r260743)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h	Thu Jan 16 14:35:20 2014	(r260744)
@@ -23,6 +23,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012 by Delphix. All rights reserved.
  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _ZIO_H
@@ -472,10 +473,9 @@ struct zio {
 	zio_cksum_report_t *io_cksum_report;
 	uint64_t	io_ena;
 
-#ifdef _KERNEL
-	/* FreeBSD only. */
-	struct ostask	io_task;
-#endif
+	/* Taskq dispatching state */
+	taskq_ent_t	io_tqent;
+
 	avl_node_t	io_trim_node;
 	list_node_t	io_trim_link;
 };

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==============================================================================
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Thu Jan 16 14:35:06 2014	(r260743)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c	Thu Jan 16 14:35:20 2014	(r260744)
@@ -21,6 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -1183,7 +1184,7 @@ zio_taskq_dispatch(zio_t *zio, enum zio_
 {
 	spa_t *spa = zio->io_spa;
 	zio_type_t t = zio->io_type;
-	int flags = TQ_SLEEP | (cutinline ? TQ_FRONT : 0);
+	int flags = (cutinline ? TQ_FRONT : 0);
 
 	ASSERT(q == ZIO_TASKQ_ISSUE || q == ZIO_TASKQ_INTERRUPT);
 
@@ -1209,13 +1210,19 @@ zio_taskq_dispatch(zio_t *zio, enum zio_
 		q++;
 
 	ASSERT3U(q, <, ZIO_TASKQ_TYPES);
-#ifdef _KERNEL
-	(void) taskq_dispatch_safe(spa->spa_zio_taskq[t][q],
-	    (task_func_t *)zio_execute, zio, flags, &zio->io_task);
+
+	/*
+	 * NB: We are assuming that the zio can only be dispatched
+	 * to a single taskq at a time.  It would be a grievous error
+	 * to dispatch the zio to another taskq at the same time.
+	 */
+#if defined(illumos) || !defined(_KERNEL)
+	ASSERT(zio->io_tqent.tqent_next == NULL);
 #else
-	(void) taskq_dispatch(spa->spa_zio_taskq[t][q],
-	    (task_func_t *)zio_execute, zio, flags);
+	ASSERT(zio->io_tqent.tqent_task.ta_pending == 0);
 #endif
+	taskq_dispatch_ent(spa->spa_zio_taskq[t][q],
+	    (task_func_t *)zio_execute, zio, flags, &zio->io_tqent);
 }
 
 static boolean_t
@@ -3133,16 +3140,15 @@ zio_done(zio_t *zio)
 			 * Reexecution is potentially a huge amount of work.
 			 * Hand it off to the otherwise-unused claim taskq.
 			 */
-#ifdef _KERNEL
-			(void) taskq_dispatch_safe(
-			    spa->spa_zio_taskq[ZIO_TYPE_CLAIM][ZIO_TASKQ_ISSUE],
-			    (task_func_t *)zio_reexecute, zio, TQ_SLEEP,
-			    &zio->io_task);
+#if defined(illumos) || !defined(_KERNEL)
+			ASSERT(zio->io_tqent.tqent_next == NULL);
 #else
-			(void) taskq_dispatch(
-			    spa->spa_zio_taskq[ZIO_TYPE_CLAIM][ZIO_TASKQ_ISSUE],
-			    (task_func_t *)zio_reexecute, zio, TQ_SLEEP);
+			ASSERT(zio->io_tqent.tqent_task.ta_pending == 0);
 #endif
+			(void) taskq_dispatch_ent(
+			    spa->spa_zio_taskq[ZIO_TYPE_CLAIM][ZIO_TASKQ_ISSUE],
+			    (task_func_t *)zio_reexecute, zio, 0,
+			    &zio->io_tqent);
 		}
 		return (ZIO_PIPELINE_STOP);
 	}

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/taskq.h
==============================================================================
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/taskq.h	Thu Jan 16 14:35:06 2014	(r260743)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/sys/taskq.h	Thu Jan 16 14:35:20 2014	(r260744)
@@ -45,6 +45,12 @@ typedef struct taskq taskq_t;
 typedef uintptr_t taskqid_t;
 typedef void (task_func_t)(void *);
 
+typedef struct taskq_ent {
+	struct task	 tqent_task;
+	task_func_t	*tqent_func;
+	void		*tqent_arg;
+} taskq_ent_t;
+
 struct proc;
 
 /*
@@ -80,6 +86,8 @@ taskq_t	*taskq_create_proc(const char *,
 taskq_t	*taskq_create_sysdc(const char *, int, int, int,
     struct proc *, uint_t, uint_t);
 taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
+void	taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
+    taskq_ent_t *);
 void	nulltask(void *);
 void	taskq_destroy(taskq_t *);
 void	taskq_wait(taskq_t *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401161435.s0GEZLZO036787>