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