Skip to content

Commit 455e987

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "This is mostly about unbreaking architectures that took the UAPI changes in the v3.7 cycle, plus misc fixes." * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf kvm: Fix building perf kvm on non x86 arches perf kvm: Rename perf_kvm to perf_kvm_stat perf: Make perf build for x86 with UAPI disintegration applied perf powerpc: Use uapi/unistd.h to fix build error tools: Pass the target in descend tools: Honour the O= flag when tool build called from a higher Makefile tools: Define a Makefile function to do subdir processing x86: Export asm/{svm.h,vmx.h,perf_regs.h} perf tools: Fix strbuf_addf() when the buffer needs to grow perf header: Fix numa topology printing perf, powerpc: Fix hw breakpoints returning -ENOSPC
2 parents 7c17e48 + fd6da69 commit 455e987

File tree

23 files changed

+194
-135
lines changed

23 files changed

+194
-135
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,10 +1321,12 @@ kernelversion:
13211321

13221322
# Clear a bunch of variables before executing the submake
13231323
tools/: FORCE
1324-
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/
1324+
$(Q)mkdir -p $(objtree)/tools
1325+
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
13251326

13261327
tools/%: FORCE
1327-
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $*
1328+
$(Q)mkdir -p $(objtree)/tools
1329+
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
13281330

13291331
# Single targets
13301332
# ---------------------------------------------------------------------------

arch/x86/include/asm/Kbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ header-y += mce.h
1212
header-y += msr-index.h
1313
header-y += msr.h
1414
header-y += mtrr.h
15+
header-y += perf_regs.h
1516
header-y += posix_types_32.h
1617
header-y += posix_types_64.h
1718
header-y += posix_types_x32.h
1819
header-y += prctl.h
1920
header-y += processor-flags.h
2021
header-y += ptrace-abi.h
2122
header-y += sigcontext32.h
23+
header-y += svm.h
2224
header-y += ucontext.h
2325
header-y += vm86.h
26+
header-y += vmx.h
2427
header-y += vsyscall.h
2528

2629
genhdr-y += unistd_32.h

include/linux/hw_breakpoint.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
11
#ifndef _LINUX_HW_BREAKPOINT_H
22
#define _LINUX_HW_BREAKPOINT_H
33

4-
enum {
5-
HW_BREAKPOINT_LEN_1 = 1,
6-
HW_BREAKPOINT_LEN_2 = 2,
7-
HW_BREAKPOINT_LEN_4 = 4,
8-
HW_BREAKPOINT_LEN_8 = 8,
9-
};
10-
11-
enum {
12-
HW_BREAKPOINT_EMPTY = 0,
13-
HW_BREAKPOINT_R = 1,
14-
HW_BREAKPOINT_W = 2,
15-
HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W,
16-
HW_BREAKPOINT_X = 4,
17-
HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
18-
};
19-
20-
enum bp_type_idx {
21-
TYPE_INST = 0,
22-
#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
23-
TYPE_DATA = 0,
24-
#else
25-
TYPE_DATA = 1,
26-
#endif
27-
TYPE_MAX
28-
};
29-
30-
#ifdef __KERNEL__
31-
324
#include <linux/perf_event.h>
5+
#include <uapi/linux/hw_breakpoint.h>
336

347
#ifdef CONFIG_HAVE_HW_BREAKPOINT
358

@@ -151,6 +124,4 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
151124
}
152125

153126
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
154-
#endif /* __KERNEL__ */
155-
156127
#endif /* _LINUX_HW_BREAKPOINT_H */

include/uapi/linux/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,4 @@ header-y += wireless.h
415415
header-y += x25.h
416416
header-y += xattr.h
417417
header-y += xfrm.h
418+
header-y += hw_breakpoint.h

include/uapi/linux/hw_breakpoint.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef _UAPI_LINUX_HW_BREAKPOINT_H
2+
#define _UAPI_LINUX_HW_BREAKPOINT_H
3+
4+
enum {
5+
HW_BREAKPOINT_LEN_1 = 1,
6+
HW_BREAKPOINT_LEN_2 = 2,
7+
HW_BREAKPOINT_LEN_4 = 4,
8+
HW_BREAKPOINT_LEN_8 = 8,
9+
};
10+
11+
enum {
12+
HW_BREAKPOINT_EMPTY = 0,
13+
HW_BREAKPOINT_R = 1,
14+
HW_BREAKPOINT_W = 2,
15+
HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W,
16+
HW_BREAKPOINT_X = 4,
17+
HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
18+
};
19+
20+
enum bp_type_idx {
21+
TYPE_INST = 0,
22+
#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
23+
TYPE_DATA = 0,
24+
#else
25+
TYPE_DATA = 1,
26+
#endif
27+
TYPE_MAX
28+
};
29+
30+
#endif /* _UAPI_LINUX_HW_BREAKPOINT_H */

