xref: /onnv-gate/usr/src/uts/common/sys/lgrp_user.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_LGRP_USER_H
28*0Sstevel@tonic-gate #define	_LGRP_USER_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * latency group definitions for user
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef	__cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #include <sys/inttypes.h>
42*0Sstevel@tonic-gate #include <sys/lgrp.h>
43*0Sstevel@tonic-gate #include <sys/procset.h>
44*0Sstevel@tonic-gate #include <sys/processor.h>
45*0Sstevel@tonic-gate #include <sys/pset.h>
46*0Sstevel@tonic-gate #include <sys/types.h>
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate /*
50*0Sstevel@tonic-gate  * lgroup interface version
51*0Sstevel@tonic-gate  */
52*0Sstevel@tonic-gate #define	LGRP_VER_NONE		0	/* no lgroup interface version */
53*0Sstevel@tonic-gate #define	LGRP_VER_CURRENT	2	/* current lgroup interface version */
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  * lgroup system call subcodes
58*0Sstevel@tonic-gate  */
59*0Sstevel@tonic-gate #define	LGRP_SYS_MEMINFO	0	/* meminfo(2) aka MISYS_MEMINFO */
60*0Sstevel@tonic-gate #define	LGRP_SYS_GENERATION	1	/* lgrp_generation() */
61*0Sstevel@tonic-gate #define	LGRP_SYS_VERSION	2	/* lgrp_version() */
62*0Sstevel@tonic-gate #define	LGRP_SYS_SNAPSHOT	3	/* lgrp_snapshot() */
63*0Sstevel@tonic-gate #define	LGRP_SYS_AFFINITY_GET	4	/* lgrp_affinity_set() */
64*0Sstevel@tonic-gate #define	LGRP_SYS_AFFINITY_SET	5	/* lgrp_affinity_get() */
65*0Sstevel@tonic-gate #define	LGRP_SYS_LATENCY	6	/* lgrp_latency() */
66*0Sstevel@tonic-gate #define	LGRP_SYS_HOME		7	/* lgrp_home() */
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate /*
70*0Sstevel@tonic-gate  * lgroup resources
71*0Sstevel@tonic-gate  */
72*0Sstevel@tonic-gate #define	LGRP_RSRC_COUNT		2	/* no. of resource types in lgroup */
73*0Sstevel@tonic-gate #define	LGRP_RSRC_CPU		0	/* CPU resources */
74*0Sstevel@tonic-gate #define	LGRP_RSRC_MEM		1	/* memory resources */
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate typedef int lgrp_rsrc_t;
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate /*
81*0Sstevel@tonic-gate  * lgroup affinity
82*0Sstevel@tonic-gate  */
83*0Sstevel@tonic-gate #define	LGRP_AFF_NONE		0x0	/* no affinity */
84*0Sstevel@tonic-gate #define	LGRP_AFF_WEAK		0x10	/* weak affinity */
85*0Sstevel@tonic-gate #define	LGRP_AFF_STRONG		0x100	/* strong affinity */
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate typedef int lgrp_affinity_t;
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate /*
90*0Sstevel@tonic-gate  * Arguments to lgrp_affinity_{get,set}()
91*0Sstevel@tonic-gate  */
92*0Sstevel@tonic-gate typedef struct lgrp_affinity_args {
93*0Sstevel@tonic-gate 	idtype_t	idtype;	/* ID type */
94*0Sstevel@tonic-gate 	id_t		id;	/* ID */
95*0Sstevel@tonic-gate 	lgrp_id_t	lgrp;	/* lgroup */
96*0Sstevel@tonic-gate 	lgrp_affinity_t	aff;	/* affinity */
97*0Sstevel@tonic-gate } lgrp_affinity_args_t;
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate /*
101*0Sstevel@tonic-gate  * Flags to specify contents of lgroups desired
102*0Sstevel@tonic-gate  */
103*0Sstevel@tonic-gate typedef enum lgrp_content {
104*0Sstevel@tonic-gate 	LGRP_CONTENT_ALL,	/* everything in lgroup */
105*0Sstevel@tonic-gate 	    /* everything in lgroup's hierarchy (for compatability) */
106*0Sstevel@tonic-gate 	LGRP_CONTENT_HIERARCHY = LGRP_CONTENT_ALL,
107*0Sstevel@tonic-gate 	LGRP_CONTENT_DIRECT	/* what's directly contained in lgroup */
108*0Sstevel@tonic-gate } lgrp_content_t;
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate /*
112*0Sstevel@tonic-gate  * Flags for lgrp_latency_cookie() specifying what hardware resources to get
113*0Sstevel@tonic-gate  * latency between
114*0Sstevel@tonic-gate  */
115*0Sstevel@tonic-gate typedef enum lgrp_lat_between {
116*0Sstevel@tonic-gate 	LGRP_LAT_CPU_TO_MEM	/* latency between CPU and memory */
117*0Sstevel@tonic-gate } lgrp_lat_between_t;
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate /*
121*0Sstevel@tonic-gate  * lgroup memory size type
122*0Sstevel@tonic-gate  */
123*0Sstevel@tonic-gate typedef longlong_t	lgrp_mem_size_t;
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate /*
127*0Sstevel@tonic-gate  * lgroup memory size flags
128*0Sstevel@tonic-gate  */
129*0Sstevel@tonic-gate typedef enum lgrp_mem_size_flag {
130*0Sstevel@tonic-gate 	LGRP_MEM_SZ_FREE,		/* free memory */
131*0Sstevel@tonic-gate 	LGRP_MEM_SZ_INSTALLED		/* installed memory */
132*0Sstevel@tonic-gate } lgrp_mem_size_flag_t;
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate /*
136*0Sstevel@tonic-gate  * View of lgroups
137*0Sstevel@tonic-gate  */
138*0Sstevel@tonic-gate typedef enum lgrp_view {
139*0Sstevel@tonic-gate 	LGRP_VIEW_CALLER,	/* what's available to the caller */
140*0Sstevel@tonic-gate 	LGRP_VIEW_OS		/* what's available to operating system */
141*0Sstevel@tonic-gate } lgrp_view_t;
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate /*
145*0Sstevel@tonic-gate  * lgroup information needed by user
146*0Sstevel@tonic-gate  */
147*0Sstevel@tonic-gate typedef	struct lgrp_info {
148*0Sstevel@tonic-gate 	lgrp_id_t	info_lgrpid;		/* lgroup ID */
149*0Sstevel@tonic-gate 	int		info_latency;		/* latency */
150*0Sstevel@tonic-gate 	ulong_t		*info_parents;		/* parent lgroups */
151*0Sstevel@tonic-gate 	ulong_t		*info_children;		/* children lgroups */
152*0Sstevel@tonic-gate 	ulong_t		*info_rset;		/* lgroup resources */
153*0Sstevel@tonic-gate 	pgcnt_t		info_mem_free;		/* free memory */
154*0Sstevel@tonic-gate 	pgcnt_t		info_mem_install;	/* installed memory */
155*0Sstevel@tonic-gate 	processorid_t	*info_cpuids;		/* CPU IDs */
156*0Sstevel@tonic-gate 	int		info_ncpus;		/* number of CPUs */
157*0Sstevel@tonic-gate } lgrp_info_t;
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate 
160*0Sstevel@tonic-gate /*
161*0Sstevel@tonic-gate  * Type of lgroup cookie to use with interface routines
162*0Sstevel@tonic-gate  */
163*0Sstevel@tonic-gate typedef uintptr_t	lgrp_cookie_t;
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate #define	LGRP_COOKIE_NONE	0	/* no cookie */
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate /*
169*0Sstevel@tonic-gate  * Type of lgroup generation number
170*0Sstevel@tonic-gate  */
171*0Sstevel@tonic-gate typedef uint_t	lgrp_gen_t;
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate 
174*0Sstevel@tonic-gate /*
175*0Sstevel@tonic-gate  * Format of lgroup hierarchy snapshot
176*0Sstevel@tonic-gate  */
177*0Sstevel@tonic-gate typedef struct lgrp_snapshot_header {
178*0Sstevel@tonic-gate 	int		ss_version;	/* lgroup interface version */
179*0Sstevel@tonic-gate 	int		ss_levels;	/* levels of hierarchy */
180*0Sstevel@tonic-gate 	int		ss_nlgrps;	/* number of lgroups */
181*0Sstevel@tonic-gate 	int		ss_nlgrps_os;	/* number of lgroups (OS view) */
182*0Sstevel@tonic-gate 	int		ss_nlgrps_max;	/* maximum number of lgroups */
183*0Sstevel@tonic-gate 	int		ss_root;	/* root lgroup */
184*0Sstevel@tonic-gate 	int		ss_ncpus;	/* total number of CPUs */
185*0Sstevel@tonic-gate 	lgrp_view_t	ss_view;	/* view of lgroup hierarchy */
186*0Sstevel@tonic-gate 	psetid_t	ss_pset;	/* caller's pset ID */
187*0Sstevel@tonic-gate 	lgrp_gen_t	ss_gen;		/* snapshot generation ID */
188*0Sstevel@tonic-gate 	size_t		ss_size;	/* total size of snapshot */
189*0Sstevel@tonic-gate 	uintptr_t	ss_magic;	/* snapshot magic number */
190*0Sstevel@tonic-gate 	lgrp_info_t	*ss_info;	/* lgroup info array */
191*0Sstevel@tonic-gate 	processorid_t	*ss_cpuids;	/* lgroup CPU ID array */
192*0Sstevel@tonic-gate 	ulong_t		*ss_lgrpset;	/* bit mask of available lgroups */
193*0Sstevel@tonic-gate 	ulong_t		*ss_parents;	/* lgroup parent bit masks */
194*0Sstevel@tonic-gate 	ulong_t		*ss_children;	/* lgroup children bit masks */
195*0Sstevel@tonic-gate 	ulong_t		*ss_rsets;	/* lgroup resource set bit masks */
196*0Sstevel@tonic-gate 	int		**ss_latencies;	/* latencies between lgroups */
197*0Sstevel@tonic-gate } lgrp_snapshot_header_t;
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate #ifdef	_SYSCALL32
201*0Sstevel@tonic-gate /*
202*0Sstevel@tonic-gate  * lgroup information needed by 32-bit user
203*0Sstevel@tonic-gate  */
204*0Sstevel@tonic-gate typedef	struct lgrp_info32 {
205*0Sstevel@tonic-gate 	int		info_lgrpid;		/* lgroup ID */
206*0Sstevel@tonic-gate 	int		info_latency;		/* latency */
207*0Sstevel@tonic-gate 	caddr32_t	info_parents;		/* parent lgroups */
208*0Sstevel@tonic-gate 	caddr32_t	info_children;		/* children lgroups */
209*0Sstevel@tonic-gate 	caddr32_t	info_rset;		/* lgroup resources */
210*0Sstevel@tonic-gate 	uint32_t	info_mem_free;		/* free memory */
211*0Sstevel@tonic-gate 	uint32_t	info_mem_install;	/* installed memory */
212*0Sstevel@tonic-gate 	caddr32_t	info_cpuids;		/* CPU IDs */
213*0Sstevel@tonic-gate 	int		info_ncpus;		/* number of CPUs */
214*0Sstevel@tonic-gate } lgrp_info32_t;
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate /*
218*0Sstevel@tonic-gate  * Format of lgroup hierarchy snapshot for 32-bit programs
219*0Sstevel@tonic-gate  */
220*0Sstevel@tonic-gate typedef struct lgrp_snapshot_header32 {
221*0Sstevel@tonic-gate 	int		ss_version;	/* lgroup interface version */
222*0Sstevel@tonic-gate 	int		ss_levels;	/* levels of hierarchy */
223*0Sstevel@tonic-gate 	int		ss_nlgrps;	/* number of lgroups */
224*0Sstevel@tonic-gate 	int		ss_nlgrps_os;	/* number of lgroups (OS view) */
225*0Sstevel@tonic-gate 	int		ss_nlgrps_max;	/* maximum number of lgroups */
226*0Sstevel@tonic-gate 	int		ss_root;	/* root lgroup */
227*0Sstevel@tonic-gate 	int		ss_ncpus;	/* total number of CPUs */
228*0Sstevel@tonic-gate 	int		ss_view;	/* view of lgroup hierarchy */
229*0Sstevel@tonic-gate 	int		ss_pset;	/* caller's pset ID */
230*0Sstevel@tonic-gate 	uint_t		ss_gen;		/* snapshot generation ID */
231*0Sstevel@tonic-gate 	size32_t	ss_size;	/* total size of snapshot */
232*0Sstevel@tonic-gate 	uint32_t	ss_magic;	/* snapshot magic number */
233*0Sstevel@tonic-gate 	caddr32_t	ss_info;	/* lgroup info array */
234*0Sstevel@tonic-gate 	caddr32_t	ss_cpuids;	/* lgroup CPU ID array */
235*0Sstevel@tonic-gate 	caddr32_t	ss_lgrpset;	/* bit mask of available lgroups */
236*0Sstevel@tonic-gate 	caddr32_t	ss_parents;	/* lgroup parent bit masks */
237*0Sstevel@tonic-gate 	caddr32_t	ss_children;	/* lgroup children bit masks */
238*0Sstevel@tonic-gate 	caddr32_t	ss_rsets;	/* lgroup resource set bit masks */
239*0Sstevel@tonic-gate 	caddr32_t	ss_latencies;	/* latencies between lgroups */
240*0Sstevel@tonic-gate } lgrp_snapshot_header32_t;
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate #endif	/* _SYSCALL32 */
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate #if (!defined(_KERNEL) && !defined(_KMEMUSER))
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate #ifdef	__STDC__
248*0Sstevel@tonic-gate 
249*0Sstevel@tonic-gate lgrp_affinity_t	lgrp_affinity_get(idtype_t idtype, id_t id, lgrp_id_t lgrp);
250*0Sstevel@tonic-gate 
251*0Sstevel@tonic-gate int		lgrp_affinity_set(idtype_t idtype, id_t id, lgrp_id_t lgrp,
252*0Sstevel@tonic-gate     lgrp_affinity_t aff);
253*0Sstevel@tonic-gate 
254*0Sstevel@tonic-gate int		lgrp_children(lgrp_cookie_t cookie, lgrp_id_t lgrp,
255*0Sstevel@tonic-gate     lgrp_id_t *children, uint_t count);
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate int		lgrp_cookie_stale(lgrp_cookie_t cookie);
258*0Sstevel@tonic-gate 
259*0Sstevel@tonic-gate int		lgrp_cpus(lgrp_cookie_t cookie, lgrp_id_t lgrp,
260*0Sstevel@tonic-gate     processorid_t *cpuids, uint_t count, lgrp_content_t content);
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate int		lgrp_fini(lgrp_cookie_t cookie);
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate int		lgrp_latency(lgrp_id_t from, lgrp_id_t to);
265*0Sstevel@tonic-gate 
266*0Sstevel@tonic-gate int		lgrp_latency_cookie(lgrp_cookie_t cookie, lgrp_id_t from,
267*0Sstevel@tonic-gate     lgrp_id_t to, lgrp_lat_between_t between);
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate lgrp_id_t	lgrp_home(idtype_t idtype, id_t id);
270*0Sstevel@tonic-gate 
271*0Sstevel@tonic-gate lgrp_cookie_t	lgrp_init(lgrp_view_t view);
272*0Sstevel@tonic-gate 
273*0Sstevel@tonic-gate lgrp_mem_size_t	lgrp_mem_size(lgrp_cookie_t cookie, lgrp_id_t lgrp,
274*0Sstevel@tonic-gate     lgrp_mem_size_flag_t type, lgrp_content_t content);
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate int		lgrp_nlgrps(lgrp_cookie_t cookie);
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate int		lgrp_parents(lgrp_cookie_t cookie, lgrp_id_t lgrp,
279*0Sstevel@tonic-gate     lgrp_id_t *parents, uint_t count);
280*0Sstevel@tonic-gate 
281*0Sstevel@tonic-gate int		lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp,
282*0Sstevel@tonic-gate     lgrp_id_t *lgrps, uint_t count, lgrp_rsrc_t type);
283*0Sstevel@tonic-gate 
284*0Sstevel@tonic-gate lgrp_id_t	lgrp_root(lgrp_cookie_t cookie);
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate int		lgrp_version(int version);
287*0Sstevel@tonic-gate 
288*0Sstevel@tonic-gate lgrp_view_t	lgrp_view(lgrp_cookie_t cookie);
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate #else	/* __STDC__ */
291*0Sstevel@tonic-gate lgrp_affinity_t	lgrp_affinity_get();
292*0Sstevel@tonic-gate int		lgrp_affinity_set();
293*0Sstevel@tonic-gate int		lgrp_children();
294*0Sstevel@tonic-gate int		lgrp_cookie_stale();
295*0Sstevel@tonic-gate int		lgrp_cpus();
296*0Sstevel@tonic-gate int		lgrp_fini();
297*0Sstevel@tonic-gate lgrp_id_t	lgrp_home();
298*0Sstevel@tonic-gate int		lgrp_init();
299*0Sstevel@tonic-gate int		lgrp_latency();
300*0Sstevel@tonic-gate spgcnt_t	lgrp_mem_size();
301*0Sstevel@tonic-gate int		lgrp_nlgrps();
302*0Sstevel@tonic-gate int		lgrp_parents();
303*0Sstevel@tonic-gate int		lgrp_resources();
304*0Sstevel@tonic-gate lgrp_id_t	lgrp_root();
305*0Sstevel@tonic-gate int		lgrp_version();
306*0Sstevel@tonic-gate lgrp_view_t	lgrp_view();
307*0Sstevel@tonic-gate #endif	/* __STDC__ */
308*0Sstevel@tonic-gate 
309*0Sstevel@tonic-gate #endif	/* !_KERNEL && !_KMEMUSER */
310*0Sstevel@tonic-gate 
311*0Sstevel@tonic-gate #ifdef	__cplusplus
312*0Sstevel@tonic-gate }
313*0Sstevel@tonic-gate #endif
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate #endif /* _LGRP_USER_H */
316