The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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>.
    6  *  UCRL-CODE-235197
    7  *
    8  *  This file is part of the SPL, Solaris Porting Layer.
    9  *
   10  *  The SPL is free software; you can redistribute it and/or modify it
   11  *  under the terms of the GNU General Public License as published by the
   12  *  Free Software Foundation; either version 2 of the License, or (at your
   13  *  option) any later version.
   14  *
   15  *  The SPL is distributed in the hope that it will be useful, but WITHOUT
   16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18  *  for more details.
   19  *
   20  *  You should have received a copy of the GNU General Public License along
   21  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
   22  */
   23 
   24 #ifndef _SPL_TASKQ_H
   25 #define _SPL_TASKQ_H
   26 
   27 #include <linux/module.h>
   28 #include <linux/gfp.h>
   29 #include <linux/slab.h>
   30 #include <linux/interrupt.h>
   31 #include <linux/kthread.h>
   32 #include <sys/types.h>
   33 #include <sys/thread.h>
   34 #include <sys/rwlock.h>
   35 #include <sys/wait.h>
   36 
   37 #define TASKQ_NAMELEN           31
   38 
   39 #define TASKQ_PREPOPULATE       0x00000001
   40 #define TASKQ_CPR_SAFE          0x00000002
   41 #define TASKQ_DYNAMIC           0x00000004
   42 #define TASKQ_THREADS_CPU_PCT   0x00000008
   43 #define TASKQ_DC_BATCH          0x00000010
   44 #define TASKQ_ACTIVE            0x80000000
   45 
   46 /*
   47  * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
   48  * KM_SLEEP/KM_NOSLEEP.  TQ_NOQUEUE/TQ_NOALLOC are set particularly
   49  * large so as not to conflict with already used GFP_* defines.
   50  */
   51 #define TQ_SLEEP                0x00000000
   52 #define TQ_NOSLEEP              0x00000001
   53 #define TQ_PUSHPAGE             0x00000002
   54 #define TQ_NOQUEUE              0x01000000
   55 #define TQ_NOALLOC              0x02000000
   56 #define TQ_NEW                  0x04000000
   57 #define TQ_FRONT                0x08000000
   58 
   59 /*
   60  * Reserved taskqid values.
   61  */
   62 #define TASKQID_INVALID         ((taskqid_t)0)
   63 #define TASKQID_INITIAL         ((taskqid_t)1)
   64 
   65 /*
   66  * spin_lock(lock) and spin_lock_nested(lock,0) are equivalent,
   67  * so TQ_LOCK_DYNAMIC must not evaluate to 0
   68  */
   69 typedef enum tq_lock_role {
   70         TQ_LOCK_GENERAL =       0,
   71         TQ_LOCK_DYNAMIC =       1,
   72 } tq_lock_role_t;
   73 
   74 typedef unsigned long taskqid_t;
   75 typedef void (task_func_t)(void *);
   76 
   77 typedef struct taskq {
   78         spinlock_t              tq_lock;        /* protects taskq_t */
   79         char                    *tq_name;       /* taskq name */
   80         int                     tq_instance;    /* instance of tq_name */
   81         struct list_head        tq_thread_list; /* list of all threads */
   82         struct list_head        tq_active_list; /* list of active threads */
   83         int                     tq_nactive;     /* # of active threads */
   84         int                     tq_nthreads;    /* # of existing threads */
   85         int                     tq_nspawn;      /* # of threads being spawned */
   86         int                     tq_maxthreads;  /* # of threads maximum */
   87         /* If PERCPU flag is set, percent of NCPUs to have as threads */
   88         int                     tq_cpu_pct;
   89         int                     tq_pri;         /* priority */
   90         int                     tq_minalloc;    /* min taskq_ent_t pool size */
   91         int                     tq_maxalloc;    /* max taskq_ent_t pool size */
   92         int                     tq_nalloc;      /* cur taskq_ent_t pool size */
   93         uint_t                  tq_flags;       /* flags */
   94         taskqid_t               tq_next_id;     /* next pend/work id */
   95         taskqid_t               tq_lowest_id;   /* lowest pend/work id */
   96         struct list_head        tq_free_list;   /* free taskq_ent_t's */
   97         struct list_head        tq_pend_list;   /* pending taskq_ent_t's */
   98         struct list_head        tq_prio_list;   /* priority taskq_ent_t's */
   99         struct list_head        tq_delay_list;  /* delayed taskq_ent_t's */
  100         struct list_head        tq_taskqs;      /* all taskq_t's */
  101         spl_wait_queue_head_t   tq_work_waitq;  /* new work waitq */
  102         spl_wait_queue_head_t   tq_wait_waitq;  /* wait waitq */
  103         tq_lock_role_t          tq_lock_class;  /* class when taking tq_lock */
  104         /* list node for the cpu hotplug callback */
  105         struct hlist_node       tq_hp_cb_node;
  106         boolean_t               tq_hp_support;
  107 } taskq_t;
  108 
  109 typedef struct taskq_ent {
  110         spinlock_t              tqent_lock;
  111         spl_wait_queue_head_t   tqent_waitq;
  112         struct timer_list       tqent_timer;
  113         struct list_head        tqent_list;
  114         taskqid_t               tqent_id;
  115         task_func_t             *tqent_func;
  116         void                    *tqent_arg;
  117         taskq_t                 *tqent_taskq;
  118         uintptr_t               tqent_flags;
  119         unsigned long           tqent_birth;
  120 } taskq_ent_t;
  121 
  122 #define TQENT_FLAG_PREALLOC     0x1
  123 #define TQENT_FLAG_CANCEL       0x2
  124 
  125 typedef struct taskq_thread {
  126         struct list_head        tqt_thread_list;
  127         struct list_head        tqt_active_list;
  128         struct task_struct      *tqt_thread;
  129         taskq_t                 *tqt_tq;
  130         taskqid_t               tqt_id;
  131         taskq_ent_t             *tqt_task;
  132         uintptr_t               tqt_flags;
  133 } taskq_thread_t;
  134 
  135 /* Global system-wide dynamic task queue available for all consumers */
  136 extern taskq_t *system_taskq;
  137 /* Global dynamic task queue for long delay */
  138 extern taskq_t *system_delay_taskq;
  139 
  140 /* List of all taskqs */
  141 extern struct list_head tq_list;
  142 extern struct rw_semaphore tq_list_sem;
  143 
  144 extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
  145 extern taskqid_t taskq_dispatch_delay(taskq_t *, task_func_t, void *,
  146     uint_t, clock_t);
  147 extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
  148     taskq_ent_t *);
  149 extern int taskq_empty_ent(taskq_ent_t *);
  150 extern void taskq_init_ent(taskq_ent_t *);
  151 extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
  152 extern void taskq_destroy(taskq_t *);
  153 extern void taskq_wait_id(taskq_t *, taskqid_t);
  154 extern void taskq_wait_outstanding(taskq_t *, taskqid_t);
  155 extern void taskq_wait(taskq_t *);
  156 extern int taskq_cancel_id(taskq_t *, taskqid_t);
  157 extern int taskq_member(taskq_t *, kthread_t *);
  158 extern taskq_t *taskq_of_curthread(void);
  159 
  160 #define taskq_create_proc(name, nthreads, pri, min, max, proc, flags) \
  161     taskq_create(name, nthreads, pri, min, max, flags)
  162 #define taskq_create_sysdc(name, nthreads, min, max, proc, dc, flags) \
  163         ((void) sizeof (dc), \
  164             taskq_create(name, nthreads, maxclsyspri, min, max, flags))
  165 
  166 int spl_taskq_init(void);
  167 void spl_taskq_fini(void);
  168 
  169 #endif  /* _SPL_TASKQ_H */

Cache object: f2cae791e2283f02bb868327e55b95a2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.