Skip to content

Commit

Permalink
14838 Rename erratum 147 handling
Browse files Browse the repository at this point in the history
14839 Untangle erratum 147 from lockstat
14840 Modernize lockstat probes
14865 mutex_tryenter:adaptive-acquire probe never fires
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Dan McDonald <danmcd@mnx.io>
Reviewed by: Gergő Mihály Doma <domag02@gmail.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>
  • Loading branch information
pfmooney committed Aug 13, 2022
1 parent 64439ec commit ee6ee36
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 240 deletions.
5 changes: 3 additions & 2 deletions usr/src/uts/common/dtrace/lockstat.c
Expand Up @@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2022 Oxide Computer Company
*/


Expand Down Expand Up @@ -93,7 +94,7 @@ lockstat_enable(void *arg, dtrace_id_t id, void *parg)
lockstat_probemap[probe->lsp_probe] = id;
membar_producer();

lockstat_hot_patch();
lockstat_hotpatch_probe(probe->lsp_probe);
membar_producer();

/*
Expand All @@ -115,7 +116,7 @@ lockstat_disable(void *arg, dtrace_id_t id, void *parg)
ASSERT(lockstat_probemap[probe->lsp_probe]);

lockstat_probemap[probe->lsp_probe] = 0;
lockstat_hot_patch();
lockstat_hotpatch_probe(probe->lsp_probe);
membar_producer();

/*
Expand Down
8 changes: 3 additions & 5 deletions usr/src/uts/common/sys/lockstat.h
Expand Up @@ -26,8 +26,6 @@
#ifndef _SYS_LOCKSTAT_H
#define _SYS_LOCKSTAT_H

#pragma ident "%Z%%M% %I% %E% SMI"

#include <sys/dtrace.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -123,7 +121,7 @@ extern void (*lockstat_probe)(dtrace_id_t, uintptr_t, uintptr_t,

extern int lockstat_active_threads(void);
extern int lockstat_depth(void);
extern void lockstat_hot_patch(void);
extern void lockstat_hotpatch_probe(int);

/*
* Macros to record lockstat probes.
Expand Down Expand Up @@ -175,10 +173,10 @@ extern void lockstat_hot_patch(void);
if (t_spin) { \
t_spin = gethrtime_waitfree() - t_spin; \
t_spin = CLAMP32(t_spin); \
} \
} \
(*lockstat_probe)(id, (uintptr_t)(lp), t_spin, \
0, 0, 0); \
} \
} \
curthread->t_lockstat--; \
}

Expand Down
5 changes: 3 additions & 2 deletions usr/src/uts/i86pc/Makefile.workarounds
Expand Up @@ -101,9 +101,10 @@ WORKAROUND_DEFS += -DOPTERON_ERRATUM_131
WORKAROUND_DEFS += -DOPTERON_WORKAROUND_6336786

#
# Mutex primitives don't work as expected
# Potential Violation of Read Ordering Rules Between Semaphore Operations and
# Unlocked Read-Modify-Write Instructions
#
WORKAROUND_DEFS += -DOPTERON_WORKAROUND_6323525
WORKAROUND_DEFS += -DOPTERON_ERRATUM_147

#
# Some Registered DIMMs incompatible with address parity feature
Expand Down
2 changes: 1 addition & 1 deletion usr/src/uts/i86pc/os/cpuid.c
Expand Up @@ -6274,7 +6274,7 @@ cpuid_opteron_erratum(cpu_t *cpu, uint_t erratum)
return (!(regs.cp_edx & 0x100));
}
return (0);
case 6323525:
case 147:
/*
* This erratum (K8 #147) is not present on family 10 and newer.
*/
Expand Down
27 changes: 14 additions & 13 deletions usr/src/uts/i86pc/os/mp_startup.c
Expand Up @@ -30,6 +30,7 @@
* Copyright 2020 Joyent, Inc.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
* Copyright 2022 Oxide Computer Company
*/

#include <sys/types.h>
Expand Down Expand Up @@ -669,8 +670,8 @@ int opteron_workaround_6336786; /* non-zero -> WA relevant and applied */
int opteron_workaround_6336786_UP = 0; /* Not needed for UP */
#endif

