Skip to contentSkip to conversation

perf, pt: Intel PT updates

PATCH In review Alexander Shishkin 3 participants 9 messages Apr 28, 2016 – May 5, 2016

Subsystems (2)
lore
Share & tools
lore
author reviewer
#1 lore raw

PATCH 1/3 perf/x86/intel/pt: Convert ACCESS_ONCE()s

In reply to Alexander Shishkin

This patch converts remaining ACCESS_ONCE() instances into READ_ONCE() and WRITE_ONCE() as appropriate.

---
 arch/x86/events/intel/pt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/intel/pt.c +3 -3
index 05ef87d839..e88915ff98 100644
@@ -933,7 +933,7 @@ void intel_pt_interrupt(void)
 	 * after PT has been disabled by pt_event_stop(). Make sure we don't
 	 * do anything (particularly, re-enable) for this event here.
 	 */
-	if (!ACCESS_ONCE(pt->handle_nmi))
+	if (!READ_ONCE(pt->handle_nmi))
 		return;
 
 	/*
@@ -1035,7 +1035,7 @@ static void pt_event_start(struct perf_event *event, int mode)
 			goto fail_end_stop;
 	}
 
-	ACCESS_ONCE(pt->handle_nmi) = 1;
+	WRITE_ONCE(pt->handle_nmi, 1);
 	hwc->state = 0;
 
 	pt_config_buffer(buf->cur->table, buf->cur_idx,
@@ -1058,7 +1058,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
 	 * Protect against the PMI racing with disabling wrmsr,
 	 * see comment in intel_pt_interrupt().
 	 */
-	ACCESS_ONCE(pt->handle_nmi) = 0;
+	WRITE_ONCE(pt->handle_nmi, 0);
 
 	pt_config_stop(event);
 
Signature · 1 line
2.8.0.rc3
author reviewer
#3 lore raw

PATCH 2/3 perf/x86/intel/pt: Export cpu frequency ratios needed by PT decoders

In reply to Alexander Shishkin

In order for Intel PT decoders to infer correct crystal clock and bus frequencies that are required to correctly decode timing information from a PT stream (MTC and CBR packets), export them as sysfs attributes:

* max_nonturbo_ratio: ratio between the invariant TSC and base clock;
* tsc_art_ratio: TSC to core crystal clock ratio.

---
 arch/x86/events/intel/pt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/events/intel/pt.h |  6 ++++++
 2 files changed, 60 insertions(+)
arch/x86/events/intel/pt.c +54 -0
index e88915ff98..bf0b0fe33d 100644
@@ -125,9 +125,46 @@ static struct attribute_group pt_format_group = {
 	.attrs	= pt_formats_attr,
 };
 
