chip.c revision f56c1286e5113aa46bd6e723da14d30c123153f2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License, Version 1.0 only
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (the "License"). You may not use this file except in compliance
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma ident "%Z%%M% %I% %E% SMI"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CMT aware scheduler/dispatcher support
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * With the introduction of Chip Multi-Threaded (CMT) processor architectures,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * it is no longer necessarily true that a given physical processor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * module (chip) will present itself as a single schedulable entity (cpu_t).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Rather, each chip may present itself as one or more "logical" CPUs.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The logical CPUs presented may share physical components on the chip
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * such as caches, data pipes, FPUs, etc. It is advantageous to have the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * kernel know which logical CPUs are presented by a given chip,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and what facilities on the chip are shared, since the kernel can then use
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * this information to employ scheduling policies that help improve the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * availability of per chip resources, and increase utilization of a thread's
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * cache investment.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The "chip_t" structure represents a physical processor.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * It is used to keep track of which logical CPUs are presented by a given
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * chip, and to provide a parameterized representation of a chip's
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * properties. A count of the number of running threads is also
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * maintained, and is used by the dispatcher to balance load across the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * system's chips to improve performance through increased chip resource
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * availability.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Locking:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Safely traversing the per lgroup lists requires the same protections
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * as traversing the cpu lists. One must either:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * - hold cpu_lock
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * - have disabled kernel preemption
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * - be at high SPL
* Declare static kstat names (defined in chip.h)
static chip_t *
return (chp);
return (NULL);
#ifndef sun4v
return (EACCES);
int rechoose;
#ifdef sun4v
nchips++;
nchips--;
for (i = 0; i < CHIP_SET_WORDS; i++) {