#ifndef _SYS_CPU_DATA_H_
#define _SYS_CPU_DATA_H_
struct callout;
struct lwp;
#include <sys/sched.h>
#include <sys/condvar.h>
#include <sys/pcu.h>
#include <sys/percpu_types.h>
#include <sys/queue.h>
#include <sys/kcpuset.h>
#include <sys/ipi.h>
#include <sys/intr.h>
enum cpu_count {
CPU_COUNT_NSWTCH,
CPU_COUNT_NSYSCALL,
CPU_COUNT_NTRAP,
CPU_COUNT_NINTR,
CPU_COUNT_NSOFT,
CPU_COUNT_FORKS,
CPU_COUNT_FORKS_PPWAIT,
CPU_COUNT_FORKS_SHAREVM,
CPU_COUNT_COLORHIT,
CPU_COUNT_COLORMISS,
CPU_COUNT__UNUSED3,
CPU_COUNT__UNUSED4,
CPU_COUNT_CPUHIT,
CPU_COUNT_CPUMISS,
CPU_COUNT_FREEPAGES,
CPU_COUNT__UNUSED5,
CPU_COUNT_PAGEINS,
CPU_COUNT_FLTUP,
CPU_COUNT_FLTNOUP,
CPU_COUNT_FLTPGWAIT,
CPU_COUNT_FLTRELCK,
CPU_COUNT_FLTRELCKOK,
CPU_COUNT__UNUSED1,
CPU_COUNT__UNUSED2,
CPU_COUNT_NFAULT,
CPU_COUNT_FLT_ACOW,
CPU_COUNT_FLT_ANON,
CPU_COUNT_FLT_OBJ,
CPU_COUNT_FLT_PRCOPY,
CPU_COUNT_FLT_PRZERO,
CPU_COUNT_FLTAMCOPY,
CPU_COUNT_FLTANGET,
CPU_COUNT_FLTANRETRY,
CPU_COUNT_FLTGET,
CPU_COUNT_FLTLGET,
CPU_COUNT_FLTNAMAP,
CPU_COUNT_FLTNOMAP,
CPU_COUNT_FLTNOANON,
CPU_COUNT_FLTNORAM,
CPU_COUNT_FLTPGRELE,
CPU_COUNT_ANONUNKNOWN,
CPU_COUNT_ANONCLEAN,
CPU_COUNT_ANONDIRTY,
CPU_COUNT_FILEUNKNOWN,
CPU_COUNT_FILECLEAN,
CPU_COUNT_FILEDIRTY,
CPU_COUNT_EXECPAGES,
CPU_COUNT_SYNC,
CPU_COUNT_MAX
};
struct lockdebug;
enum cpu_rel {
CPUREL_CORE,
CPUREL_PACKAGE,
CPUREL_PACKAGE1ST,
CPUREL_COUNT
};
struct cpu_data {
u_int cpu_index;
lwp_t *cpu_biglock_wanted;
kcondvar_t cpu_xcall;
int cpu_xcall_pending;
u_int cpu_psz_read_depth;
uint32_t cpu_ipipend[IPI_BITWORDS];
struct schedstate_percpu cpu_schedstate;
u_int cpu_package_id;
u_int cpu_core_id;
u_int cpu_smt_id;
u_int cpu_numa_id;
bool cpu_is_slow;
u_int cpu_nsibling[CPUREL_COUNT];
struct cpu_info *cpu_sibling[CPUREL_COUNT];
struct cpu_info *cpu_package1st;
lwp_t *cpu_idlelwp __aligned(64);
void *cpu_lockstat;
u_int cpu_biglock_count;
u_int cpu_spin_locks;
u_int cpu_simple_locks;
u_int cpu_spin_locks2;
u_int cpu_lkdebug_recurse;
u_int cpu_softints;
struct uvm_cpu *cpu_uvm;
u_int cpu_faultrng;
void *cpu_callout;
void *cpu_softcpu;
TAILQ_HEAD(,buf) cpu_biodone;
percpu_cpu_t cpu_percpu;
struct selcluster *cpu_selcluster;
void *cpu_nch;
_TAILQ_HEAD(,struct lockdebug,volatile) cpu_ld_locks;
__cpu_simple_lock_t cpu_ld_lock;
uint64_t cpu_cc_freq;
int64_t cpu_cc_skew;
char cpu_name[8];
kcpuset_t *cpu_kcpuset;
struct lwp * volatile cpu_pcu_curlwp[PCU_UNIT_COUNT];
int64_t cpu_counts[CPU_COUNT_MAX];
unsigned cpu_heartbeat_count;
unsigned cpu_heartbeat_uptime_cache;
unsigned cpu_heartbeat_uptime_stamp;
unsigned cpu_heartbeat_suspend;
};
#define ci_schedstate ci_data.cpu_schedstate
#define ci_index ci_data.cpu_index
#define ci_biglock_count ci_data.cpu_biglock_count
#define ci_biglock_wanted ci_data.cpu_biglock_wanted
#define ci_cpuname ci_data.cpu_name
#define ci_spin_locks ci_data.cpu_spin_locks
#define ci_simple_locks ci_data.cpu_simple_locks
#define ci_lockstat ci_data.cpu_lockstat
#define ci_spin_locks2 ci_data.cpu_spin_locks2
#define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse
#define ci_pcu_curlwp ci_data.cpu_pcu_curlwp
#define ci_kcpuset ci_data.cpu_kcpuset
#define ci_ipipend ci_data.cpu_ipipend
#define ci_psz_read_depth ci_data.cpu_psz_read_depth
#define ci_package_id ci_data.cpu_package_id
#define ci_core_id ci_data.cpu_core_id
#define ci_smt_id ci_data.cpu_smt_id
#define ci_numa_id ci_data.cpu_numa_id
#define ci_is_slow ci_data.cpu_is_slow
#define ci_nsibling ci_data.cpu_nsibling
#define ci_sibling ci_data.cpu_sibling
#define ci_package1st ci_data.cpu_package1st
#define ci_faultrng ci_data.cpu_faultrng
#define ci_counts ci_data.cpu_counts
#define ci_heartbeat_count ci_data.cpu_heartbeat_count
#define ci_heartbeat_uptime_cache ci_data.cpu_heartbeat_uptime_cache
#define ci_heartbeat_uptime_stamp ci_data.cpu_heartbeat_uptime_stamp
#define ci_heartbeat_suspend ci_data.cpu_heartbeat_suspend
#define cpu_nsyscall cpu_counts[CPU_COUNT_NSYSCALL]
#define cpu_ntrap cpu_counts[CPU_COUNT_NTRAP]
#define cpu_nswtch cpu_counts[CPU_COUNT_NSWTCH]
#define cpu_nintr cpu_counts[CPU_COUNT_NINTR]
#define cpu_nsoft cpu_counts[CPU_COUNT_NSOFT]
#define cpu_nfault cpu_counts[CPU_COUNT_NFAULT]
void mi_cpu_init(void);
int mi_cpu_attach(struct cpu_info *);
#define CPU_COUNT(idx, d) \
do { \
extern bool kpreempt_disabled(void); \
KASSERT(kpreempt_disabled()); \
KASSERT((unsigned)(idx) < CPU_COUNT_MAX); \
curcpu()->ci_counts[(idx)] += (d); \
} while (0)
static inline int64_t
cpu_count_get(enum cpu_count idx)
{
extern int64_t cpu_counts[];
return cpu_counts[idx];
}
void cpu_count(enum cpu_count, int64_t);
void cpu_count_sync(bool);
#endif