1 /* $NetBSD: cpu_data.h,v 1.35 2012/09/01 00:24:44 matt Exp $ */ 2 3 /*- 4 * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * based on arch/i386/include/cpu.h: 31 * NetBSD: cpu.h,v 1.115 2004/05/16 12:32:53 yamt Exp 32 */ 33 34 #ifndef _SYS_CPU_DATA_H_ 35 #define _SYS_CPU_DATA_H_ 36 37 struct callout; 38 struct lwp; 39 40 #include <sys/sched.h> /* for schedstate_percpu */ 41 #include <sys/condvar.h> 42 #include <sys/pcu.h> 43 #include <sys/percpu_types.h> 44 #include <sys/queue.h> 45 #include <sys/kcpuset.h> 46 47 /* 48 * MI per-cpu data 49 * 50 * this structure is intended to be included in MD cpu_info structure. 51 * struct cpu_info { 52 * struct cpu_data ci_data; 53 * } 54 * 55 * note that cpu_data is not expected to contain much data, 56 * as cpu_info is size-limited on most ports. 57 */ 58 59 struct lockdebug; 60 61 struct cpu_data { 62 /* 63 * The first section is likely to be touched by other CPUs - 64 * it is cache hot. 65 */ 66 lwp_t *cpu_biglock_wanted; /* LWP spinning on biglock */ 67 void *cpu_callout; /* per-CPU callout state */ 68 void *cpu_unused1; /* unused */ 69 u_int cpu_unused2; /* unused */ 70 struct schedstate_percpu cpu_schedstate; /* scheduler state */ 71 kcondvar_t cpu_xcall; /* cross-call support */ 72 int cpu_xcall_pending; /* cross-call support */ 73 lwp_t *cpu_onproc; /* bottom level LWP */ 74 CIRCLEQ_ENTRY(cpu_info) cpu_qchain; /* circleq of all CPUs */ 75 76 cpuid_t cpu_package_id; 77 cpuid_t cpu_core_id; 78 cpuid_t cpu_smt_id; 79 80 struct lwp * volatile cpu_pcu_curlwp[PCU_UNIT_COUNT]; 81 82 /* 83 * This section is mostly CPU-private. 84 */ 85 lwp_t *cpu_idlelwp; /* idle lwp */ 86 void *cpu_lockstat; /* lockstat private tables */ 87 u_int cpu_index; /* CPU index */ 88 u_int cpu_biglock_count; /* # recursive holds */ 89 u_int cpu_spin_locks; /* # of spinlockmgr locks */ 90 u_int cpu_simple_locks; /* # of simple locks held */ 91 u_int cpu_spin_locks2; /* # of spin locks held XXX */ 92 u_int cpu_lkdebug_recurse; /* LOCKDEBUG recursion */ 93 u_int cpu_softints; /* pending (slow) softints */ 94 uint64_t cpu_nsyscall; /* syscall counter */ 95 uint64_t cpu_ntrap; /* trap counter */ 96 uint64_t cpu_nswtch; /* context switch counter */ 97 uint64_t cpu_nintr; /* interrupt count */ 98 uint64_t cpu_nsoft; /* soft interrupt count */ 99 uint64_t cpu_nfault; /* pagefault counter */ 100 void *cpu_uvm; /* uvm per-cpu data */ 101 void *cpu_softcpu; /* soft interrupt table */ 102 TAILQ_HEAD(,buf) cpu_biodone; /* finished block xfers */ 103 percpu_cpu_t cpu_percpu; /* per-cpu data */ 104 struct selcluster *cpu_selcluster; /* per-CPU select() info */ 105 void *cpu_nch; /* per-cpu vfs_cache data */ 106 _TAILQ_HEAD(,struct lockdebug,volatile) cpu_ld_locks;/* !: lockdebug */ 107 __cpu_simple_lock_t cpu_ld_lock; /* lockdebug */ 108 uint64_t cpu_cc_freq; /* cycle counter frequency */ 109 int64_t cpu_cc_skew; /* counter skew vs cpu0 */ 110 char cpu_name[8]; /* eg, "cpu4" */ 111 kcpuset_t *cpu_kcpuset; /* kcpuset_t of this cpu only */ 112 }; 113 114 /* compat definitions */ 115 #define ci_schedstate ci_data.cpu_schedstate 116 #define ci_index ci_data.cpu_index 117 #define ci_biglock_count ci_data.cpu_biglock_count 118 #define ci_biglock_wanted ci_data.cpu_biglock_wanted 119 #define ci_cpuname ci_data.cpu_name 120 #define ci_spin_locks ci_data.cpu_spin_locks 121 #define ci_simple_locks ci_data.cpu_simple_locks 122 #define ci_lockstat ci_data.cpu_lockstat 123 #define ci_spin_locks2 ci_data.cpu_spin_locks2 124 #define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse 125 #define ci_pcu_curlwp ci_data.cpu_pcu_curlwp 126 #define ci_kcpuset ci_data.cpu_kcpuset 127 128 #define ci_package_id ci_data.cpu_package_id 129 #define ci_core_id ci_data.cpu_core_id 130 #define ci_smt_id ci_data.cpu_smt_id 131 132 void mi_cpu_init(void); 133 int mi_cpu_attach(struct cpu_info *); 134 135 #endif /* _SYS_CPU_DATA_H_ */ 136