Print this page
13902 Fix for 13717 may break 8-disk raidz2
13915 installctx() blocking allocate causes problems
Portions contributed by: Jerry Jelinek <gjelinek@gmail.com>
Change-Id: I934d69946cec42630fc541fa8c7385b862b69ca2


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2019 Joyent, Inc.
  24  */
  25 
  26 /*
  27  * x86-specific routines used by the CPU Performance counter driver.
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/time.h>
  32 #include <sys/atomic.h>
  33 #include <sys/regset.h>
  34 #include <sys/privregs.h>
  35 #include <sys/x86_archext.h>
  36 #include <sys/cpuvar.h>
  37 #include <sys/machcpuvar.h>
  38 #include <sys/archsystm.h>
  39 #include <sys/cpc_pcbe.h>
  40 #include <sys/cpc_impl.h>
  41 #include <sys/x_call.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/cmt.h>


 152                 }
 153         }
 154 
 155         if (strands_perfmon_shared) {
 156                 mutex_enter(&cpu_setup_lock);
 157                 if (setup_registered == 0) {
 158                         mutex_enter(&cpu_lock);
 159                         register_cpu_setup_func(kcpc_cpu_setup, NULL);
 160                         mutex_exit(&cpu_lock);
 161                         setup_registered = 1;
 162                 }
 163                 mutex_exit(&cpu_setup_lock);
 164         }
 165 
 166         mutex_init(&cp->cpu_cpc_ctxlock, "cpu_cpc_ctxlock", MUTEX_DEFAULT, 0);
 167 
 168         if (kcpc_counts_include_idle)
 169                 return;
 170 
 171         installctx(t, cp, kcpc_idle_save, kcpc_idle_restore,
 172             NULL, NULL, NULL, NULL);
 173 }
 174 
 175 void
 176 kcpc_hw_fini(cpu_t *cp)
 177 {
 178         ASSERT(cp->cpu_idle_thread == NULL);
 179 
 180         mutex_destroy(&cp->cpu_cpc_ctxlock);
 181 }
 182 
 183 #define BITS(v, u, l)   \
 184         (((v) >> (l)) & ((1 << (1 + (u) - (l))) - 1))
 185 
 186 #define PCBE_NAMELEN 30 /* Enough Room for pcbe.manuf.model.family.stepping */
 187 
 188 /*
 189  * Examine the processor and load an appropriate PCBE.
 190  */
 191 int
 192 kcpc_hw_load_pcbe(void)




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2021 Joyent, Inc.
  24  */
  25 
  26 /*
  27  * x86-specific routines used by the CPU Performance counter driver.
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/time.h>
  32 #include <sys/atomic.h>
  33 #include <sys/regset.h>
  34 #include <sys/privregs.h>
  35 #include <sys/x86_archext.h>
  36 #include <sys/cpuvar.h>
  37 #include <sys/machcpuvar.h>
  38 #include <sys/archsystm.h>
  39 #include <sys/cpc_pcbe.h>
  40 #include <sys/cpc_impl.h>
  41 #include <sys/x_call.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/cmt.h>


 152                 }
 153         }
 154 
 155         if (strands_perfmon_shared) {
 156                 mutex_enter(&cpu_setup_lock);
 157                 if (setup_registered == 0) {
 158                         mutex_enter(&cpu_lock);
 159                         register_cpu_setup_func(kcpc_cpu_setup, NULL);
 160                         mutex_exit(&cpu_lock);
 161                         setup_registered = 1;
 162                 }
 163                 mutex_exit(&cpu_setup_lock);
 164         }
 165 
 166         mutex_init(&cp->cpu_cpc_ctxlock, "cpu_cpc_ctxlock", MUTEX_DEFAULT, 0);
 167 
 168         if (kcpc_counts_include_idle)
 169                 return;
 170 
 171         installctx(t, cp, kcpc_idle_save, kcpc_idle_restore,
 172             NULL, NULL, NULL, NULL, NULL);
 173 }
 174 
 175 void
 176 kcpc_hw_fini(cpu_t *cp)
 177 {
 178         ASSERT(cp->cpu_idle_thread == NULL);
 179 
 180         mutex_destroy(&cp->cpu_cpc_ctxlock);
 181 }
 182 
 183 #define BITS(v, u, l)   \
 184         (((v) >> (l)) & ((1 << (1 + (u) - (l))) - 1))
 185 
 186 #define PCBE_NAMELEN 30 /* Enough Room for pcbe.manuf.model.family.stepping */
 187 
 188 /*
 189  * Examine the processor and load an appropriate PCBE.
 190  */
 191 int
 192 kcpc_hw_load_pcbe(void)