kernel/events/hw_breakpoint.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ static unsigned int max_task_bp_pinned(int cpu, enum bp_type_idx type)
111111
* Count the number of breakpoints of the same type and same task.
112112
* The given event must be not on the list.
113113
*/
114-
static int task_bp_pinned(struct perf_event *bp, enum bp_type_idx type)
114+
static int task_bp_pinned(int cpu, struct perf_event *bp, enum bp_type_idx type)
115115
{
116116
struct task_struct *tsk = bp->hw.bp_target;
117117
struct perf_event *iter;
118118
int count = 0;
119119

120120
list_for_each_entry(iter, &bp_task_head, hw.bp_list) {
121-
if (iter->hw.bp_target == tsk && find_slot_idx(iter) == type)
121+
if (iter->hw.bp_target == tsk &&
122+
find_slot_idx(iter) == type &&
123+
cpu == iter->cpu)
122124
count += hw_breakpoint_weight(iter);
123125
}
124126

@@ -141,7 +143,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
141143
if (!tsk)
142144
slots->pinned += max_task_bp_pinned(cpu, type);
143145
else
144-
slots->pinned += task_bp_pinned(bp, type);
146+
slots->pinned += task_bp_pinned(cpu, bp, type);
145147
slots->flexible = per_cpu(nr_bp_flexible[type], cpu);
146148

147149
return;
@@ -154,7 +156,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
154156
if (!tsk)
155157
nr += max_task_bp_pinned(cpu, type);
156158
else
157-
nr += task_bp_pinned(bp, type);
159+
nr += task_bp_pinned(cpu, bp, type);
158160

159161
if (nr > slots->pinned)
160162
slots->pinned = nr;
@@ -188,7 +190,7 @@ static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable,
188190
int old_idx = 0;
189191
int idx = 0;
190192

191-
old_count = task_bp_pinned(bp, type);
193+
old_count = task_bp_pinned(cpu, bp, type);
192194
old_idx = old_count - 1;
193195
idx = old_idx + weight;
194196

tools/Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,44 @@ help:
3131
@echo ' clean: a summary clean target to clean _all_ folders'
3232

3333
cpupower: FORCE
34-
$(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1)
34+
$(call descend,power/$@)
3535

3636
firewire lguest perf usb virtio vm: FORCE
37-
$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
37+
$(call descend,$@)
3838

3939
selftests: FORCE
40-
$(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1)
40+
$(call descend,testing/$@)
4141

4242
turbostat x86_energy_perf_policy: FORCE
43-
$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)
43+
$(call descend,power/x86/$@)
4444

4545
cpupower_install:
46-
$(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install
46+
$(call descend,power/$(@:_install=),install)
4747

4848
firewire_install lguest_install perf_install usb_install virtio_install vm_install:
49-
$(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install
49+
$(call descend,$(@:_install=),install)
5050

5151
selftests_install:
52-
$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install
52+
$(call descend,testing/$(@:_clean=),install)
5353

5454
turbostat_install x86_energy_perf_policy_install:
55-
$(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install
55+
$(call descend,power/x86/$(@:_install=),install)
5656

5757
install: cpupower_install firewire_install lguest_install perf_install \
5858
selftests_install turbostat_install usb_install virtio_install \
5959
vm_install x86_energy_perf_policy_install
6060

6161
cpupower_clean:
62-
$(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean
62+
$(call descend,power/cpupower,clean)
6363

6464
firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
65-
$(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean
65+
$(call descend,$(@:_clean=),clean)
6666

6767
selftests_clean:
68-
$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
68+
$(call descend,testing/$(@:_clean=),clean)
6969

7070
turbostat_clean x86_energy_perf_policy_clean:
71-
$(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
71+
$(call descend,power/x86/$(@:_clean=),clean)
7272

7373
clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
7474
turbostat_clean usb_clean virtio_clean vm_clean \

tools/perf/Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,34 @@ endif
169169

170170
### --- END CONFIGURATION SECTION ---
171171

172-
BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
172+
ifeq ($(srctree),)
173+
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
174+
srctree := $(patsubst %/,%,$(dir $(srctree)))
175+
#$(info Determined 'srctree' to be $(srctree))
176+
endif
177+
178+
ifneq ($(objtree),)
179+
#$(info Determined 'objtree' to be $(objtree))
180+
endif
181+
182+
ifneq ($(OUTPUT),)
183+
#$(info Determined 'OUTPUT' to be $(OUTPUT))
184+
endif
185+
186+
BASIC_CFLAGS = \
187+
-Iutil/include \
188+
-Iarch/$(ARCH)/include \
189+
$(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \
190+
-I$(srctree)/arch/$(ARCH)/include/uapi \
191+
-I$(srctree)/arch/$(ARCH)/include \
192+
$(if $(objtree),-I$(objtree)/include/generated/uapi) \
193+
-I$(srctree)/include/uapi \
194+
-I$(srctree)/include \
195+
-I$(OUTPUT)util \
196+
-Iutil \
197+
-I. \
198+
-I$(TRACE_EVENT_DIR) \
199+
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
173200
BASIC_LDFLAGS =
174201

175202
# Guard against environment variables

tools/perf/arch/x86/include/perf_regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <stdlib.h>
55
#include "../../util/types.h"
6-
#include "../../../../../arch/x86/include/asm/perf_regs.h"
6+
#include <asm/perf_regs.h>
77

88
#ifndef ARCH_X86_64
99
#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)

0 commit comments

Comments
 (0)