usr/src/uts/common/sys/taskq_impl.h
changeset 13414 b42c1f0432b6
parent 11854 5351ddd19d45
equal deleted inserted replaced
13413:22409bb43a34 13414:b42c1f0432b6
    20  */
    20  */
    21 /*
    21 /*
    22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
    22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
    23  * Use is subject to license terms.
    23  * Use is subject to license terms.
    24  */
    24  */
       
    25 /*
       
    26  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       
    27  */
    25 
    28 
    26 #ifndef	_SYS_TASKQ_IMPL_H
    29 #ifndef	_SYS_TASKQ_IMPL_H
    27 #define	_SYS_TASKQ_IMPL_H
    30 #define	_SYS_TASKQ_IMPL_H
    28 
    31 
    29 #include <sys/taskq.h>
    32 #include <sys/taskq.h>
    41 typedef struct taskq_ent {
    44 typedef struct taskq_ent {
    42 	struct taskq_ent	*tqent_next;
    45 	struct taskq_ent	*tqent_next;
    43 	struct taskq_ent	*tqent_prev;
    46 	struct taskq_ent	*tqent_prev;
    44 	task_func_t		*tqent_func;
    47 	task_func_t		*tqent_func;
    45 	void			*tqent_arg;
    48 	void			*tqent_arg;
    46 	taskq_bucket_t		*tqent_bucket;
    49 	union {
       
    50 		taskq_bucket_t	*tqent_bucket;
       
    51 		uintptr_t	tqent_flags;
       
    52 	}			tqent_un;
    47 	kthread_t		*tqent_thread;
    53 	kthread_t		*tqent_thread;
    48 	kcondvar_t		tqent_cv;
    54 	kcondvar_t		tqent_cv;
    49 } taskq_ent_t;
    55 } taskq_ent_t;
       
    56 
       
    57 #define	TQENT_FLAG_PREALLOC	0x1
    50 
    58 
    51 /*
    59 /*
    52  * Taskq Statistics fields are not protected by any locks.
    60  * Taskq Statistics fields are not protected by any locks.
    53  */
    61  */
    54 typedef struct tqstat {
    62 typedef struct tqstat {
   139 	int		tq_maxtasks;	/* Max number of tasks in the queue */
   147 	int		tq_maxtasks;	/* Max number of tasks in the queue */
   140 	int		tq_tcreates;
   148 	int		tq_tcreates;
   141 	int		tq_tdeaths;
   149 	int		tq_tdeaths;
   142 };
   150 };
   143 
   151 
       
   152 /* Special form of taskq dispatch that uses preallocated entries. */
       
   153 void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, taskq_ent_t *);
       
   154 
       
   155 
   144 #define	tq_thread tq_thr._tq_thread
   156 #define	tq_thread tq_thr._tq_thread
   145 #define	tq_threadlist tq_thr._tq_threadlist
   157 #define	tq_threadlist tq_thr._tq_threadlist
   146 
   158 
   147 /* The MAX guarantees we have at least one thread */
   159 /* The MAX guarantees we have at least one thread */
   148 #define	TASKQ_THREADS_PCT(ncpus, pct)	MAX(((ncpus) * (pct)) / 100, 1)
   160 #define	TASKQ_THREADS_PCT(ncpus, pct)	MAX(((ncpus) * (pct)) / 100, 1)