Skip to contentSkip to conversation

perf: Kernel updates

PATCH In review Robert Richter 2 participants 11 messages Apr 5, 2012 – Apr 26, 2012

Subsystems (6)
Arm (32-bit) x86 PowerPC perf events +2 more subsystems
lore
Share & tools
lore
#5 lore raw

PATCH 3/4 perf: use static variant of perf_event_overflow in core.c

In reply to Robert Richter

No need to have an additional function layer.

---
 kernel/events/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/core.c +1 -1
index 8833198..e69a57d 100644
@@ -5349,7 +5349,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 
 	if (regs && !perf_exclude_event(event, regs)) {
 		if (!(event->attr.exclude_idle && is_idle_task(current)))
-			if (perf_event_overflow(event, &data, regs))
+			if (__perf_event_overflow(event, 1, &data, regs))
 				ret = HRTIMER_NORESTART;
 	}
 
Signature · 1 line
1.7.8.4
#0 lore raw

cover perf: Kernel updates

Enclosed some changes made while working with the code. Mostly trivial but worth to add.

-Robert

Robert Richter (4):
perf: Trivial cleanup of duplicate code
perf, x86: Fix cmpxchg() usage in amd_put_event_constraints()
perf: use static variant of perf_event_overflow in core.c
perf: Remove PERF_COUNTERS config option

 arch/arm/configs/bcmring_defconfig        |    2 +-
 arch/powerpc/configs/chroma_defconfig     |    2 +-
 arch/powerpc/configs/gamecube_defconfig   |    2 +-
 arch/powerpc/configs/wii_defconfig        |    2 +-
 arch/sh/configs/sh7785lcr_32bit_defconfig |    2 +-
 arch/sparc/configs/sparc64_defconfig      |    2 +-
 arch/x86/kernel/cpu/perf_event.c          |    3 ---
 arch/x86/kernel/cpu/perf_event_amd.c      |    4 +---
 init/Kconfig                              |   14 +-------------
 kernel/events/core.c                      |    2 +-
 10 files changed, 9 insertions(+), 26 deletions(-)
Signature · 1 line
1.7.8.4
#3 lore raw

PATCH 2/4 perf, x86: Fix cmpxchg() usage in amd_put_event_constraints()

Now the return value of cmpxchg() is used to match an event. The change removes the duplicate event comparison and traverses the list until an event was removed. This also fixes the following warning:

arch/x86/kernel/cpu/perf_event_amd.c:170: warning: value computed is not used

---
 arch/x86/kernel/cpu/perf_event_amd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_amd.c +1 -3
index 4be3463..6565226 100644
@@ -210,10 +210,8 @@ static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
 	 * when we come here
 	 */
 	for (i = 0; i < x86_pmu.num_counters; i++) {
-		if (nb->owners[i] == event) {
-			cmpxchg(nb->owners+i, event, NULL);
+		if (cmpxchg(nb->owners + i, event, NULL) == event)
 			break;
-		}
 	}
 }
 
Signature · 1 line
1.7.8.4
#1 lore raw

PATCH 1/4 perf: Trivial cleanup of duplicate code

In reply to Robert Richter

Removing duplicate code.

---
 arch/x86/kernel/cpu/perf_event.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event.c +0 -3
index 56ae3af..16726a9 100644
@@ -485,9 +485,6 @@ static int __x86_pmu_event_init(struct perf_event *event)
 
 	/* mark unused */
 	event->hw.extra_reg.idx = EXTRA_REG_NONE;
-
-	/* mark not used */
-	event->hw.extra_reg.idx = EXTRA_REG_NONE;
 	event->hw.branch_reg.idx = EXTRA_REG_NONE;
 
 	return x86_pmu.hw_config(event);
Signature · 1 line
1.7.8.4
#7 lore raw

PATCH 4/4 perf: Remove PERF_COUNTERS config option

In reply to Robert Richter

Renaming remaining PERF_COUNTERS options into PERF_EVENTS.

Think we can get rid of PERF_COUNTERS now.

