1*2850d85bSmv /* 2*2850d85bSmv * CDDL HEADER START 3*2850d85bSmv * 4*2850d85bSmv * The contents of this file are subject to the terms of the 5*2850d85bSmv * Common Development and Distribution License (the "License"). 6*2850d85bSmv * You may not use this file except in compliance with the License. 7*2850d85bSmv * 8*2850d85bSmv * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2850d85bSmv * or http://www.opensolaris.org/os/licensing. 10*2850d85bSmv * See the License for the specific language governing permissions 11*2850d85bSmv * and limitations under the License. 12*2850d85bSmv * 13*2850d85bSmv * When distributing Covered Code, include this CDDL HEADER in each 14*2850d85bSmv * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2850d85bSmv * If applicable, add the following below this CDDL HEADER, with the 16*2850d85bSmv * fields enclosed by brackets "[]" replaced with your own identifying 17*2850d85bSmv * information: Portions Copyright [yyyy] [name of copyright owner] 18*2850d85bSmv * 19*2850d85bSmv * CDDL HEADER END 20*2850d85bSmv */ 21*2850d85bSmv 22*2850d85bSmv /* 23*2850d85bSmv * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*2850d85bSmv * Use is subject to license terms. 25*2850d85bSmv */ 26*2850d85bSmv 27*2850d85bSmv #ifndef _SYS_CLOCK_TICK_H 28*2850d85bSmv #define _SYS_CLOCK_TICK_H 29*2850d85bSmv 30*2850d85bSmv #include <sys/types.h> 31*2850d85bSmv #include <sys/mutex.h> 32*2850d85bSmv #include <sys/cpuvar.h> 33*2850d85bSmv #include <sys/systm.h> 34*2850d85bSmv #include <sys/cyclic.h> 35*2850d85bSmv 36*2850d85bSmv #ifdef __cplusplus 37*2850d85bSmv extern "C" { 38*2850d85bSmv #endif 39*2850d85bSmv 40*2850d85bSmv #define CLOCK_TICK_NCPUS 32 41*2850d85bSmv 42*2850d85bSmv /* 43*2850d85bSmv * Per-CPU structure to facilitate multi-threaded tick accounting. 44*2850d85bSmv * 45*2850d85bSmv * ct_lock 46*2850d85bSmv * Mutex for the structure. Used to lock the structure to pass 47*2850d85bSmv * arguments to the tick processing softint handler. 48*2850d85bSmv * ct_intr 49*2850d85bSmv * Tick processing softint handle. For parallelism, each CPU 50*2850d85bSmv * needs to have its own softint handle. 51*2850d85bSmv * ct_lbolt 52*2850d85bSmv * Copy of the lbolt at the time of tick scheduling. 53*2850d85bSmv * ct_pending 54*2850d85bSmv * Number of ticks to be processed by one invocation of the tick 55*2850d85bSmv * processing softint. 56*2850d85bSmv * ct_start 57*2850d85bSmv * First CPU to do tick processing for. 58*2850d85bSmv * ct_end 59*2850d85bSmv * Last CPU to do tick processing for. 60*2850d85bSmv * ct_scan 61*2850d85bSmv * CPU to start the tick processing from. Rotated every tick. 62*2850d85bSmv */ 63*2850d85bSmv typedef struct clock_tick_cpu { 64*2850d85bSmv kmutex_t ct_lock; 65*2850d85bSmv ulong_t ct_intr; 66*2850d85bSmv clock_t ct_lbolt; 67*2850d85bSmv int ct_pending; 68*2850d85bSmv int ct_start; 69*2850d85bSmv int ct_end; 70*2850d85bSmv int ct_scan; 71*2850d85bSmv } clock_tick_cpu_t; 72*2850d85bSmv 73*2850d85bSmv /* 74*2850d85bSmv * Per-set structure to facilitate multi-threaded tick accounting. 75*2850d85bSmv * clock_tick_lock protects this. 76*2850d85bSmv * 77*2850d85bSmv * ct_start 78*2850d85bSmv * First CPU to do tick processing for. 79*2850d85bSmv * ct_end 80*2850d85bSmv * Last CPU to do tick processing for. 81*2850d85bSmv * ct_scan 82*2850d85bSmv * CPU to start the tick processing from. Rotated every tick. 83*2850d85bSmv */ 84*2850d85bSmv typedef struct clock_tick_set { 85*2850d85bSmv int ct_start; 86*2850d85bSmv int ct_end; 87*2850d85bSmv int ct_scan; 88*2850d85bSmv } clock_tick_set_t; 89*2850d85bSmv 90*2850d85bSmv #define CLOCK_TICK_CPU_OFFLINE(cp) \ 91*2850d85bSmv (((cp) != cpu_active) && ((cp)->cpu_next_onln == (cp))) 92*2850d85bSmv 93*2850d85bSmv #define CLOCK_TICK_XCALL_SAFE(cp) \ 94*2850d85bSmv CPU_IN_SET(clock_tick_online_cpuset, cp->cpu_id) 95*2850d85bSmv 96*2850d85bSmv #define CLOCK_TICK_PROC_MAX 10 97*2850d85bSmv 98*2850d85bSmv #ifdef _KERNEL 99*2850d85bSmv #pragma weak create_softint 100*2850d85bSmv extern ulong_t create_softint(uint_t, uint_t (*)(caddr_t, caddr_t), 101*2850d85bSmv caddr_t); 102*2850d85bSmv #pragma weak invoke_softint 103*2850d85bSmv extern void invoke_softint(processorid_t, ulong_t); 104*2850d85bSmv #pragma weak sync_softint 105*2850d85bSmv extern void sync_softint(cpuset_t); 106*2850d85bSmv extern void clock_tick(kthread_t *, int); 107*2850d85bSmv extern void membar_sync(void); 108*2850d85bSmv 109*2850d85bSmv extern int hires_tick; 110*2850d85bSmv #endif /* _KERNEL */ 111*2850d85bSmv 112*2850d85bSmv #ifdef __cplusplus 113*2850d85bSmv } 114*2850d85bSmv #endif 115*2850d85bSmv 116*2850d85bSmv #endif /* _SYS_CLOCK_TICK_H */ 117