10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216812Sraf
220Sstevel@tonic-gate /*
23*10089SSurya.Prakki@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
276812Sraf #include "lint.h"
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/procset.h>
300Sstevel@tonic-gate #include <sys/processor.h>
310Sstevel@tonic-gate #include <sys/pset.h>
320Sstevel@tonic-gate #include <sys/param.h>
330Sstevel@tonic-gate #include <sys/loadavg.h>
340Sstevel@tonic-gate
350Sstevel@tonic-gate int _pset(int, ...);
360Sstevel@tonic-gate
370Sstevel@tonic-gate /* subcode wrappers for _pset system call */
380Sstevel@tonic-gate
390Sstevel@tonic-gate int
pset_create(psetid_t * npset)400Sstevel@tonic-gate pset_create(psetid_t *npset)
410Sstevel@tonic-gate {
420Sstevel@tonic-gate return (_pset(PSET_CREATE, npset));
430Sstevel@tonic-gate }
440Sstevel@tonic-gate
450Sstevel@tonic-gate int
pset_destroy(psetid_t pset)460Sstevel@tonic-gate pset_destroy(psetid_t pset)
470Sstevel@tonic-gate {
480Sstevel@tonic-gate return (_pset(PSET_DESTROY, pset));
490Sstevel@tonic-gate }
500Sstevel@tonic-gate
510Sstevel@tonic-gate int
pset_assign(psetid_t pset,processorid_t cpu,psetid_t * opset)520Sstevel@tonic-gate pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset)
530Sstevel@tonic-gate {
540Sstevel@tonic-gate return (_pset(PSET_ASSIGN, pset, cpu, opset));
550Sstevel@tonic-gate }
560Sstevel@tonic-gate
570Sstevel@tonic-gate int
pset_assign_forced(psetid_t pset,processorid_t cpu,psetid_t * opset)580Sstevel@tonic-gate pset_assign_forced(psetid_t pset, processorid_t cpu, psetid_t *opset)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate return (_pset(PSET_ASSIGN_FORCED, pset, cpu, opset));
610Sstevel@tonic-gate }
620Sstevel@tonic-gate
630Sstevel@tonic-gate int
pset_info(psetid_t pset,int * type,uint_t * numcpus,processorid_t * cpulist)640Sstevel@tonic-gate pset_info(psetid_t pset, int *type, uint_t *numcpus, processorid_t *cpulist)
650Sstevel@tonic-gate {
660Sstevel@tonic-gate return (_pset(PSET_INFO, pset, type, numcpus, cpulist));
670Sstevel@tonic-gate }
680Sstevel@tonic-gate
690Sstevel@tonic-gate int
pset_bind(psetid_t pset,idtype_t idtype,id_t id,psetid_t * opset)700Sstevel@tonic-gate pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset)
710Sstevel@tonic-gate {
720Sstevel@tonic-gate return (_pset(PSET_BIND, pset, idtype, id, opset));
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
75*10089SSurya.Prakki@Sun.COM int
pset_bind_lwp(psetid_t pset,id_t id,pid_t pid,psetid_t * opset)76*10089SSurya.Prakki@Sun.COM pset_bind_lwp(psetid_t pset, id_t id, pid_t pid, psetid_t *opset)
77*10089SSurya.Prakki@Sun.COM {
78*10089SSurya.Prakki@Sun.COM return (_pset(PSET_BIND_LWP, pset, id, pid, opset));
79*10089SSurya.Prakki@Sun.COM }
80*10089SSurya.Prakki@Sun.COM
810Sstevel@tonic-gate /*
820Sstevel@tonic-gate * Get the per-processor-set load average.
830Sstevel@tonic-gate */
840Sstevel@tonic-gate int
pset_getloadavg(psetid_t pset,double loadavg[],int nelem)850Sstevel@tonic-gate pset_getloadavg(psetid_t pset, double loadavg[], int nelem)
860Sstevel@tonic-gate {
870Sstevel@tonic-gate int i, buf[LOADAVG_NSTATS];
880Sstevel@tonic-gate
890Sstevel@tonic-gate if (nelem > LOADAVG_NSTATS)
900Sstevel@tonic-gate nelem = LOADAVG_NSTATS;
910Sstevel@tonic-gate
920Sstevel@tonic-gate if (_pset(PSET_GETLOADAVG, pset, buf, nelem) == -1)
930Sstevel@tonic-gate return (-1);
940Sstevel@tonic-gate
950Sstevel@tonic-gate for (i = 0; i < nelem; i++)
960Sstevel@tonic-gate loadavg[i] = (double)buf[i] / FSCALE;
970Sstevel@tonic-gate
980Sstevel@tonic-gate return (nelem);
990Sstevel@tonic-gate }
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate int
pset_list(psetid_t * psetlist,uint_t * numpsets)1020Sstevel@tonic-gate pset_list(psetid_t *psetlist, uint_t *numpsets)
1030Sstevel@tonic-gate {
1040Sstevel@tonic-gate return (_pset(PSET_LIST, psetlist, numpsets));
1050Sstevel@tonic-gate }
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate int
pset_setattr(psetid_t pset,uint_t attr)1080Sstevel@tonic-gate pset_setattr(psetid_t pset, uint_t attr)
1090Sstevel@tonic-gate {
1100Sstevel@tonic-gate return (_pset(PSET_SETATTR, pset, attr));
1110Sstevel@tonic-gate }
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate int
pset_getattr(psetid_t pset,uint_t * attr)1140Sstevel@tonic-gate pset_getattr(psetid_t pset, uint_t *attr)
1150Sstevel@tonic-gate {
1160Sstevel@tonic-gate return (_pset(PSET_GETATTR, pset, attr));
1170Sstevel@tonic-gate }
118