Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161872505
D46420.id142378.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D46420.id142378.diff
View Options
Index: sys/dev/hwpmc/hwpmc_core.c
===================================================================
--- sys/dev/hwpmc/hwpmc_core.c
+++ sys/dev/hwpmc/hwpmc_core.c
@@ -1051,7 +1051,7 @@
counter_u64_add(pmc_stats.pm_intr_ignored, 1);
if (found_interrupt)
- lapic_reenable_pmc();
+ lapic_reenable_pcint();
return (found_interrupt);
}
@@ -1150,7 +1150,7 @@
counter_u64_add(pmc_stats.pm_intr_ignored, 1);
if (found_interrupt)
- lapic_reenable_pmc();
+ lapic_reenable_pcint();
/*
* Reenable all non-stalled PMCs.
Index: sys/dev/hwpmc/hwpmc_x86.c
===================================================================
--- sys/dev/hwpmc/hwpmc_x86.c
+++ sys/dev/hwpmc/hwpmc_x86.c
@@ -242,7 +242,7 @@
return (NULL);
/* disallow sampling if we do not have an LAPIC */
- if (md != NULL && !lapic_enable_pmc())
+ if (md != NULL && !lapic_enable_pcint())
for (i = 0; i < md->pmd_nclass; i++) {
if (i == PMC_CLASS_INDEX_SOFT)
continue;
@@ -256,7 +256,7 @@
pmc_md_finalize(struct pmc_mdep *md)
{
- lapic_disable_pmc();
+ lapic_disable_pcint();
if (cpu_vendor_id == CPU_VENDOR_AMD ||
cpu_vendor_id == CPU_VENDOR_HYGON)
pmc_amd_finalize(md);
Index: sys/x86/include/apicvar.h
===================================================================
--- sys/x86/include/apicvar.h
+++ sys/x86/include/apicvar.h
@@ -229,9 +229,9 @@
void apic_disable_vector(u_int apic_id, u_int vector);
void apic_free_vector(u_int apic_id, u_int vector, u_int irq);
void lapic_calibrate_timer(void);
-int lapic_enable_pmc(void);
-void lapic_disable_pmc(void);
-void lapic_reenable_pmc(void);
+int lapic_enable_pcint(void);
+void lapic_disable_pcint(void);
+void lapic_reenable_pcint(void);
void lapic_enable_cmc(void);
int lapic_enable_mca_elvt(void);
void lapic_ipi_raw(register_t icrlo, u_int dest);
Index: sys/x86/x86/local_apic.c
===================================================================
--- sys/x86/x86/local_apic.c
+++ sys/x86/x86/local_apic.c
@@ -36,6 +36,7 @@
#include <sys/cdefs.h>
#include "opt_atpic.h"
#include "opt_hwpmc_hooks.h"
+#include "opt_hwt_hooks.h"
#include "opt_ddb.h"
@@ -50,6 +51,7 @@
#include <sys/mutex.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
+#include <sys/refcount.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
@@ -206,6 +208,7 @@
static int __read_mostly lapic_ds_idle_timeout = 1000000;
#endif
unsigned int max_apic_id;
+static int pcint_refcnt = 0;
SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"APIC options");
@@ -809,20 +812,22 @@
SYSINIT(lapic_intrcnt, SI_SUB_INTR, SI_ORDER_MIDDLE, lapic_intrcnt, NULL);
void
-lapic_reenable_pmc(void)
+lapic_reenable_pcint(void)
{
-#ifdef HWPMC_HOOKS
+#if defined(HWPMC_HOOKS) || defined(HWT_HOOKS)
uint32_t value;
+ if (refcount_load(&pcint_refcnt) == 0)
+ return;
value = lapic_read32(LAPIC_LVT_PCINT);
value &= ~APIC_LVT_M;
lapic_write32(LAPIC_LVT_PCINT, value);
#endif
}
-#ifdef HWPMC_HOOKS
+#if defined(HWPMC_HOOKS) || defined(HWT_HOOKS)
static void
-lapic_update_pmc(void *dummy)
+lapic_update_pcint(void *dummy)
{
struct lapic *la;
@@ -858,9 +863,9 @@
}
int
-lapic_enable_pmc(void)
+lapic_enable_pcint(void)
{
-#ifdef HWPMC_HOOKS
+#if defined(HWPMC_HOOKS) || defined(HWT_HOOKS)
u_int32_t maxlvt;
#ifdef DEV_ATPIC
@@ -873,11 +878,12 @@
maxlvt = (lapic_read32(LAPIC_VERSION) & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
if (maxlvt < APIC_LVT_PMC)
return (0);
-
+ if (refcount_acquire(&pcint_refcnt) > 0)
+ return (1);
lvts[APIC_LVT_PMC].lvt_masked = 0;
MPASS(mp_ncpus == 1 || smp_started);
- smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+ smp_rendezvous(NULL, lapic_update_pcint, NULL, NULL);
return (1);
#else
return (0);
@@ -885,9 +891,9 @@
}
void
-lapic_disable_pmc(void)
+lapic_disable_pcint(void)
{
-#ifdef HWPMC_HOOKS
+#if defined(HWPMC_HOOKS) || defined(HWT_HOOKS)
u_int32_t maxlvt;
#ifdef DEV_ATPIC
@@ -900,14 +906,15 @@
maxlvt = (lapic_read32(LAPIC_VERSION) & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
if (maxlvt < APIC_LVT_PMC)
return;
-
+ if (refcount_release(&pcint_refcnt))
+ return;
lvts[APIC_LVT_PMC].lvt_masked = 1;
#ifdef SMP
/* The APs should always be started when hwpmc is unloaded. */
KASSERT(mp_ncpus == 1 || smp_started, ("hwpmc unloaded too early"));
#endif
- smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+ smp_rendezvous(NULL, lapic_update_pcint, NULL, NULL);
#endif
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 8, 3:00 PM (4 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34848732
Default Alt Text
D46420.id142378.diff (4 KB)
Attached To
Mode
D46420: x86: Allow sharing of perfomance counter interrupts
Attached
Detach File
Event Timeline
Log In to Comment