#if defined(OPTERON_WORKAROUND_6323525)
int opteron_workaround_6323525; /* if non-zero -> at least one cpu has it */
#if defined(OPTERON_ERRATUM_147)
int opteron_erratum_147; /* if non-zero -> at least one cpu has it */
#endif

#if defined(OPTERON_ERRATUM_298)
Expand Down Expand Up @@ -1166,8 +1167,8 @@ workaround_errata(struct cpu *cpu)
* 'Revision Guide for AMD Athlon 64 and AMD Opteron Processors'
* document 25759.
*/
if (cpuid_opteron_erratum(cpu, 6323525) > 0) {
#if defined(OPTERON_WORKAROUND_6323525)
if (cpuid_opteron_erratum(cpu, 147) > 0) {
#if defined(OPTERON_ERRATUM_147)
/*
* This problem only occurs with 2 or more cores. If bit in
* MSR_AMD_BU_CFG set, then not applicable. The workaround
Expand All @@ -1178,8 +1179,8 @@ workaround_errata(struct cpu *cpu)
* It is too early in boot to call the patch routine so
* set erratum variable to be done in startup_end().
*/
if (opteron_workaround_6323525) {
opteron_workaround_6323525++;
if (opteron_erratum_147) {
opteron_erratum_147++;
#if defined(__xpv)
} else if (is_x86_feature(x86_featureset, X86FSET_SSE2)) {
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
Expand All @@ -1188,26 +1189,26 @@ workaround_errata(struct cpu *cpu)
* operations are supported?
*/
if (xpv_nr_phys_cpus() > 1)
opteron_workaround_6323525++;
opteron_erratum_147++;
} else {
/*
* We have no way to tell how many physical
* cpus there are, or even if this processor
* has the problem, so enable the workaround
* unconditionally (at some performance cost).
*/
opteron_workaround_6323525++;
opteron_erratum_147++;
}
#else /* __xpv */
} else if (is_x86_feature(x86_featureset, X86FSET_SSE2) &&
((opteron_get_nnodes() *
cpuid_get_ncpu_per_chip(cpu)) > 1)) {
if ((xrdmsr(MSR_AMD_BU_CFG) & (UINT64_C(1) << 33)) == 0)
opteron_workaround_6323525++;
opteron_erratum_147++;
#endif /* __xpv */
}
#else
workaround_warning(cpu, 6323525);
workaround_warning(cpu, 147);
missing++;
#endif
}
Expand Down Expand Up @@ -1306,9 +1307,9 @@ workaround_errata_end()
if (opteron_workaround_6336786)
workaround_applied(6336786);
#endif
#if defined(OPTERON_WORKAROUND_6323525)
if (opteron_workaround_6323525)
workaround_applied(6323525);
#if defined(OPTERON_ERRATUM_147)
if (opteron_erratum_147)
workaround_applied(147);
#endif
#if defined(OPTERON_ERRATUM_298)
if (opteron_erratum_298) {
Expand Down
8 changes: 4 additions & 4 deletions usr/src/uts/i86pc/os/startup.c
Expand Up @@ -25,7 +25,7 @@
* Copyright 2017 Nexenta Systems, Inc.
* Copyright 2020 Joyent, Inc.
* Copyright (c) 2015 by Delphix. All rights reserved.
* Copyright 2020 Oxide Computer Company
* Copyright 2022 Oxide Computer Company
* Copyright (c) 2020 Carlos Neira <cneirabustos@gmail.com>
*/
/*
Expand Down Expand Up @@ -2125,9 +2125,9 @@ startup_end(void)
*/
cpu_event_init();

#if defined(OPTERON_WORKAROUND_6323525)
if (opteron_workaround_6323525)
patch_workaround_6323525();
#if defined(OPTERON_ERRATUM_147)
if (opteron_erratum_147)
patch_erratum_147();
#endif
/*
* If needed, load TOD module now so that ddi_get_time(9F) etc. work
Expand Down

0 comments on commit ee6ee36

Please sign in to comment.