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