Skip to contentSkip to conversation

x86/perf: Add hardware performance events support for Zhaoxin CPU.

PATCH In review CodyYao-oc 4 participants 5 messages Mar 31, 2020 – Apr 8, 2020

Subsystems (2)
lore
Share & tools
lore

CodyYao-oc

author
#0 lore raw

PATCH 1/1 x86/perf: Add hardware performance events support for Zhaoxin CPU.

Zhaoxin CPU has provided facilities for monitoring performance via PMU(Performance Monitor Unit), but the functionality is unused so far. Therefore, add support for zhaoxin pmu to make performance related hardware events available.

---
 arch/x86/events/Makefile               |   2 +
 arch/x86/events/core.c                 |   4 +
 arch/x86/events/perf_event.h           |   9 +
 arch/x86/events/zhaoxin/Makefile       |   2 +
 arch/x86/events/zhaoxin/core.c         | 618 +++++++++++++++++++++++++++++++++
 arch/x86/kernel/cpu/perfctr-watchdog.c |   6 +
 6 files changed, 641 insertions(+)
 create mode 100644 arch/x86/events/zhaoxin/Makefile
 create mode 100644 arch/x86/events/zhaoxin/core.c
arch/x86/events/Makefile +2 -0
index 9e07f55..6f1d1fd 100644
@@ -3,3 +3,5 @@ obj-y					+= core.o probe.o
 obj-y					+= amd/
 obj-$(CONFIG_X86_LOCAL_APIC)            += msr.o
 obj-$(CONFIG_CPU_SUP_INTEL)		+= intel/
+obj-$(CONFIG_CPU_SUP_CENTAUR)		+= zhaoxin/
+obj-$(CONFIG_CPU_SUP_ZHAOXIN)		+= zhaoxin/
arch/x86/events/core.c +4 -0
index 3bb738f..e76048e 100644
@@ -1839,6 +1839,10 @@ static int __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		x86_pmu.name = "HYGON";
 		break;
+	case X86_VENDOR_ZHAOXIN:
+	case X86_VENDOR_CENTAUR:
+		err = zhaoxin_pmu_init();
+		break;
 	default:
 		err = -ENOTSUPP;
 	}
arch/x86/events/perf_event.h +9 -0
index f1cd1ca..f6bbdca 100644
@@ -1133,3 +1133,12 @@ static inline int is_ht_workaround_enabled(void)
 	return 0;
 }
 #endif /* CONFIG_CPU_SUP_INTEL */
+
+#if ((defined CONFIG_CPU_SUP_CENTAUR) || (defined CONFIG_CPU_SUP_ZHAOXIN))
+int zhaoxin_pmu_init(void);
+#else
+static inline int zhaoxin_pmu_init(void)
+{
+	return 0;
+}
+#endif /*CONFIG_CPU_SUP_CENTAUR or CONFIG_CPU_SUP_ZHAOXIN*/
arch/x86/events/zhaoxin/Makefile new file +2 -0
new file mode 100644
index 0000000..642c1174
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y	+= core.o
arch/x86/events/zhaoxin/core.c new file +618 -0

618 lines not on this page · raw message

arch/x86/kernel/cpu/perfctr-watchdog.c +6 -0
index 9556930..63a5828 100644
@@ -63,6 +63,9 @@ static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr)
 		case 15:
 			return msr - MSR_P4_BPU_PERFCTR0;
 		}
+	case X86_VENDOR_ZHAOXIN:
+	case X86_VENDOR_CENTAUR:
+		return msr - MSR_ARCH_PERFMON_PERFCTR0;
 	}
 	return 0;
 }
@@ -92,6 +95,9 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
 		case 15:
 			return msr - MSR_P4_BSU_ESCR0;
 		}
+	case X86_VENDOR_ZHAOXIN:
+	case X86_VENDOR_CENTAUR:
+		return msr - MSR_ARCH_PERFMON_EVENTSEL0;
 	}
 	return 0;
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 4 lines · CodyYao-oc

Zhaoxin CPU has provided facilities for monitoring performance via PMU(Performance Monitor Unit), but the functionality is unused so far. Therefore, add support for zhaoxin pmu to make performance related hardware events available.

This looks like an Intel Architectural PMU v2 or so, is that correct? Do you have a link to documentation for your CPU?