+static ssize_t
+pt_timing_attr_show(struct device *dev, struct device_attribute *attr,
+		    char *page)
+{
+	struct perf_pmu_events_attr *pmu_attr =
+		container_of(attr, struct perf_pmu_events_attr, attr);
+
+	switch (pmu_attr->id) {
+	case 0:
+		return sprintf(page, "%lu\n", pt_pmu.max_nonturbo_ratio);
+	case 1:
+		return sprintf(page, "%u:%u\n",
+			       pt_pmu.tsc_art_num,
+			       pt_pmu.tsc_art_den);
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
+PMU_EVENT_ATTR(max_nonturbo_ratio, timing_attr_max_nonturbo_ratio, 0,
+	       pt_timing_attr_show);
+PMU_EVENT_ATTR(tsc_art_ratio, timing_attr_tsc_art_ratio, 1,
+	       pt_timing_attr_show);
+
+static struct attribute *pt_timing_attr[] = {
+	&timing_attr_max_nonturbo_ratio.attr.attr,
+	&timing_attr_tsc_art_ratio.attr.attr,
+	NULL,
+};
+
+static struct attribute_group pt_timing_group = {
+	.attrs	= pt_timing_attr,
+};
+
 static const struct attribute_group *pt_attr_groups[] = {
 	&pt_cap_group,
 	&pt_format_group,
+	&pt_timing_group,
 	NULL,
 };
 
@@ -140,6 +177,23 @@ static int __init pt_pmu_hw_init(void)
 	int ret;
 	long i;
 
+	rdmsrl(MSR_PLATFORM_INFO, reg);
+	pt_pmu.max_nonturbo_ratio = (reg & 0xff00) >> 8;
+
+	/*
+	 * if available, read in TSC to core crystal clock ratio,
+	 * otherwise, zero for numerator stands for "not enumerated"
+	 * as per SDM
+	 */
+	if (boot_cpu_data.cpuid_level >= CPUID_TSC_LEAF) {
+		u32 eax, ebx, ecx, edx;
+
+		cpuid(CPUID_TSC_LEAF, &eax, &ebx, &ecx, &edx);
+
+		pt_pmu.tsc_art_num = ebx;
+		pt_pmu.tsc_art_den = eax;
+	}
+
 	if (boot_cpu_has(X86_FEATURE_VMX)) {
 		/*
 		 * Intel SDM, 36.5 "Tracing post-VMXON" says that
arch/x86/events/intel/pt.h +6 -0
index 3abb5f5ccc..e5385b1fa0 100644
@@ -48,6 +48,9 @@ struct topa_entry {
 #define PT_CPUID_LEAVES		2
 #define PT_CPUID_REGS_NUM	4 /* number of regsters (eax, ebx, ecx, edx) */
 
+/* TSC to Core Crystal Clock Ratio */
+#define CPUID_TSC_LEAF		0x15
+
 enum pt_capabilities {
 	PT_CAP_max_subleaf = 0,
 	PT_CAP_cr3_filtering,
@@ -66,6 +69,9 @@ struct pt_pmu {
 	struct pmu		pmu;
 	u32			caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];
 	bool			vmx;
+	unsigned long		max_nonturbo_ratio;
+	unsigned int		tsc_art_num;
+	unsigned int		tsc_art_den;
 };
 
 /**
Signature · 1 line
2.8.0.rc3
author reviewer
#7 lore raw

PATCH 3/3 perf, x86: Bypass PT vs LBR exclusivity if the core supports it

In reply to Alexander Shishkin

Not all cores prevent using Intel PT and LBRs simultaneously, although most of them still do as of today. This patch adds an opt-in flag for such cores to disable mutual exclusivity between PT and LBR; also flip it on for Goldmont.

---
 arch/x86/events/core.c       | 6 ++++++
 arch/x86/events/intel/core.c | 1 +
 arch/x86/events/perf_event.h | 1 +
 3 files changed, 8 insertions(+)
arch/x86/events/core.c +6 -0
index 41d93d0e97..5e5e76a52f 100644
@@ -360,6 +360,9 @@ int x86_add_exclusive(unsigned int what)
 {
 	int i;
 
+	if (x86_pmu.lbr_pt_coexist)
+		return 0;
+
 	if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) {
 		mutex_lock(&pmc_reserve_mutex);
 		for (i = 0; i < ARRAY_SIZE(x86_pmu.lbr_exclusive); i++) {
@@ -380,6 +383,9 @@ fail_unlock:
 
 void x86_del_exclusive(unsigned int what)
 {
+	if (x86_pmu.lbr_pt_coexist)
+		return;
+
 	atomic_dec(&x86_pmu.lbr_exclusive[what]);
 	atomic_dec(&active_events);
 }
arch/x86/events/intel/core.c +1 -0
index 79b59437f5..e36422c687 100644
@@ -3609,6 +3609,7 @@ __init int intel_pmu_init(void)
 		 */
 		x86_pmu.pebs_aliases = NULL;
 		x86_pmu.pebs_prec_dist = true;
+		x86_pmu.lbr_pt_coexist = true;
 		x86_pmu.flags |= PMU_FL_HAS_RSP_1;
 		pr_cont("Goldmont events, ");
 		break;
arch/x86/events/perf_event.h +1 -0
index 7d62a02f49..8bd764df81 100644
@@ -601,6 +601,7 @@ struct x86_pmu {
 	u64		lbr_sel_mask;		   /* LBR_SELECT valid bits */
 	const int	*lbr_sel_map;		   /* lbr_select mappings */
 	bool		lbr_double_abort;	   /* duplicated lbr aborts */
+	bool		lbr_pt_coexist;		   /* LBR may coexist with PT */
 
 	/*
 	 * Intel PT/LBR/BTS are exclusive
Signature · 1 line
2.8.0.rc3

Alexander Shishkin

author reviewer
#0 lore raw

cover perf, pt: Intel PT updates

Hi Peter,

Here are some patches for Intel PT driver, should all be self-evident. 2/3 has been posted before in a slightly different form, but it's been quite a while and everybody should have forgotten it by now.

Alexander Shishkin (3):
perf/x86/intel/pt: Convert ACCESS_ONCE()s perf/x86/intel/pt: Export cpu frequency ratios needed by PT decoders perf, x86: Bypass PT vs LBR exclusivity if the core supports it

 arch/x86/events/core.c       |  6 +++++
 arch/x86/events/intel/core.c |  1 +
 arch/x86/events/intel/pt.c   | 60 +++++++++++++++++++++++++++++++++++++++++---
 arch/x86/events/intel/pt.h   |  6 +++++
 arch/x86/events/perf_event.h |  1 +
 5 files changed, 71 insertions(+), 3 deletions(-)
Signature · 1 line
2.8.0.rc3
author reviewer
#4 lore raw

Re: [PATCH v0 2/3] perf/x86/intel/pt: Export cpu frequency ratios needed by PT decoders

In reply to Alexander Shishkin
Quoted 8 lines · Alexander Shishkin

In order for Intel PT decoders to infer correct crystal clock and bus frequencies that are required to correctly decode timing information from a PT stream (MTC and CBR packets), export them as sysfs attributes:

* max_nonturbo_ratio: ratio between the invariant TSC and base clock;
* tsc_art_ratio: TSC to core crystal clock ratio.

With a slightly better changelog:

Quoted 1 line

From d0fbc4e45fb633e464cbbd61d6aacd5a476fd50d Mon Sep 17 00:00:00 2001

From: Alexander Shishkin <[email protected]>
Date: Wed, 19 Aug 2015 17:02:10 +0300
Subject: [PATCH] perf/x86/intel/pt: Export cpu frequency ratios needed by PT
decoders

Intel PT decoders need access to various bits of timing related information to be able to correctly decode timing packets from a PT stream (MTC and CBR packets). This patch exports all the necessary bits as sysfs attributes for the sake of consistency:

* max_nonturbo_ratio: ratio between the invariant TSC and base clock;
* tsc_art_ratio: TSC to core crystal clock ratio (also available as

    CPUID.15H).
---
 arch/x86/events/intel/pt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/events/intel/pt.h |  6 ++++++
 2 files changed, 60 insertions(+)
arch/x86/events/intel/pt.c +54 -0
index e88915ff98..bf0b0fe33d 100644
@@ -125,9 +125,46 @@ static struct attribute_group pt_format_group = {
 	.attrs	= pt_formats_attr,
 };
 
+static ssize_t
+pt_timing_attr_show(struct device *dev, struct device_attribute *attr,
+		    char *page)
+{
+	struct perf_pmu_events_attr *pmu_attr =
+		container_of(attr, struct perf_pmu_events_attr, attr);
+
+	switch (pmu_attr->id) {
+	case 0:
+		return sprintf(page, "%lu\n", pt_pmu.max_nonturbo_ratio);
+	case 1:
+		return sprintf(page, "%u:%u\n",
+			       pt_pmu.tsc_art_num,
+			       pt_pmu.tsc_art_den);
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
+PMU_EVENT_ATTR(max_nonturbo_ratio, timing_attr_max_nonturbo_ratio, 0,
+	       pt_timing_attr_show);
+PMU_EVENT_ATTR(tsc_art_ratio, timing_attr_tsc_art_ratio, 1,
+	       pt_timing_attr_show);
+
+static struct attribute *pt_timing_attr[] = {
+	&timing_attr_max_nonturbo_ratio.attr.attr,
+	&timing_attr_tsc_art_ratio.attr.attr,
+	NULL,
+};
+
+static struct attribute_group pt_timing_group = {
+	.attrs	= pt_timing_attr,
+};
+
 static const struct attribute_group *pt_attr_groups[] = {
 	&pt_cap_group,
 	&pt_format_group,
+	&pt_timing_group,
 	NULL,
 };
 
@@ -140,6 +177,23 @@ static int __init pt_pmu_hw_init(void)
 	int ret;
 	long i;
 
+	rdmsrl(MSR_PLATFORM_INFO, reg);
+	pt_pmu.max_nonturbo_ratio = (reg & 0xff00) >> 8;
+
+	/*
+	 * if available, read in TSC to core crystal clock ratio,
+	 * otherwise, zero for numerator stands for "not enumerated"
+	 * as per SDM
+	 */
+	if (boot_cpu_data.cpuid_level >= CPUID_TSC_LEAF) {
+		u32 eax, ebx, ecx, edx;
+
+		cpuid(CPUID_TSC_LEAF, &eax, &ebx, &ecx, &edx);
+
+		pt_pmu.tsc_art_num = ebx;
+		pt_pmu.tsc_art_den = eax;
+	}
+
 	if (boot_cpu_has(X86_FEATURE_VMX)) {
 		/*
 		 * Intel SDM, 36.5 "Tracing post-VMXON" says that
arch/x86/events/intel/pt.h +6 -0
index 3abb5f5ccc..e5385b1fa0 100644
@@ -48,6 +48,9 @@ struct topa_entry {
 #define PT_CPUID_LEAVES		2
 #define PT_CPUID_REGS_NUM	4 /* number of regsters (eax, ebx, ecx, edx) */
 
+/* TSC to Core Crystal Clock Ratio */
+#define CPUID_TSC_LEAF		0x15
+
 enum pt_capabilities {
 	PT_CAP_max_subleaf = 0,
 	PT_CAP_cr3_filtering,
@@ -66,6 +69,9 @@ struct pt_pmu {
 	struct pmu		pmu;
 	u32			caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];
 	bool			vmx;
+	unsigned long		max_nonturbo_ratio;
+	unsigned int		tsc_art_num;
+	unsigned int		tsc_art_den;
 };
 
 /**
Signature · 1 line
2.8.0.rc3
maintainer
#6 lore raw

Re: [PATCH v0 2/3] perf/x86/intel/pt: Export cpu frequency ratios needed by PT decoders

In reply to Alexander Shishkin
Quoted 6 lines · Alexander Shishkin

In order for Intel PT decoders to infer correct crystal clock and bus frequencies that are required to correctly decode timing information from a PT stream (MTC and CBR packets), export them as sysfs attributes:

* max_nonturbo_ratio: ratio between the invariant TSC and base clock;
* tsc_art_ratio: TSC to core crystal clock ratio.

I guess new sysfs nodes need to be documented:

Documentation/ABI/...

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#8 lore raw

[tip:perf/core] perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it

In reply to Alexander Shishkin
perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it
Commit-ID:  ccbebba4c6bfda8e3ef9e431ce2c3d91c5fc5a63
Gitweb:     http://git.kernel.org/tip/ccbebba4c6bfda8e3ef9e431ce2c3d91c5fc5a63
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Thu, 28 Apr 2016 18:35:46 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 May 2016 10:16:28 +0200

perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it

Not all cores prevent using Intel PT and LBRs simultaneously, although most of them still do as of today. This patch adds an opt-in flag for such cores to disable mutual exclusivity between PT and LBR; also flip it on for Goldmont.

---
 arch/x86/events/core.c       | 6 ++++++
 arch/x86/events/intel/core.c | 1 +
 arch/x86/events/perf_event.h | 1 +
 3 files changed, 8 insertions(+)
arch/x86/events/core.c +6 -0
index 41d93d0..5e5e76a 100644
@@ -360,6 +360,9 @@ int x86_add_exclusive(unsigned int what)
 {
 	int i;
 
+	if (x86_pmu.lbr_pt_coexist)
+		return 0;
+
 	if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) {
 		mutex_lock(&pmc_reserve_mutex);
 		for (i = 0; i < ARRAY_SIZE(x86_pmu.lbr_exclusive); i++) {
@@ -380,6 +383,9 @@ fail_unlock:
 
 void x86_del_exclusive(unsigned int what)
 {
+	if (x86_pmu.lbr_pt_coexist)
+		return;
+
 	atomic_dec(&x86_pmu.lbr_exclusive[what]);
 	atomic_dec(&active_events);
 }
arch/x86/events/intel/core.c +1 -0
index 90ba3ae..cd31940 100644
@@ -3609,6 +3609,7 @@ __init int intel_pmu_init(void)
 		 */
 		x86_pmu.pebs_aliases = NULL;
 		x86_pmu.pebs_prec_dist = true;
+		x86_pmu.lbr_pt_coexist = true;
 		x86_pmu.flags |= PMU_FL_HAS_RSP_1;
 		pr_cont("Goldmont events, ");
 		break;
arch/x86/events/perf_event.h +1 -0
index 7d62a02..8bd764d 100644
@@ -601,6 +601,7 @@ struct x86_pmu {
 	u64		lbr_sel_mask;		   /* LBR_SELECT valid bits */
 	const int	*lbr_sel_map;		   /* lbr_select mappings */
 	bool		lbr_double_abort;	   /* duplicated lbr aborts */
+	bool		lbr_pt_coexist;		   /* LBR may coexist with PT */
 
 	/*
 	 * Intel PT/LBR/BTS are exclusive
#5 lore raw

[tip:perf/core] perf/x86/intel/pt: Export CPU frequency ratios needed by PT decoders

In reply to Alexander Shishkin
perf/x86/intel/pt: Export CPU frequency ratios needed by PT decoders
Commit-ID:  65c7e6f1c4810e9bce935520f44f6d2613cd1b40
Gitweb:     http://git.kernel.org/tip/65c7e6f1c4810e9bce935520f44f6d2613cd1b40
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Wed, 19 Aug 2015 17:02:10 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 May 2016 10:16:28 +0200

perf/x86/intel/pt: Export CPU frequency ratios needed by PT decoders

Intel PT decoders need access to various bits of timing related information to be able to correctly decode timing packets from a PT stream (MTC and CBR packets). This patch exports all the necessary bits as sysfs attributes for the sake of consistency:

* max_nonturbo_ratio: ratio between the invariant TSC and base clock;

* tsc_art_ratio: TSC to core crystal clock ratio (also available as CPUID.15H).

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
---
 arch/x86/events/intel/pt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/events/intel/pt.h |  6 ++++++
 2 files changed, 60 insertions(+)
arch/x86/events/intel/pt.c +54 -0
index 2d1ce2c..c3a359c 100644
@@ -127,9 +127,46 @@ static struct attribute_group pt_format_group = {
 	.attrs	= pt_formats_attr,
 };
 
+static ssize_t
+pt_timing_attr_show(struct device *dev, struct device_attribute *attr,
+		    char *page)
+{
+	struct perf_pmu_events_attr *pmu_attr =
+		container_of(attr, struct perf_pmu_events_attr, attr);
+
+	switch (pmu_attr->id) {
+	case 0:
+		return sprintf(page, "%lu\n", pt_pmu.max_nonturbo_ratio);
+	case 1:
+		return sprintf(page, "%u:%u\n",
+			       pt_pmu.tsc_art_num,
+			       pt_pmu.tsc_art_den);
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
+PMU_EVENT_ATTR(max_nonturbo_ratio, timing_attr_max_nonturbo_ratio, 0,
+	       pt_timing_attr_show);
+PMU_EVENT_ATTR(tsc_art_ratio, timing_attr_tsc_art_ratio, 1,
+	       pt_timing_attr_show);
+
+static struct attribute *pt_timing_attr[] = {
+	&timing_attr_max_nonturbo_ratio.attr.attr,
+	&timing_attr_tsc_art_ratio.attr.attr,
+	NULL,
+};
+
+static struct attribute_group pt_timing_group = {
+	.attrs	= pt_timing_attr,
+};
+
 static const struct attribute_group *pt_attr_groups[] = {
 	&pt_cap_group,
 	&pt_format_group,
+	&pt_timing_group,
 	NULL,
 };
 
@@ -142,6 +179,23 @@ static int __init pt_pmu_hw_init(void)
 	int ret;
 	long i;
 
+	rdmsrl(MSR_PLATFORM_INFO, reg);
+	pt_pmu.max_nonturbo_ratio = (reg & 0xff00) >> 8;
+
+	/*
+	 * if available, read in TSC to core crystal clock ratio,
+	 * otherwise, zero for numerator stands for "not enumerated"
+	 * as per SDM
+	 */
+	if (boot_cpu_data.cpuid_level >= CPUID_TSC_LEAF) {
+		u32 eax, ebx, ecx, edx;
+
+		cpuid(CPUID_TSC_LEAF, &eax, &ebx, &ecx, &edx);
+
+		pt_pmu.tsc_art_num = ebx;
+		pt_pmu.tsc_art_den = eax;
+	}
+
 	if (boot_cpu_has(X86_FEATURE_VMX)) {
 		/*
 		 * Intel SDM, 36.5 "Tracing post-VMXON" says that
arch/x86/events/intel/pt.h +6 -0
index ca64599..efffa4a 100644
@@ -82,6 +82,9 @@ struct topa_entry {
 #define PT_CPUID_LEAVES		2
 #define PT_CPUID_REGS_NUM	4 /* number of regsters (eax, ebx, ecx, edx) */
 
+/* TSC to Core Crystal Clock Ratio */
+#define CPUID_TSC_LEAF		0x15
+
 enum pt_capabilities {
 	PT_CAP_max_subleaf = 0,
 	PT_CAP_cr3_filtering,
@@ -102,6 +105,9 @@ struct pt_pmu {
 	struct pmu		pmu;
 	u32			caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];
 	bool			vmx;
+	unsigned long		max_nonturbo_ratio;
+	unsigned int		tsc_art_num;
+	unsigned int		tsc_art_den;
 };
 
 /**
#2 lore raw

[tip:perf/core] perf/x86/intel/pt: Convert ACCESS_ONCE()s

In reply to Alexander Shishkin
perf/x86/intel/pt: Convert ACCESS_ONCE()s
Commit-ID:  1b6de5917172967acd8db4d222df4225d23a8a60
Gitweb:     http://git.kernel.org/tip/1b6de5917172967acd8db4d222df4225d23a8a60
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Thu, 28 Apr 2016 18:35:44 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 May 2016 10:16:29 +0200

perf/x86/intel/pt: Convert ACCESS_ONCE()s

This patch converts remaining ACCESS_ONCE() instances into READ_ONCE() and WRITE_ONCE() as appropriate.

---
 arch/x86/events/intel/pt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/intel/pt.c +3 -3
index c3a359c..54fa238 100644
@@ -1135,7 +1135,7 @@ void intel_pt_interrupt(void)
 	 * after PT has been disabled by pt_event_stop(). Make sure we don't
 	 * do anything (particularly, re-enable) for this event here.
 	 */
-	if (!ACCESS_ONCE(pt->handle_nmi))
+	if (!READ_ONCE(pt->handle_nmi))
 		return;
 
 	/*
@@ -1237,7 +1237,7 @@ static void pt_event_start(struct perf_event *event, int mode)
 			goto fail_end_stop;
 	}
 
-	ACCESS_ONCE(pt->handle_nmi) = 1;
+	WRITE_ONCE(pt->handle_nmi, 1);
 	hwc->state = 0;
 
 	pt_config_buffer(buf->cur->table, buf->cur_idx,
@@ -1260,7 +1260,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
 	 * Protect against the PMI racing with disabling wrmsr,
 	 * see comment in intel_pt_interrupt().
 	 */
-	ACCESS_ONCE(pt->handle_nmi) = 0;
+	WRITE_ONCE(pt->handle_nmi, 0);
 
 	pt_config_stop(event);