---
 arch/arm/configs/bcmring_defconfig        |    2 +-
 arch/powerpc/configs/chroma_defconfig     |    2 +-
 arch/powerpc/configs/gamecube_defconfig   |    2 +-
 arch/powerpc/configs/wii_defconfig        |    2 +-
 arch/sh/configs/sh7785lcr_32bit_defconfig |    2 +-
 arch/sparc/configs/sparc64_defconfig      |    2 +-
 init/Kconfig                              |   14 +-------------
 7 files changed, 7 insertions(+), 19 deletions(-)
arch/arm/configs/bcmring_defconfig +1 -1
index 795374d..9e6a8fe 100644
@@ -11,7 +11,7 @@ CONFIG_KALLSYMS_EXTRA_PASS=y
 # CONFIG_TIMERFD is not set
 # CONFIG_EVENTFD is not set
 # CONFIG_AIO is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
 # CONFIG_COMPAT_BRK is not set
arch/powerpc/configs/chroma_defconfig +1 -1
index acf7fb2..85acd89 100644
@@ -32,7 +32,7 @@ CONFIG_RD_LZMA=y
 CONFIG_INITRAMFS_COMPRESSION_GZIP=y
 CONFIG_KALLSYMS_ALL=y
 CONFIG_EMBEDDED=y
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 CONFIG_PROFILING=y
 CONFIG_OPROFILE=y
 CONFIG_KPROBES=y
arch/powerpc/configs/gamecube_defconfig +1 -1
index e74d3a4..9ef2cc1 100644
@@ -8,7 +8,7 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_EXPERT=y
 # CONFIG_ELF_CORE is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_SLAB=y
 CONFIG_MODULES=y
arch/powerpc/configs/wii_defconfig +1 -1
index 175295f..1e2b7d0 100644
@@ -9,7 +9,7 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_EXPERT=y
 # CONFIG_ELF_CORE is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_SLAB=y
 CONFIG_MODULES=y
arch/sh/configs/sh7785lcr_32bit_defconfig +1 -1
index 7b9c696..9bdcf72 100644
@@ -5,7 +5,7 @@ CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=16
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
arch/sparc/configs/sparc64_defconfig +1 -1
index 3c1e858..9d8521b 100644
@@ -5,7 +5,7 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_LOG_BUF_SHIFT=18
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
init/Kconfig +1 -13
index 3f42cd6..fad58a9 100644
@@ -1165,7 +1165,7 @@ menu "Kernel Performance Events And Counters"
 
 config PERF_EVENTS
 	bool "Kernel performance events and counters"
-	default y if (PROFILING || PERF_COUNTERS)
+	default y if PROFILING
 	depends on HAVE_PERF_EVENTS
 	select ANON_INODES
 	select IRQ_WORK
@@ -1192,18 +1192,6 @@ config PERF_EVENTS
 
 	  Say Y if unsure.
 
-config PERF_COUNTERS
-	bool "Kernel performance counters (old config option)"
-	depends on HAVE_PERF_EVENTS
-	help
-	  This config has been obsoleted by the PERF_EVENTS
-	  config option - please see that one for details.
-
-	  It has no effect on the kernel whether you enable
-	  it or not, it is a compatibility placeholder.
-
-	  Say N if unsure.
-
 config DEBUG_PERF_USE_VMALLOC
 	default n
 	bool "Debug: use vmalloc to back perf mmap() buffers"
Signature · 1 line
1.7.8.4
#9 lore raw
In reply to Robert Richter
Quoted 11 lines · Robert Richter

Enclosed some changes made while working with the code. Mostly trivial but worth to add.

-Robert

Robert Richter (4):
perf: Trivial cleanup of duplicate code
perf, x86: Fix cmpxchg() usage in amd_put_event_constraints()
perf: use static variant of perf_event_overflow in core.c
perf: Remove PERF_COUNTERS config option

Peter,

what's the status of this?

Thanks,

-Robert