Quoted 44 lines
arch/x86/events/zhaoxin/core.c new file +43 -0
+static void zhaoxin_pmu_disable_all(void)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
+}
+
+static void zhaoxin_pmu_enable_all(int added)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
+}
+
+static inline u64 zhaoxin_pmu_get_status(void)
+{
+	u64 status;
+
+	rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
+
+	return status;
+}
+
+static inline void zhaoxin_pmu_ack_status(u64 ack)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, ack);
+}
 
+static int zhaoxin_pmu_handle_irq(struct pt_regs *regs)
+{
+	struct perf_sample_data data;
+	struct cpu_hw_events *cpuc;
+	int bit;
+	u64 status;
+	bool is_zxc;
+	int handled = 0;
+
+	cpuc = this_cpu_ptr(&cpu_hw_events);
+	apic_write(APIC_LVTPC, APIC_DM_NMI);
+	zhaoxin_pmu_disable_all();
+	status = zhaoxin_pmu_get_status();
+	if (!status)
+		goto done;
+
+	if (boot_cpu_data.x86 == 0x06 &&
+		(boot_cpu_data.x86_model == 0x0f ||
+			boot_cpu_data.x86_model == 0x19))
+		is_zxc = true;

arch/x86/events/zhaoxin/core.c

Quoted 10 lines
arch/x86/events/zhaoxin/core.c new file +10 -0
+again:
+
+	/*Clearing status works only if the global control is enable on zxc.*/
+	if (is_zxc)
+		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
+
+	zhaoxin_pmu_ack_status(status);
+
+	if (is_zxc)
+		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);

That's an unfortunate errata; perhaps write it like so:

static inline void zxc_pmu_ack_status(u64 status)

{
	/*
	 * ZXC needs global control enabled in order to clear status bits.
	 */
	zhaoxin_pmu_enable_all(0);
	zhaoxin_pmu_ack_status(status);
	zhaoxin_pmu_disable_all();
}
	if (is_zxc)
		zxc_pmu_ack_status(status);
	else
		zhaoxin_pmu_ack_status(status);

Alternatively; you can do a whole zxc specific handle_irq() and move the get/ack status before disable_all(). If you do that, then factor this:

Quoted 16 lines
arch/x86/events/zhaoxin/core.c new file +16 -0
+	/*
+	 * CondChgd bit 63 doesn't mean any overflow status. Ignore
+	 * and clear the bit.
+	 */
+	if (__test_and_clear_bit(63, (unsigned long *)&status)) {
+		if (!status)
+			goto done;
+	}
+
+	for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
+		struct perf_event *event = cpuc->events[bit];
+
+		handled++;
+
+		if (!test_bit(bit, cpuc->active_mask))
+			continue;

arch/x86/events/zhaoxin/core.c line 404

Quoted 10 lines
arch/x86/events/zhaoxin/core.c new file +10 -0
+
+		x86_perf_event_update(event);
+		perf_sample_data_init(&data, 0, event->hw.last_period);
+
+		if (!x86_perf_event_set_period(event))
+			continue;
+
+		if (perf_event_overflow(event, &data, regs))
+			x86_pmu_stop(event, 0);
+	}

bit into it's own function so you don't have to duplicate it. Then the two handle_irq() functions only differ in the status handling.

Quoted 12 lines
arch/x86/events/zhaoxin/core.c new file +12 -0
+
+	/*
+	 * Repeat if there is more work to be done:
+	 */
+	status = zhaoxin_pmu_get_status();
+	if (status)
+		goto again;
+
+done:
+	zhaoxin_pmu_enable_all(0);
+	return handled;
+}
author
#2 lore raw
Quoted 9 lines · Peter Zijlstra
Quoted 4 lines · CodyYao-oc

Zhaoxin CPU has provided facilities for monitoring performance via PMU(Performance Monitor Unit), but the functionality is unused so far. Therefore, add support for zhaoxin pmu to make performance related hardware events available.

This looks like an Intel Architectural PMU v2 or so, is that correct? Do you have a link to documentation for your CPU?

I'm sorry for such a late reply. Yes, the usage method is the same as Intel PMU v2, but there is no online document at present. For your convenience, provide some event descriptions as follows:

-----------------------------------------------------------------------------------------------------------------------------------

Event                      | Event  | Umask |          Description
                           | Select |       |
-----------------------------------------------------------------------------------------------------------------------------------
cpu-cycles                 |  82h   |  00h  | unhalt core clock
instructions               |  00h   |  00h  | number of instructions at retirement.
cache-references           |  15h   |  05h  | number of fillq pushs at the current cycle.
cache-misses               |  1ah   |  05h  | number of l2 miss pushed by fillq.
branch-instructions        |  28h   |  00h  | counts the number of branch instructions retired.
branch-misses              |  29h   |  00h  | mispredicted branch instructions at retirement.
bus-cycles                 |  83h   |  00h  | unhalt bus clock
stalled-cycles-frontend    |  01h   |  01h  | Increments each cycle the # of Uops issued by the RAT to RS.
stalled-cycles-backend     |  0fh   |  04h  | RS0/1/2/3/45 empty
L1-dcache-loads            |  68h   |  05h  | number of retire/commit load.
L1-dcache-load-misses      |  4bh   |  05h  | retired load uops whose data source followed an L1 miss.
L1-dcache-stores           |  69h   |  06h  | number of retire/commit Store,no LEA
L1-dcache-store-misses     |  62h   |  05h  | cache lines in M state evicted out of L1D due to Snoop HitM or dirty line replacement.
L1-icache-loads            |  00h   |  03h  | number of l1i cache access for valid normal fetch,including un-cacheable access.
L1-icache-load-misses      |  01h   |  03h  | number of l1i cache miss for valid normal fetch,including un-cacheable miss.
L1-icache-prefetches       |  0ah   |  03h  | number of prefetch.
L1-icache-prefetch-misses  |  0bh   |  03h  | number of prefetch miss.
dTLB-loads                 |  68h   |  05h  | number of retire/commit load
dTLB-load-misses           |  2ch   |  05h  | number of load operations miss all level tlbs and cause a tablewalk.
dTLB-stores                |  69h   |  06h  | number of retire/commit Store,no LEA
dTLB-store-misses          |  30h   |  05h  | number of store operations miss all level tlbs and cause a tablewalk.
dTLB-prefetches            |  64h   |  05h  | number of hardware pte prefetch requests dispatched out of the prefetch FIFO.
dTLB-prefetch-misses       |  65h   |  05h  | number of hardware pte prefetch requests miss the l1d data cache.
iTLB-load                  |  00h   |  00h  | actually counter instructions.
iTLB-load-misses           |  34h   |  05h  | number of code operations miss all level tlbs and cause a tablewalk.

-----------------------------------------------------------------------------------------------------------------------------------

Quoted 48 lines
Quoted 48 lines
arch/x86/events/zhaoxin/core.c new file +47 -0
+static void zhaoxin_pmu_disable_all(void)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
+}
+
+static void zhaoxin_pmu_enable_all(int added)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
+}
+
+static inline u64 zhaoxin_pmu_get_status(void)
+{
+	u64 status;
+
+	rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
+
+	return status;
+}
+
+static inline void zhaoxin_pmu_ack_status(u64 ack)
+{
+	wrmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, ack);
+}
 
+static int zhaoxin_pmu_handle_irq(struct pt_regs *regs)
+{
+	struct perf_sample_data data;
+	struct cpu_hw_events *cpuc;
+	int bit;
+	u64 status;
+	bool is_zxc;
+	int handled = 0;
+
+	cpuc = this_cpu_ptr(&cpu_hw_events);
+	apic_write(APIC_LVTPC, APIC_DM_NMI);
+	zhaoxin_pmu_disable_all();
+	status = zhaoxin_pmu_get_status();
+	if (!status)
+		goto done;
+
+	if (boot_cpu_data.x86 == 0x06 &&
+		(boot_cpu_data.x86_model == 0x0f ||
+			boot_cpu_data.x86_model == 0x19))
+		is_zxc = true;
+again:
+
+	/*Clearing status works only if the global control is enable on zxc.*/
+	if (is_zxc)
Quoted 9 lines

arch/x86/events/zhaoxin/core.c line 375

Quoted 6 lines
arch/x86/events/zhaoxin/core.c new file +6 -0
+		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
+
+	zhaoxin_pmu_ack_status(status);
+
+	if (is_zxc)
+		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);

That's an unfortunate errata; perhaps write it like so:

Thank you very much for your advice, I have changed the code.

Quoted 62 lines

static inline void zxc_pmu_ack_status(u64 status)

{
	/*
	 * ZXC needs global control enabled in order to clear status bits.
	 */
	zhaoxin_pmu_enable_all(0);
	zhaoxin_pmu_ack_status(status);
	zhaoxin_pmu_disable_all();
}
	if (is_zxc)
		zxc_pmu_ack_status(status);
	else
		zhaoxin_pmu_ack_status(status);

