summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/pool.h
blob: c4cc9fc22af783b3f0a77989af71c46a38725c5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_POOL_H
#define	_SYS_POOL_H

#include <sys/types.h>
#include <sys/time.h>
#include <sys/nvpair.h>
#include <sys/procset.h>
#include <sys/list.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	POOL_DEFAULT		0		/* default pool's ID */
#define	POOL_MAXID		999999		/* maximum possible pool ID */
#define	POOL_INVALID		-1

/* pools states */
#define	POOL_DISABLED		0		/* pools enabled */
#define	POOL_ENABLED		1		/* pools disabled */

#ifdef	_KERNEL

struct pool_pset;

typedef struct pool {
	poolid_t		pool_id;	/* pool ID */
	uint32_t		pool_ref;	/* # of procs in this pool */
	list_node_t		pool_link;	/* links to next/prev pools */
	nvlist_t		*pool_props;	/* pool properties */
	struct pool_pset	*pool_pset;	/* pool's pset */
} pool_t;

/*
 * Flags for pool_do_bind
 */
#define	POOL_BIND_PSET	0x00000001
#define	POOL_BIND_ALL	POOL_BIND_PSET

/*
 * Result codes for pool_get_class()
 */
#define	POOL_CLASS_UNSET	-1		/* no scheduling class set */
#define	POOL_CLASS_INVAL	-2		/* class is invalid */

extern int	pool_count;	/* current number of pools */
extern pool_t	*pool_default;	/* default pool pointer */
extern int	pool_state;	/* pools state -- enabled/disabled */
extern void	*pool_buf;	/* last state snapshot */
extern size_t	pool_bufsz;	/* size of pool_buf */

/*
 * Lookup routines
 */
extern pool_t	*pool_lookup_pool_by_id(poolid_t);
extern pool_t	*pool_lookup_pool_by_name(char *);
extern pool_t	*pool_lookup_pool_by_pset(int);

/*
 * Configuration routines
 */
extern void 	pool_init(void);
extern int	pool_status(int);
extern int	pool_create(int, int, id_t *);
extern int	pool_destroy(int, int, id_t);
extern int	pool_transfer(int, id_t, id_t, uint64_t);
extern int	pool_assoc(poolid_t, int, id_t);
extern int	pool_dissoc(poolid_t, int);
extern int	pool_bind(poolid_t, idtype_t, id_t);
extern id_t	pool_get_class(pool_t *);
extern int	pool_do_bind(pool_t *, idtype_t, id_t, int);
extern int	pool_query_binding(idtype_t, id_t, id_t *);
extern int	pool_xtransfer(int, id_t, id_t, uint_t, id_t *);
extern int	pool_pack_conf(void *, size_t, size_t *);
extern int	pool_propput(int, int, id_t, nvpair_t *);
extern int	pool_proprm(int, int, id_t, char *);
extern int	pool_propget(char *, int, int, id_t, nvlist_t **);
extern int	pool_commit(int);
extern void	pool_get_name(pool_t *, char **);

/*
 * Synchronization routines
 */
extern void	pool_lock(void);
extern int	pool_lock_intr(void);
extern int	pool_lock_held(void);
extern void	pool_unlock(void);
extern void	pool_barrier_enter(void);
extern void	pool_barrier_exit(void);

typedef enum {
	POOL_E_ENABLE,
	POOL_E_DISABLE,
	POOL_E_CHANGE,
} pool_event_t;

typedef void pool_event_cb_func_t(pool_event_t, poolid_t,  void *);

typedef struct pool_event_cb {
	pool_event_cb_func_t	*pec_func;
	void			*pec_arg;
	list_node_t		pec_list;
} pool_event_cb_t;

/*
 * Routines used to register interest in changes in cpu pools.
 */
extern void pool_event_cb_register(pool_event_cb_t *);
extern void pool_event_cb_unregister(pool_event_cb_t *);
#endif	/* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_POOL_H */