Quoted 16 lines
 arch/arm/configs/bcmring_defconfig        |    2 +-
 arch/powerpc/configs/chroma_defconfig     |    2 +-
 arch/powerpc/configs/gamecube_defconfig   |    2 +-
 arch/powerpc/configs/wii_defconfig        |    2 +-
 arch/sh/configs/sh7785lcr_32bit_defconfig |    2 +-
 arch/sparc/configs/sparc64_defconfig      |    2 +-
 arch/x86/kernel/cpu/perf_event.c          |    3 ---
 arch/x86/kernel/cpu/perf_event_amd.c      |    4 +---
 init/Kconfig                              |   14 +-------------
 kernel/events/core.c                      |    2 +-
 10 files changed, 9 insertions(+), 26 deletions(-)
Signature · 1 line
1.7.8.4
Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
maintainer
#10 lore raw
Quoted 5 lines · Robert Richter

Peter,

what's the status of this?

I've got them queued, I'll try and shove them Ingo-wards soon.

Thanks!

#2 lore raw

[tip:perf/core] perf: Trivial cleanup of duplicate code

In reply to Robert Richter
Commit-ID:  10c250234c98928d1e15c4cea1c44b9a25354ccf
Gitweb:     http://git.kernel.org/tip/10c250234c98928d1e15c4cea1c44b9a25354ccf
Author:     Robert Richter <[email protected]>
AuthorDate: Thu, 5 Apr 2012 18:24:41 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Apr 2012 13:52:50 +0200

perf: Trivial cleanup of duplicate code

Removing duplicate code.

---
 arch/x86/kernel/cpu/perf_event.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event.c +0 -3
index bb8e034..e33e9cf 100644
@@ -484,9 +484,6 @@ static int __x86_pmu_event_init(struct perf_event *event)
 
 	/* mark unused */
 	event->hw.extra_reg.idx = EXTRA_REG_NONE;
-
-	/* mark not used */
-	event->hw.extra_reg.idx = EXTRA_REG_NONE;
 	event->hw.branch_reg.idx = EXTRA_REG_NONE;
 
 	return x86_pmu.hw_config(event);
#4 lore raw

[tip:perf/core] perf/x86: Fix cmpxchg() usage in amd_put_event_constraints()

In reply to Robert Richter
Commit-ID:  5f09fc688936705b2020ca247df39ee27283668a
Gitweb:     http://git.kernel.org/tip/5f09fc688936705b2020ca247df39ee27283668a
Author:     Robert Richter <[email protected]>
AuthorDate: Thu, 5 Apr 2012 18:24:42 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Apr 2012 13:52:51 +0200

perf/x86: Fix cmpxchg() usage in amd_put_event_constraints()

Now the return value of cmpxchg() is used to match an event. The change removes the duplicate event comparison and traverses the list until an event was removed. This also fixes the following warning:

arch/x86/kernel/cpu/perf_event_amd.c:170: warning: value computed is not used

---
 arch/x86/kernel/cpu/perf_event_amd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_amd.c +1 -3
index 95e7fe1..589286f 100644
@@ -205,10 +205,8 @@ static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
 	 * when we come here
 	 */
 	for (i = 0; i < x86_pmu.num_counters; i++) {
-		if (nb->owners[i] == event) {
-			cmpxchg(nb->owners+i, event, NULL);
+		if (cmpxchg(nb->owners + i, event, NULL) == event)
 			break;
-		}
 	}
 }
 
#6 lore raw

[tip:perf/core] perf: Use static variant of perf_event_overflow in core.c

In reply to Robert Richter
Commit-ID:  33b07b8be7f0e1e8e4184e3473d71f174e4b0641
Gitweb:     http://git.kernel.org/tip/33b07b8be7f0e1e8e4184e3473d71f174e4b0641
Author:     Robert Richter <[email protected]>
AuthorDate: Thu, 5 Apr 2012 18:24:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Apr 2012 13:52:52 +0200

perf: Use static variant of perf_event_overflow in core.c

No need to have an additional function layer.

---
 kernel/events/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/core.c +1 -1
index a6a9ec4..9789a56 100644
@@ -5350,7 +5350,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 
 	if (regs && !perf_exclude_event(event, regs)) {
 		if (!(event->attr.exclude_idle && is_idle_task(current)))
-			if (perf_event_overflow(event, &data, regs))
+			if (__perf_event_overflow(event, 1, &data, regs))
 				ret = HRTIMER_NORESTART;
 	}
 
#8 lore raw

[tip:perf/core] perf: Remove PERF_COUNTERS config option

