Print this page
8115 parallel zfs mount
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/taskq_impl.h
+++ new/usr/src/uts/common/sys/taskq_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25 /*
26 26 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27 27 * Copyright (c) 2017 by Delphix. All rights reserved.
28 + * Copyright 2017 RackTop Systems.
28 29 */
29 30
30 31 #ifndef _SYS_TASKQ_IMPL_H
31 32 #define _SYS_TASKQ_IMPL_H
32 33
33 34 #include <sys/taskq.h>
34 35 #include <sys/inttypes.h>
35 36 #include <sys/vmem.h>
36 37 #include <sys/list.h>
37 38 #include <sys/kstat.h>
39 +#include <sys/rwlock.h>
38 40
39 41 #ifdef __cplusplus
40 42 extern "C" {
41 43 #endif
42 44
43 45 typedef struct taskq_bucket taskq_bucket_t;
44 46
45 47 typedef struct taskq_ent {
46 48 struct taskq_ent *tqent_next;
47 49 struct taskq_ent *tqent_prev;
48 50 task_func_t *tqent_func;
49 51 void *tqent_arg;
50 52 union {
51 53 taskq_bucket_t *tqent_bucket;
52 54 uintptr_t tqent_flags;
53 55 } tqent_un;
54 56 kthread_t *tqent_thread;
55 57 kcondvar_t tqent_cv;
56 58 } taskq_ent_t;
57 59
58 60 #define TQENT_FLAG_PREALLOC 0x1
59 61
60 62 /*
61 63 * Taskq Statistics fields are not protected by any locks.
62 64 */
63 65 typedef struct tqstat {
64 66 uint_t tqs_hits;
65 67 uint_t tqs_misses;
66 68 uint_t tqs_overflow; /* no threads to allocate */
67 69 uint_t tqs_tcreates; /* threads created */
68 70 uint_t tqs_tdeaths; /* threads died */
69 71 uint_t tqs_maxthreads; /* max # of alive threads */
70 72 uint_t tqs_disptcreates;
71 73 } tqstat_t;
72 74
73 75 /*
74 76 * Per-CPU hash bucket manages taskq_bent_t structures using freelist.
75 77 */
76 78 struct taskq_bucket {
77 79 kmutex_t tqbucket_lock;
78 80 taskq_t *tqbucket_taskq; /* Enclosing taskq */
79 81 taskq_ent_t tqbucket_freelist;
80 82 uint_t tqbucket_nalloc; /* # of allocated entries */
81 83 uint_t tqbucket_nfree; /* # of free entries */
82 84 kcondvar_t tqbucket_cv;
83 85 ushort_t tqbucket_flags;
84 86 hrtime_t tqbucket_totaltime;
85 87 tqstat_t tqbucket_stat;
86 88 };
87 89
88 90 /*
89 91 * Bucket flags.
90 92 */
91 93 #define TQBUCKET_CLOSE 0x01
92 94 #define TQBUCKET_SUSPEND 0x02
93 95
94 96 #define TASKQ_INTERFACE_FLAGS 0x0000ffff /* defined in <sys/taskq.h> */
95 97
96 98 /*
97 99 * taskq implementation flags: bit range 16-31
98 100 */
99 101 #define TASKQ_CHANGING 0x00010000 /* nthreads != target */
100 102 #define TASKQ_SUSPENDED 0x00020000 /* taskq is suspended */
101 103 #define TASKQ_NOINSTANCE 0x00040000 /* no instance number */
102 104 #define TASKQ_THREAD_CREATED 0x00080000 /* a thread has been created */
103 105 #define TASKQ_DUTY_CYCLE 0x00100000 /* using the SDC class */
104 106
105 107 struct taskq {
106 108 char tq_name[TASKQ_NAMELEN + 1];
107 109 kmutex_t tq_lock;
108 110 krwlock_t tq_threadlock;
109 111 kcondvar_t tq_dispatch_cv;
110 112 kcondvar_t tq_wait_cv;
111 113 kcondvar_t tq_exit_cv;
112 114 pri_t tq_pri; /* Scheduling priority */
113 115 uint_t tq_flags;
114 116 int tq_active;
115 117 int tq_nthreads;
116 118 int tq_nthreads_target;
117 119 int tq_nthreads_max;
118 120 int tq_threads_ncpus_pct;
119 121 int tq_nalloc;
120 122 int tq_minalloc;
121 123 int tq_maxalloc;
122 124 kcondvar_t tq_maxalloc_cv;
123 125 int tq_maxalloc_wait;
124 126 taskq_ent_t *tq_freelist;
125 127 taskq_ent_t tq_task;
126 128 int tq_maxsize;
127 129 taskq_bucket_t *tq_buckets; /* Per-cpu array of buckets */
128 130 int tq_instance;
129 131 uint_t tq_nbuckets; /* # of buckets (2^n) */
130 132 union {
131 133 kthread_t *_tq_thread;
132 134 kthread_t **_tq_threadlist;
133 135 } tq_thr;
134 136
135 137 list_node_t tq_cpupct_link; /* linkage for taskq_cpupct_list */
136 138 struct proc *tq_proc; /* process for taskq threads */
137 139 int tq_cpupart; /* cpupart id bound to */
138 140 uint_t tq_DC; /* duty cycle for SDC */
139 141
140 142 /*
141 143 * Statistics.
142 144 */
143 145 kstat_t *tq_kstat; /* Exported statistics */
144 146 hrtime_t tq_totaltime; /* Time spent processing tasks */
145 147 uint64_t tq_nomem; /* # of times there was no memory */
146 148 uint64_t tq_tasks; /* Total # of tasks posted */
147 149 uint64_t tq_executed; /* Total # of tasks executed */
148 150 int tq_maxtasks; /* Max number of tasks in the queue */
149 151 int tq_tcreates;
150 152 int tq_tdeaths;
151 153 };
152 154
153 155 /* Special form of taskq dispatch that uses preallocated entries. */
154 156 void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, taskq_ent_t *);
155 157
156 158
157 159 #define tq_thread tq_thr._tq_thread
158 160 #define tq_threadlist tq_thr._tq_threadlist
159 161
160 162 /* The MAX guarantees we have at least one thread */
161 163 #define TASKQ_THREADS_PCT(ncpus, pct) MAX(((ncpus) * (pct)) / 100, 1)
162 164
163 165 #ifdef __cplusplus
164 166 }
165 167 #endif
166 168
167 169 #endif /* _SYS_TASKQ_IMPL_H */
↓ open down ↓ |
120 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX