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/smp.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  * ----------------------------------------------------------------------------
    3  * "THE BEER-WARE LICENSE" (Revision 42):
    4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
    5  * can do whatever you want with this stuff. If we meet some day, and you think
    6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
    7  * ----------------------------------------------------------------------------
    8  *
    9  * $FreeBSD$
   10  */
   11 
   12 #ifndef _SYS_SMP_H_
   13 #define _SYS_SMP_H_
   14 
   15 #ifdef _KERNEL
   16 
   17 #ifndef LOCORE
   18 
   19 #ifdef SMP
   20 
   21 /*
   22  * Topology of a NUMA or HTT system.
   23  *
   24  * The top level topology is an array of pointers to groups.  Each group
   25  * contains a bitmask of cpus in its group or subgroups.  It may also
   26  * contain a pointer to an array of child groups.
   27  *
   28  * The bitmasks at non leaf groups may be used by consumers who support
   29  * a smaller depth than the hardware provides.
   30  *
   31  * The topology may be omitted by systems where all CPUs are equal.
   32  */
   33 
   34 struct cpu_group {
   35         cpumask_t cg_mask;              /* Mask of cpus in this group. */
   36         int     cg_count;               /* Count of cpus in this group. */
   37         int     cg_children;            /* Number of children groups. */
   38         struct cpu_group *cg_child;     /* Optional child group. */
   39 };
   40 
   41 struct cpu_top {
   42         int     ct_count;               /* Count of groups. */
   43         struct cpu_group *ct_group;     /* Array of pointers to cpu groups. */
   44 };
   45 
   46 extern struct cpu_top *smp_topology;
   47 extern void (*cpustop_restartfunc)(void);
   48 extern int smp_active;
   49 extern int smp_cpus;
   50 extern volatile cpumask_t started_cpus;
   51 extern volatile cpumask_t stopped_cpus;
   52 extern cpumask_t idle_cpus_mask;
   53 extern cpumask_t hlt_cpus_mask;
   54 extern cpumask_t logical_cpus_mask;
   55 #endif /* SMP */
   56 
   57 extern u_int mp_maxid;
   58 extern int mp_maxcpus;
   59 extern int mp_ncpus;
   60 extern volatile int smp_started;
   61 
   62 extern cpumask_t all_cpus;
   63 
   64 /*
   65  * Macro allowing us to determine whether a CPU is absent at any given
   66  * time, thus permitting us to configure sparse maps of cpuid-dependent
   67  * (per-CPU) structures.
   68  */
   69 #define CPU_ABSENT(x_cpu)       ((all_cpus & (1 << (x_cpu))) == 0)
   70 
   71 /*
   72  * Macros to iterate over non-absent CPUs.  CPU_FOREACH() takes an
   73  * integer iterator and iterates over the available set of CPUs.
   74  * CPU_FIRST() returns the id of the first non-absent CPU.  CPU_NEXT()
   75  * returns the id of the next non-absent CPU.  It will wrap back to
   76  * CPU_FIRST() once the end of the list is reached.  The iterators are
   77  * currently implemented via inline functions.
   78  */
   79 #define CPU_FOREACH(i)                                                  \
   80         for ((i) = 0; (i) <= mp_maxid; (i)++)                           \
   81                 if (!CPU_ABSENT((i)))
   82 
   83 static __inline int
   84 cpu_first(void)
   85 {
   86         int i;
   87 
   88         for (i = 0;; i++)
   89                 if (!CPU_ABSENT(i))
   90                         return (i);
   91 }
   92 
   93 static __inline int
   94 cpu_next(int i)
   95 {
   96 
   97         for (;;) {
   98                 i++;
   99                 if (i > mp_maxid)
  100                         i = 0;
  101                 if (!CPU_ABSENT(i))
  102                         return (i);
  103         }
  104 }
  105 
  106 #define CPU_FIRST()     cpu_first()
  107 #define CPU_NEXT(i)     cpu_next((i))
  108 
  109 #ifdef SMP
  110 /*
  111  * Machine dependent functions used to initialize MP support.
  112  *
  113  * The cpu_mp_probe() should check to see if MP support is present and return
  114  * zero if it is not or non-zero if it is.  If MP support is present, then
  115  * cpu_mp_start() will be called so that MP can be enabled.  This function
  116  * should do things such as startup secondary processors.  It should also
  117  * setup mp_ncpus, all_cpus, and smp_cpus.  It should also ensure that
  118  * smp_active and smp_started are initialized at the appropriate time.
  119  * Once cpu_mp_start() returns, machine independent MP startup code will be
  120  * executed and a simple message will be output to the console.  Finally,
  121  * cpu_mp_announce() will be called so that machine dependent messages about
  122  * the MP support may be output to the console if desired.
  123  *
  124  * The cpu_setmaxid() function is called very early during the boot process
  125  * so that the MD code may set mp_maxid to provide an upper bound on CPU IDs
  126  * that other subsystems may use.  If a platform is not able to determine
  127  * the exact maximum ID that early, then it may set mp_maxid to MAXCPU - 1.
  128  */
  129 struct thread;
  130 
  131 void    cpu_mp_announce(void);
  132 int     cpu_mp_probe(void);
  133 void    cpu_mp_setmaxid(void);
  134 void    cpu_mp_start(void);
  135 
  136 void    forward_signal(struct thread *);
  137 void    forward_roundrobin(void);
  138 int     restart_cpus(cpumask_t);
  139 int     stop_cpus(cpumask_t);
  140 void    smp_rendezvous_action(void);
  141 extern  struct mtx smp_ipi_mtx;
  142 
  143 #endif /* SMP */
  144 void    smp_no_rendevous_barrier(void *);
  145 void    smp_rendezvous(void (*)(void *), 
  146                        void (*)(void *),
  147                        void (*)(void *),
  148                        void *arg);
  149 void    smp_rendezvous_cpus(cpumask_t,
  150                        void (*)(void *), 
  151                        void (*)(void *),
  152                        void (*)(void *),
  153                        void *arg);
  154 #endif /* !LOCORE */
  155 #endif /* _KERNEL */
  156 #endif /* _SYS_SMP_H_ */

Cache object: a5ca3d7b10453e247ef2e057f6e2af6f


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