In reply to Robert Richter
Commit-ID:  392d65a9adbe2f09707d2de27110dafb9c8dc08b
Gitweb:     http://git.kernel.org/tip/392d65a9adbe2f09707d2de27110dafb9c8dc08b
Author:     Robert Richter <[email protected]>
AuthorDate: Thu, 5 Apr 2012 18:24:44 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Apr 2012 13:52:52 +0200

perf: Remove PERF_COUNTERS config option

Renaming remaining PERF_COUNTERS options into PERF_EVENTS.

Think we can get rid of PERF_COUNTERS now.

---
 arch/arm/configs/bcmring_defconfig        |    2 +-
 arch/powerpc/configs/chroma_defconfig     |    2 +-
 arch/powerpc/configs/gamecube_defconfig   |    2 +-
 arch/powerpc/configs/wii_defconfig        |    2 +-
 arch/sh/configs/sh7785lcr_32bit_defconfig |    2 +-
 arch/sparc/configs/sparc64_defconfig      |    2 +-
 init/Kconfig                              |   14 +-------------
 7 files changed, 7 insertions(+), 19 deletions(-)
arch/arm/configs/bcmring_defconfig +1 -1
index 795374d..9e6a8fe 100644
@@ -11,7 +11,7 @@ CONFIG_KALLSYMS_EXTRA_PASS=y
 # CONFIG_TIMERFD is not set
 # CONFIG_EVENTFD is not set
 # CONFIG_AIO is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 # CONFIG_SLUB_DEBUG is not set
 # CONFIG_COMPAT_BRK is not set
arch/powerpc/configs/chroma_defconfig +1 -1
index f104ccd..b1f9597 100644
@@ -32,7 +32,7 @@ CONFIG_RD_LZMA=y
 CONFIG_INITRAMFS_COMPRESSION_GZIP=y
 CONFIG_KALLSYMS_ALL=y
 CONFIG_EMBEDDED=y
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 CONFIG_PROFILING=y
 CONFIG_OPROFILE=y
 CONFIG_KPROBES=y
arch/powerpc/configs/gamecube_defconfig +1 -1
index e74d3a4..9ef2cc1 100644
@@ -8,7 +8,7 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_EXPERT=y
 # CONFIG_ELF_CORE is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_SLAB=y
 CONFIG_MODULES=y
arch/powerpc/configs/wii_defconfig +1 -1
index 175295f..1e2b7d0 100644
@@ -9,7 +9,7 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_EXPERT=y
 # CONFIG_ELF_CORE is not set
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
 CONFIG_SLAB=y
 CONFIG_MODULES=y
arch/sh/configs/sh7785lcr_32bit_defconfig +1 -1
index 7b9c696..9bdcf72 100644
@@ -5,7 +5,7 @@ CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=16
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
arch/sparc/configs/sparc64_defconfig +1 -1
index 3c1e858..9d8521b 100644
@@ -5,7 +5,7 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_LOG_BUF_SHIFT=18
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_PERF_COUNTERS=y
+CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
 CONFIG_PROFILING=y
init/Kconfig +1 -13
index 6cfd71d..7e37135 100644
@@ -1156,7 +1156,7 @@ menu "Kernel Performance Events And Counters"
 
 config PERF_EVENTS
 	bool "Kernel performance events and counters"
-	default y if (PROFILING || PERF_COUNTERS)
+	default y if PROFILING
 	depends on HAVE_PERF_EVENTS
 	select ANON_INODES
 	select IRQ_WORK
@@ -1183,18 +1183,6 @@ config PERF_EVENTS
 
 	  Say Y if unsure.
 
-config PERF_COUNTERS
-	bool "Kernel performance counters (old config option)"
-	depends on HAVE_PERF_EVENTS
-	help
-	  This config has been obsoleted by the PERF_EVENTS
-	  config option - please see that one for details.
-
-	  It has no effect on the kernel whether you enable
-	  it or not, it is a compatibility placeholder.
-
-	  Say N if unsure.
-
 config DEBUG_PERF_USE_VMALLOC
 	default n
 	bool "Debug: use vmalloc to back perf mmap() buffers"