FreeBSD/Linux Kernel Cross Reference
sys/sys/pcpu.h
1 /*-
2 * Copyright (c) 2001 Wind River Systems, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 4. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: releng/7.4/sys/sys/pcpu.h 182630 2008-09-01 19:01:18Z obrien $
31 */
32
33 #ifndef _SYS_PCPU_H_
34 #define _SYS_PCPU_H_
35
36 #ifdef LOCORE
37 #error "no assembler-serviceable parts inside"
38 #endif
39
40 #include <sys/queue.h>
41 #include <sys/vmmeter.h>
42 #include <sys/resource.h>
43 #include <machine/pcpu.h>
44
45 struct pcb;
46 struct thread;
47
48 /*
49 * This structure maps out the global data that needs to be kept on a
50 * per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR
51 * macros defined in <machine/pcpu.h>. Machine dependent fields are
52 * defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>.
53 */
54 struct pcpu {
55 struct thread *pc_curthread; /* Current thread */
56 struct thread *pc_idlethread; /* Idle thread */
57 struct thread *pc_fpcurthread; /* Fp state owner */
58 struct thread *pc_deadthread; /* Zombie thread or NULL */
59 struct pcb *pc_curpcb; /* Current pcb */
60 uint64_t pc_switchtime;
61 int pc_switchticks;
62 u_int pc_cpuid; /* This cpu number */
63 cpumask_t pc_cpumask; /* This cpu mask */
64 cpumask_t pc_other_cpus; /* Mask of all other cpus */
65 SLIST_ENTRY(pcpu) pc_allcpu;
66 struct lock_list_entry *pc_spinlocks;
67 #ifdef KTR_PERCPU
68 int pc_ktr_idx; /* Index into trace table */
69 char *pc_ktr_buf;
70 #endif
71 PCPU_MD_FIELDS;
72 struct vmmeter pc_cnt; /* VM stats counters */
73 long pc_cp_time[CPUSTATES]; /* statclock ticks */
74 struct device *pc_device;
75 };
76
77 #ifdef _KERNEL
78
79 SLIST_HEAD(cpuhead, pcpu);
80
81 extern struct cpuhead cpuhead;
82
83 #define curcpu PCPU_GET(cpuid)
84 #define curproc (curthread->td_proc)
85 #ifndef curthread
86 #define curthread PCPU_GET(curthread)
87 #endif
88
89 /*
90 * Machine dependent callouts. cpu_pcpu_init() is responsible for
91 * initializing machine dependent fields of struct pcpu, and
92 * db_show_mdpcpu() is responsible for handling machine dependent
93 * fields for the DDB 'show pcpu' command.
94 */
95 void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size);
96 void db_show_mdpcpu(struct pcpu *pcpu);
97
98 void pcpu_destroy(struct pcpu *pcpu);
99 struct pcpu *pcpu_find(u_int cpuid);
100 void pcpu_init(struct pcpu *pcpu, int cpuid, size_t size);
101
102 #endif /* _KERNEL */
103
104 #endif /* !_SYS_PCPU_H_ */
Cache object: f63696310229cbe5289a983042f2a531
|