]>
Commit | Line | Data |
---|---|---|
715f6251 BB |
1 | /* |
2 | * This file is part of the SPL: Solaris Porting Layer. | |
3 | * | |
4 | * Copyright (c) 2008 Lawrence Livermore National Security, LLC. | |
5 | * Produced at Lawrence Livermore National Laboratory | |
6 | * Written by: | |
7 | * Brian Behlendorf <behlendorf1@llnl.gov>, | |
8 | * Herb Wartens <wartens2@llnl.gov>, | |
9 | * Jim Garlick <garlick@llnl.gov> | |
10 | * UCRL-CODE-235197 | |
11 | * | |
12 | * This is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
25 | */ | |
26 | ||
09b414e8 BB |
27 | #ifndef _SPL_TASKQ_H |
28 | #define _SPL_TASKQ_H | |
f1ca4da6 BB |
29 | |
30 | #ifdef __cplusplus | |
31 | extern "C" { | |
32 | #endif | |
33 | ||
f1b59d26 | 34 | #include <linux/module.h> |
f1ca4da6 BB |
35 | #include <linux/gfp.h> |
36 | #include <linux/slab.h> | |
37 | #include <linux/interrupt.h> | |
bcd68186 | 38 | #include <linux/kthread.h> |
f4b37741 | 39 | #include <sys/types.h> |
925ca8cc | 40 | #include <sys/thread.h> |
f1ca4da6 | 41 | |
bcd68186 | 42 | #define TASKQ_NAMELEN 31 |
f1ca4da6 | 43 | |
bcd68186 BB |
44 | #define TASKQ_PREPOPULATE 0x00000001 |
45 | #define TASKQ_CPR_SAFE 0x00000002 | |
46 | #define TASKQ_DYNAMIC 0x00000004 | |
915404bd | 47 | #define TASKQ_THREADS_CPU_PCT 0x00000008 |
f1ca4da6 | 48 | |
f1ca4da6 | 49 | typedef unsigned long taskqid_t; |
bcd68186 | 50 | typedef void (task_func_t)(void *); |
f1ca4da6 BB |
51 | |
52 | /* | |
53 | * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as | |
bcd68186 BB |
54 | * KM_SLEEP/KM_NOSLEEP. TQ_NOQUEUE/TQ_NOALLOC are set particularly |
55 | * large so as not to conflict with already used GFP_* defines. | |
f1ca4da6 | 56 | */ |
bcd68186 BB |
57 | #define TQ_SLEEP KM_SLEEP |
58 | #define TQ_NOSLEEP KM_NOSLEEP | |
59 | #define TQ_NOQUEUE 0x01000000 | |
60 | #define TQ_NOALLOC 0x02000000 | |
61 | #define TQ_NEW 0x04000000 | |
62 | #define TQ_ACTIVE 0x80000000 | |
63 | ||
bcd68186 BB |
64 | typedef struct taskq { |
65 | spinlock_t tq_lock; /* protects taskq_t */ | |
749045bb | 66 | unsigned long tq_lock_flags; /* interrupt state */ |
bcd68186 BB |
67 | struct task_struct **tq_threads; /* thread pointers */ |
68 | const char *tq_name; /* taskq name */ | |
69 | int tq_nactive; /* # of active threads */ | |
70 | int tq_nthreads; /* # of total threads */ | |
71 | int tq_pri; /* priority */ | |
72 | int tq_minalloc; /* min task_t pool size */ | |
73 | int tq_maxalloc; /* max task_t pool size */ | |
74 | int tq_nalloc; /* cur task_t pool size */ | |
75 | uint_t tq_flags; /* flags */ | |
76 | taskqid_t tq_next_id; /* next pend/work id */ | |
77 | taskqid_t tq_lowest_id; /* lowest pend/work id */ | |
78 | struct list_head tq_free_list; /* free task_t's */ | |
79 | struct list_head tq_work_list; /* work task_t's */ | |
80 | struct list_head tq_pend_list; /* pending task_t's */ | |
81 | wait_queue_head_t tq_work_waitq; /* new work waitq */ | |
82 | wait_queue_head_t tq_wait_waitq; /* wait waitq */ | |
83 | } taskq_t; | |
f1ca4da6 | 84 | |
e9cb2b4f BB |
85 | /* Global system-wide dynamic task queue available for all consumers */ |
86 | extern taskq_t *system_taskq; | |
87 | ||
f1ca4da6 BB |
88 | extern taskqid_t __taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); |
89 | extern taskq_t *__taskq_create(const char *, int, pri_t, int, int, uint_t); | |
b123971f | 90 | extern void __taskq_destroy(taskq_t *); |
7257ec41 | 91 | extern void __taskq_wait_id(taskq_t *, taskqid_t); |
b123971f | 92 | extern void __taskq_wait(taskq_t *); |
bcd68186 BB |
93 | extern int __taskq_member(taskq_t *, void *); |
94 | ||
e9cb2b4f BB |
95 | int spl_taskq_init(void); |
96 | void spl_taskq_fini(void); | |
97 | ||
bcd68186 BB |
98 | #define taskq_member(tq, t) __taskq_member(tq, t) |
99 | #define taskq_wait_id(tq, id) __taskq_wait_id(tq, id) | |
100 | #define taskq_wait(tq) __taskq_wait(tq) | |
101 | #define taskq_dispatch(tq, f, p, fl) __taskq_dispatch(tq, f, p, fl) | |
102 | #define taskq_create(n, th, p, mi, ma, fl) __taskq_create(n, th, p, mi, ma, fl) | |
103 | #define taskq_destroy(tq) __taskq_destroy(tq) | |
f1ca4da6 BB |
104 | |
105 | #ifdef __cplusplus | |
106 | } | |
107 | #endif | |
108 | ||
09b414e8 | 109 | #endif /* _SPL_TASKQ_H */ |