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/sys/gtaskqueue.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  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2014 Jeffrey Roberson <jeff@freebsd.org>
    5  * Copyright (c) 2016 Matthew Macy <mmacy@mattmacy.io>
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/12.0/sys/sys/gtaskqueue.h 340202 2018-11-06 20:46:00Z shurd $
   30  */
   31 
   32 #ifndef _SYS_GTASKQUEUE_H_
   33 #define _SYS_GTASKQUEUE_H_
   34 #include <sys/taskqueue.h>
   35 
   36 #ifndef _KERNEL
   37 #error "no user-serviceable parts inside"
   38 #endif
   39 
   40 struct gtaskqueue;
   41 typedef void (*gtaskqueue_enqueue_fn)(void *context);
   42 
   43 /*
   44  * Taskqueue groups.  Manages dynamic thread groups and irq binding for
   45  * device and other tasks.
   46  */
   47 
   48 void    gtaskqueue_block(struct gtaskqueue *queue);
   49 void    gtaskqueue_unblock(struct gtaskqueue *queue);
   50 
   51 int     gtaskqueue_cancel(struct gtaskqueue *queue, struct gtask *gtask);
   52 void    gtaskqueue_drain(struct gtaskqueue *queue, struct gtask *task);
   53 void    gtaskqueue_drain_all(struct gtaskqueue *queue);
   54 
   55 void    grouptask_block(struct grouptask *grouptask);
   56 void    grouptask_unblock(struct grouptask *grouptask);
   57 int     grouptaskqueue_enqueue(struct gtaskqueue *queue, struct gtask *task);
   58 void    taskqgroup_attach(struct taskqgroup *qgroup, struct grouptask *grptask,
   59             void *uniq, int irq, const char *name);
   60 int             taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *grptask,
   61                 void *uniq, int cpu, int irq, const char *name);
   62 void    taskqgroup_detach(struct taskqgroup *qgroup, struct grouptask *gtask);
   63 struct taskqgroup *taskqgroup_create(const char *name);
   64 void    taskqgroup_destroy(struct taskqgroup *qgroup);
   65 int     taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride);
   66 void    taskqgroup_config_gtask_init(void *ctx, struct grouptask *gtask, gtask_fn_t *fn,
   67                 const char *name);
   68 void    taskqgroup_config_gtask_deinit(struct grouptask *gtask);
   69 
   70 #define TASK_ENQUEUED                   0x1
   71 #define TASK_SKIP_WAKEUP                0x2
   72 #define TASK_NOENQUEUE                  0x4
   73 
   74 
   75 #define GTASK_INIT(task, flags, priority, func, context) do {   \
   76         (task)->ta_flags = flags;                               \
   77         (task)->ta_priority = (priority);               \
   78         (task)->ta_func = (func);                       \
   79         (task)->ta_context = (context);                 \
   80 } while (0)
   81 
   82 #define GROUPTASK_INIT(gtask, priority, func, context)  \
   83         GTASK_INIT(&(gtask)->gt_task, TASK_SKIP_WAKEUP, priority, func, context)
   84 
   85 #define GROUPTASK_ENQUEUE(gtask)                        \
   86         grouptaskqueue_enqueue((gtask)->gt_taskqueue, &(gtask)->gt_task)
   87 
   88 #define TASKQGROUP_DECLARE(name)                        \
   89 extern struct taskqgroup *qgroup_##name
   90 
   91 #define TASKQGROUP_DEFINE(name, cnt, stride)                            \
   92                                                                         \
   93 struct taskqgroup *qgroup_##name;                                       \
   94                                                                         \
   95 static void                                                             \
   96 taskqgroup_define_##name(void *arg)                                     \
   97 {                                                                       \
   98         qgroup_##name = taskqgroup_create(#name);                       \
   99 }                                                                       \
  100                                                                         \
  101 SYSINIT(taskqgroup_##name, SI_SUB_TASKQ, SI_ORDER_FIRST,                \
  102         taskqgroup_define_##name, NULL);                                \
  103                                                                         \
  104 static void                                                             \
  105 taskqgroup_adjust_##name(void *arg)                                     \
  106 {                                                                       \
  107         taskqgroup_adjust(qgroup_##name, (cnt), (stride));              \
  108 }                                                                       \
  109                                                                         \
  110 SYSINIT(taskqgroup_adj_##name, SI_SUB_SMP, SI_ORDER_ANY,                \
  111         taskqgroup_adjust_##name, NULL)
  112 
  113 TASKQGROUP_DECLARE(net);
  114 TASKQGROUP_DECLARE(softirq);
  115 
  116 #endif /* !_SYS_GTASKQUEUE_H_ */

Cache object: 108c00cc6d5f5e6f4917ded77b97ea55


[ 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.