Alternatively; you can do a whole zxc specific handle_irq() and move the get/ack status before disable_all(). If you do that, then factor this:

Quoted 16 lines
arch/x86/events/zhaoxin/core.c new file +16 -0
+	/*
+	 * CondChgd bit 63 doesn't mean any overflow status. Ignore
+	 * and clear the bit.
+	 */
+	if (__test_and_clear_bit(63, (unsigned long *)&status)) {
+		if (!status)
+			goto done;
+	}
+
+	for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
+		struct perf_event *event = cpuc->events[bit];
+
+		handled++;
+
+		if (!test_bit(bit, cpuc->active_mask))
+			continue;

arch/x86/events/zhaoxin/core.c line 404

Quoted 10 lines
arch/x86/events/zhaoxin/core.c new file +10 -0
+
+		x86_perf_event_update(event);
+		perf_sample_data_init(&data, 0, event->hw.last_period);
+
+		if (!x86_perf_event_set_period(event))
+			continue;
+
+		if (perf_event_overflow(event, &data, regs))
+			x86_pmu_stop(event, 0);
+	}

bit into it's own function so you don't have to duplicate it. Then the two handle_irq() functions only differ in the status handling.

arch/x86/events/zhaoxin/core.c line 416

Quoted 12 lines
arch/x86/events/zhaoxin/core.c new file +12 -0
+
+	/*
+	 * Repeat if there is more work to be done:
+	 */
+	status = zhaoxin_pmu_get_status();
+	if (status)
+		goto again;
+
+done:
+	zhaoxin_pmu_enable_all(0);
+	return handled;
+}

.

#3 lore raw
In reply to CodyYao-oc
Thank you for the patch! Perhaps something to improve:

Hi CodyYao-oc,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/perf/core]
[also build test WARNING on tip/auto-latest tip/x86/core v5.6 next-20200331] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/CodyYao-oc/x86-perf-Add-hardware-performance-events-support-for-Zhaoxin-CPU/20200331-223205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 629b3df7ecb01fddfdf71cb5d3c563d143117c33
config: x86_64-randconfig-d003-20200331 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 5227fa0c72ce55927cf4849160acb00442489937)

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

