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