]> git.proxmox.com Git - mirror_spl.git/blame - include/sys/taskq.h
Swap taskq_ent_t with taskqid_t in taskq_thread_t
[mirror_spl.git] / include / sys / taskq.h
CommitLineData
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
5be4767a 42#define TASKQ_DC_BATCH 0x00000010
372c2572 43#define TASKQ_NORECLAIM 0x00000020
f1ca4da6 44
f1ca4da6 45typedef unsigned long taskqid_t;
bcd68186 46typedef void (task_func_t)(void *);
f1ca4da6 47
2c02b71b
PS
48typedef struct taskq_ent {
49 spinlock_t tqent_lock;
50 struct list_head tqent_list;
51 taskqid_t tqent_id;
52 task_func_t *tqent_func;
53 void *tqent_arg;
44217f7a 54 uintptr_t tqent_flags;
2c02b71b
PS
55} taskq_ent_t;
56
44217f7a
PS
57#define TQENT_FLAG_PREALLOC 0x1
58
f1ca4da6 59/*
60 * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
bcd68186 61 * KM_SLEEP/KM_NOSLEEP. TQ_NOQUEUE/TQ_NOALLOC are set particularly
62 * large so as not to conflict with already used GFP_* defines.
f1ca4da6 63 */
bcd68186 64#define TQ_SLEEP KM_SLEEP
65#define TQ_NOSLEEP KM_NOSLEEP
66#define TQ_NOQUEUE 0x01000000
67#define TQ_NOALLOC 0x02000000
68#define TQ_NEW 0x04000000
5be4767a 69#define TQ_FRONT 0x08000000
bcd68186 70#define TQ_ACTIVE 0x80000000
71
bcd68186 72typedef struct taskq {
73 spinlock_t tq_lock; /* protects taskq_t */
749045bb 74 unsigned long tq_lock_flags; /* interrupt state */
bcd68186 75 const char *tq_name; /* taskq name */
2c02b71b
PS
76 struct list_head tq_thread_list;/* list of all threads */
77 struct list_head tq_active_list;/* list of active threads */
bcd68186 78 int tq_nactive; /* # of active threads */
79 int tq_nthreads; /* # of total threads */
80 int tq_pri; /* priority */
81 int tq_minalloc; /* min task_t pool size */
82 int tq_maxalloc; /* max task_t pool size */
83 int tq_nalloc; /* cur task_t pool size */
84 uint_t tq_flags; /* flags */
85 taskqid_t tq_next_id; /* next pend/work id */
86 taskqid_t tq_lowest_id; /* lowest pend/work id */
87 struct list_head tq_free_list; /* free task_t's */
bcd68186 88 struct list_head tq_pend_list; /* pending task_t's */
f0d8bb26 89 struct list_head tq_prio_list; /* priority pending task_t's */
bcd68186 90 wait_queue_head_t tq_work_waitq; /* new work waitq */
91 wait_queue_head_t tq_wait_waitq; /* wait waitq */
92} taskq_t;
f1ca4da6 93
2c02b71b
PS
94typedef struct taskq_thread {
95 struct list_head tqt_thread_list;
96 struct list_head tqt_active_list;
97 struct task_struct *tqt_thread;
98 taskq_t *tqt_tq;
e7e5f78e 99 taskqid_t tqt_id;
2c02b71b
PS
100} taskq_thread_t;
101
e9cb2b4f
BB
102/* Global system-wide dynamic task queue available for all consumers */
103extern taskq_t *system_taskq;
104
f1ca4da6 105extern taskqid_t __taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
44217f7a
PS
106extern void __taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, taskq_ent_t *);
107extern int __taskq_empty_ent(taskq_ent_t *);
108extern void __taskq_init_ent(taskq_ent_t *);
f1ca4da6 109extern taskq_t *__taskq_create(const char *, int, pri_t, int, int, uint_t);
b123971f 110extern void __taskq_destroy(taskq_t *);
7257ec41 111extern void __taskq_wait_id(taskq_t *, taskqid_t);
b123971f 112extern void __taskq_wait(taskq_t *);
bcd68186 113extern int __taskq_member(taskq_t *, void *);
114
e9cb2b4f
BB
115int spl_taskq_init(void);
116void spl_taskq_fini(void);
117
bcd68186 118#define taskq_member(tq, t) __taskq_member(tq, t)
119#define taskq_wait_id(tq, id) __taskq_wait_id(tq, id)
120#define taskq_wait(tq) __taskq_wait(tq)
121#define taskq_dispatch(tq, f, p, fl) __taskq_dispatch(tq, f, p, fl)
44217f7a
PS
122#define taskq_dispatch_ent(tq, f, p, fl, t) __taskq_dispatch_ent(tq, f, p, fl, t)
123#define taskq_empty_ent(t) __taskq_empty_ent(t)
124#define taskq_init_ent(t) __taskq_init_ent(t)
bcd68186 125#define taskq_create(n, th, p, mi, ma, fl) __taskq_create(n, th, p, mi, ma, fl)
ae4c36ad
BB
126#define taskq_create_proc(n, th, p, mi, ma, pr, fl) \
127 __taskq_create(n, th, p, mi, ma, fl)
128#define taskq_create_sysdc(n, th, mi, ma, pr, dc, fl) \
129 __taskq_create(n, th, maxclsyspri, mi, ma, fl)
bcd68186 130#define taskq_destroy(tq) __taskq_destroy(tq)
f1ca4da6 131
09b414e8 132#endif /* _SPL_TASKQ_H */