>> arch/x86/events/zhaoxin/core.c:362:6: warning: variable 'is_zxc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (boot_cpu_data.x86 == 0x06 &&
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/events/zhaoxin/core.c:369:6: note: uninitialized use occurs here
           if (is_zxc)
               ^~~~~~
   arch/x86/events/zhaoxin/core.c:362:2: note: remove the 'if' if its condition is always true
           if (boot_cpu_data.x86 == 0x06 &&
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86/events/zhaoxin/core.c:362:6: warning: variable 'is_zxc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
           if (boot_cpu_data.x86 == 0x06 &&
               ^~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/events/zhaoxin/core.c:369:6: note: uninitialized use occurs here
           if (is_zxc)
               ^~~~~~
   arch/x86/events/zhaoxin/core.c:362:6: note: remove the '&&' if its condition is always true
           if (boot_cpu_data.x86 == 0x06 &&
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/events/zhaoxin/core.c:352:13: note: initialize the variable 'is_zxc' to silence this warning
           bool is_zxc;
                      ^
                       = 0

2 warnings generated.

vim +362 arch/x86/events/zhaoxin/core.c

341
342 /*
343 * This handler is triggered by the local APIC, so the APIC IRQ handling
344 * rules apply:
345 */
346 static int zhaoxin_pmu_handle_irq(struct pt_regs *regs)
347 {
348 struct perf_sample_data data;
349 struct cpu_hw_events *cpuc;
350 int bit;
351 u64 status;
352 bool is_zxc;
353 int handled = 0;
354
355 cpuc = this_cpu_ptr(&cpu_hw_events);
356 apic_write(APIC_LVTPC, APIC_DM_NMI);
357 zhaoxin_pmu_disable_all();
358 status = zhaoxin_pmu_get_status();
359 if (!status)
360 goto done;
361

 > 362		if (boot_cpu_data.x86 == 0x06 &&

363 (boot_cpu_data.x86_model == 0x0f ||
364 boot_cpu_data.x86_model == 0x19))
365 is_zxc = true;
366 again:
367
368 /*Clearing status works only if the global control is enable on zxc.*/
369 if (is_zxc)
370 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
371
372 zhaoxin_pmu_ack_status(status);
373
374 if (is_zxc)
375 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
376
377 inc_irq_stat(apic_perf_irqs);
378
379 /*
380 * CondChgd bit 63 doesn't mean any overflow status. Ignore
381 * and clear the bit.
382 */
383 if (__test_and_clear_bit(63, (unsigned long *)&status)) {
384 if (!status)
385 goto done;
386 }
387
388 for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
389 struct perf_event *event = cpuc->events[bit];
390
391 handled++;
392
393 if (!test_bit(bit, cpuc->active_mask))
394 continue;
395
396 x86_perf_event_update(event);
397 perf_sample_data_init(&data, 0, event->hw.last_period);
398
399 if (!x86_perf_event_set_period(event))
400 continue;
401
402 if (perf_event_overflow(event, &data, regs))
403 x86_pmu_stop(event, 0);
404 }
405
406 /*
407 * Repeat if there is more work to be done:
408 */
409 status = zhaoxin_pmu_get_status();
410 if (status)
411 goto again;
412
413 done:
414 zhaoxin_pmu_enable_all(0);
415 return handled;
416 }
417

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#4 lore raw
In reply to CodyYao-oc

Hi CodyYao-oc,

Thank you for the patch! Perhaps something to improve:

url:    https://github.com/0day-ci/linux/commits/CodyYao-oc/x86-perf-Add-hardware-performance-events-support-for-Zhaoxin-CPU/20200331-223205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 629b3df7ecb01fddfdf71cb5d3c563d143117c33

If you fix the issue, kindly add following tag

smatch warnings:
arch/x86/events/zhaoxin/core.c:369 zhaoxin_pmu_handle_irq() error: uninitialized symbol 'is_zxc'.

# https://github.com/0day-ci/linux/commit/41b71fb039d254422d4d46c8e7beef30c11c9d39
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 41b71fb039d254422d4d46c8e7beef30c11c9d39
vim +/is_zxc +369 arch/x86/events/zhaoxin/core.c

41b71fb039d254 CodyYao-oc 2020-03-31  346  static int zhaoxin_pmu_handle_irq(struct pt_regs *regs)
41b71fb039d254 CodyYao-oc 2020-03-31  347  {
41b71fb039d254 CodyYao-oc 2020-03-31  348  	struct perf_sample_data data;
41b71fb039d254 CodyYao-oc 2020-03-31  349  	struct cpu_hw_events *cpuc;
41b71fb039d254 CodyYao-oc 2020-03-31  350  	int bit;
41b71fb039d254 CodyYao-oc 2020-03-31  351  	u64 status;
41b71fb039d254 CodyYao-oc 2020-03-31  352  	bool is_zxc;
                                                ^^^^^^^^^^^

bool is_zxc = false;

41b71fb039d254 CodyYao-oc 2020-03-31  353  	int handled = 0;
41b71fb039d254 CodyYao-oc 2020-03-31  354  
41b71fb039d254 CodyYao-oc 2020-03-31  355  	cpuc = this_cpu_ptr(&cpu_hw_events);
41b71fb039d254 CodyYao-oc 2020-03-31  356  	apic_write(APIC_LVTPC, APIC_DM_NMI);
41b71fb039d254 CodyYao-oc 2020-03-31  357  	zhaoxin_pmu_disable_all();
41b71fb039d254 CodyYao-oc 2020-03-31  358  	status = zhaoxin_pmu_get_status();
41b71fb039d254 CodyYao-oc 2020-03-31  359  	if (!status)
41b71fb039d254 CodyYao-oc 2020-03-31  360  		goto done;
41b71fb039d254 CodyYao-oc 2020-03-31  361  
41b71fb039d254 CodyYao-oc 2020-03-31  362  	if (boot_cpu_data.x86 == 0x06 &&
41b71fb039d254 CodyYao-oc 2020-03-31  363  		(boot_cpu_data.x86_model == 0x0f ||
41b71fb039d254 CodyYao-oc 2020-03-31  364  			boot_cpu_data.x86_model == 0x19))
41b71fb039d254 CodyYao-oc 2020-03-31  365  		is_zxc = true;
41b71fb039d254 CodyYao-oc 2020-03-31  366  again:
41b71fb039d254 CodyYao-oc 2020-03-31  367  
41b71fb039d254 CodyYao-oc 2020-03-31  368  	/*Clearing status works only if the global control is enable on zxc.*/
41b71fb039d254 CodyYao-oc 2020-03-31 @369  	if (is_zxc)
                                                    ^^^^^^
41b71fb039d254 CodyYao-oc 2020-03-31  370  		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
41b71fb039d254 CodyYao-oc 2020-03-31  371  
41b71fb039d254 CodyYao-oc 2020-03-31  372  	zhaoxin_pmu_ack_status(status);
41b71fb039d254 CodyYao-oc 2020-03-31  373  
41b71fb039d254 CodyYao-oc 2020-03-31  374  	if (is_zxc)
41b71fb039d254 CodyYao-oc 2020-03-31  375  		wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
41b71fb039d254 CodyYao-oc 2020-03-31  376  
41b71fb039d254 CodyYao-oc 2020-03-31  377  	inc_irq_stat(apic_perf_irqs);
41b71fb039d254 CodyYao-oc 2020-03-31  378  
41b71fb039d254 CodyYao-oc 2020-03-31  379  	/*
41b71fb039d254 CodyYao-oc 2020-03-31  380  	 * CondChgd bit 63 doesn't mean any overflow status. Ignore
41b71fb039d254 CodyYao-oc 2020-03-31  381  	 * and clear the bit.
41b71fb039d254 CodyYao-oc 2020-03-31  382  	 */
41b71fb039d254 CodyYao-oc 2020-03-31  383  	if (__test_and_clear_bit(63, (unsigned long *)&status)) {
41b71fb039d254 CodyYao-oc 2020-03-31  384  		if (!status)
41b71fb039d254 CodyYao-oc 2020-03-31  385  			goto done;
41b71fb039d254 CodyYao-oc 2020-03-31  386  	}
41b71fb039d254 CodyYao-oc 2020-03-31  387  
41b71fb039d254 CodyYao-oc 2020-03-31  388  	for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
41b71fb039d254 CodyYao-oc 2020-03-31  389  		struct perf_event *event = cpuc->events[bit];
41b71fb039d254 CodyYao-oc 2020-03-31  390  
41b71fb039d254 CodyYao-oc 2020-03-31  391  		handled++;
41b71fb039d254 CodyYao-oc 2020-03-31  392  
41b71fb039d254 CodyYao-oc 2020-03-31  393  		if (!test_bit(bit, cpuc->active_mask))
41b71fb039d254 CodyYao-oc 2020-03-31  394  			continue;
41b71fb039d254 CodyYao-oc 2020-03-31  395  
41b71fb039d254 CodyYao-oc 2020-03-31  396  		x86_perf_event_update(event);
41b71fb039d254 CodyYao-oc 2020-03-31  397  		perf_sample_data_init(&data, 0, event->hw.last_period);
41b71fb039d254 CodyYao-oc 2020-03-31  398  
41b71fb039d254 CodyYao-oc 2020-03-31  399  		if (!x86_perf_event_set_period(event))
41b71fb039d254 CodyYao-oc 2020-03-31  400  			continue;
41b71fb039d254 CodyYao-oc 2020-03-31  401  
41b71fb039d254 CodyYao-oc 2020-03-31  402  		if (perf_event_overflow(event, &data, regs))
41b71fb039d254 CodyYao-oc 2020-03-31  403  			x86_pmu_stop(event, 0);
41b71fb039d254 CodyYao-oc 2020-03-31  404  	}
41b71fb039d254 CodyYao-oc 2020-03-31  405  
41b71fb039d254 CodyYao-oc 2020-03-31  406  	/*
41b71fb039d254 CodyYao-oc 2020-03-31  407  	 * Repeat if there is more work to be done:
41b71fb039d254 CodyYao-oc 2020-03-31  408  	 */
41b71fb039d254 CodyYao-oc 2020-03-31  409  	status = zhaoxin_pmu_get_status();
41b71fb039d254 CodyYao-oc 2020-03-31  410  	if (status)
41b71fb039d254 CodyYao-oc 2020-03-31  411  		goto again;
41b71fb039d254 CodyYao-oc 2020-03-31  412  
41b71fb039d254 CodyYao-oc 2020-03-31  413  done:
41b71fb039d254 CodyYao-oc 2020-03-31  414  	zhaoxin_pmu_enable_all(0);
41b71fb039d254 CodyYao-oc 2020-03-31  415  	return handled;
41b71fb039d254 CodyYao-oc 2020-03-31  416  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org