Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178142144
D61365.1796096004.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61365.1796096004.diff
View Options
diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c
--- a/sys/dev/hwpmc/hwpmc_ibs.c
+++ b/sys/dev/hwpmc/hwpmc_ibs.c
@@ -89,15 +89,9 @@
&ibs_op_ctl2_extra_mask, 0,
"Extra allowed bits in the IBS op control 2 MSR (override; default 0)");
-/*
- * Per-processor information
- */
-#define IBS_CPU_RUNNING 1
-#define IBS_CPU_STOPPING 2
-#define IBS_CPU_STOPPED 3
-
+/* Count fetch and op stops. */
struct ibs_cpu {
- int pc_status;
+ int pc_stopping;
int pc_nmi_credit; /* owed NMIs already serviced */
struct pmc_hw pc_ibspmcs[IBS_NPMCS];
};
@@ -479,12 +473,6 @@
PMCDBG2(MDP, STA, 1, "ibs-start cpu=%d ri=%d", cpu, ri);
- /*
- * This is used to handle spurious NMIs. All that matters is that it
- * is not in the stopping state.
- */
- atomic_store_int(&ibs_pcpu[cpu]->pc_status, IBS_CPU_RUNNING);
-
/*
* Turn on the ENABLE bit. Zeroing out the control register eliminates
* stale valid bits from spurious NMIs and it resets the counter. This
@@ -550,7 +538,7 @@
config2 = pm->pm_md.pm_ibs.ibs_ctl2;
use_alt_disable = (ibs_features & CPUID_IBSID_IBSDIS) != 0;
- atomic_store_int(&ibs_pcpu[cpu]->pc_status, IBS_CPU_STOPPING);
+ atomic_add_int(&ibs_pcpu[cpu]->pc_stopping, 1);
/*
* On Zen 6, ctl2 DISABLE is the authoritative stop switch; skip
@@ -602,7 +590,7 @@
}
}
- atomic_store_int(&ibs_pcpu[cpu]->pc_status, IBS_CPU_STOPPED);
+ atomic_subtract_int(&ibs_pcpu[cpu]->pc_stopping, 1);
return (0);
}
@@ -635,7 +623,11 @@
mpd.pl_mpdata[PMC_MPIDX_FETCH_CTL2] = rdmsr(IBS_FETCH_CTL2);
}
- pmc_process_interrupt_mp(PMC_HR, pm, tf, &mpd);
+ /* Keep IBS stopped until hardclock. */
+ if (pmc_process_interrupt_mp(PMC_HR, pm, tf, &mpd) != 0) {
+ wrmsr(IBS_FETCH_CTL, 0);
+ return;
+ }
wrmsr(IBS_FETCH_CTL, pm->pm_md.pm_ibs.ibs_ctl | IBS_FETCH_CTL_ENABLE);
}
@@ -672,7 +664,11 @@
mpd.pl_mpdata[PMC_MPIDX_OP_CTL2] = rdmsr(IBS_OP_CTL2);
}
- pmc_process_interrupt_mp(PMC_HR, pm, tf, &mpd);
+ /* See pmc_ibs_process_fetch(). */
+ if (pmc_process_interrupt_mp(PMC_HR, pm, tf, &mpd) != 0) {
+ wrmsr(IBS_OP_CTL, 0);
+ return;
+ }
wrmsr(IBS_OP_CTL, pm->pm_md.pm_ibs.ibs_ctl | IBS_OP_CTL_ENABLE);
}
@@ -744,12 +740,9 @@
if (retval > 1)
retval = 1;
- if (retval == 0) {
- // Lets check for a stray NMI when stopping
- if (atomic_load_int(&pac->pc_status) == IBS_CPU_STOPPING) {
- return (1);
- }
- }
+ /* Claim stray NMIs during stop. */
+ if (retval == 0 && atomic_load_int(&pac->pc_stopping) != 0)
+ return (1);
/* The caller updates the interrupt statistics. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 1, 3:33 AM (12 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41651881
Default Alt Text
D61365.1796096004.diff (2 KB)
Attached To
Mode
D61365: hwpmc_ibs: keep stalled units stopped
Attached
Detach File
Event Timeline