Skip to content

Commit e7c632f

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 Thomas Gleixner: - plug a memory leak in the intel pmu init code - clang fixes - tooling fix to avoid including kernel headers - a fix for jvmti to generate correct debug information for inlined code - replace backtick with a regular shell function - fix the build in hardened environments * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Plug memory leak in intel_pmu_init() x86/asm: Allow again using asm.h when building for the 'bpf' clang target tools arch s390: Do not include header files from the kernel sources perf jvmti: Generate correct debug information for inlined code perf tools: Fix up build in hardened environments perf tools: Use shell function for perl cflags retrieval
2 parents 88fa025 + 7ad1437 commit e7c632f

File tree

9 files changed

+190
-43
lines changed

9 files changed

+190
-43
lines changed

arch/x86/events/intel/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3847,14 +3847,15 @@ static struct attribute *intel_pmu_attrs[] = {
38473847

38483848
__init int intel_pmu_init(void)
38493849
{
3850+
struct attribute **extra_attr = NULL;
3851+
struct attribute **to_free = NULL;
38503852
union cpuid10_edx edx;
38513853
union cpuid10_eax eax;
38523854
union cpuid10_ebx ebx;
38533855
struct event_constraint *c;
38543856
unsigned int unused;
38553857
struct extra_reg *er;
38563858
int version, i;
3857-
struct attribute **extra_attr = NULL;
38583859
char *name;
38593860

38603861
if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
@@ -4294,6 +4295,7 @@ __init int intel_pmu_init(void)
42944295
extra_attr = boot_cpu_has(X86_FEATURE_RTM) ?
42954296
hsw_format_attr : nhm_format_attr;
42964297
extra_attr = merge_attr(extra_attr, skl_format_attr);
4298+
to_free = extra_attr;
42974299
x86_pmu.cpu_events = get_hsw_events_attrs();
42984300
intel_pmu_pebs_data_source_skl(
42994301
boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X);
@@ -4401,6 +4403,7 @@ __init int intel_pmu_init(void)
44014403
pr_cont("full-width counters, ");
44024404
}
44034405

4406+
kfree(to_free);
44044407
return 0;
44054408
}
44064409

arch/x86/include/asm/asm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
#endif
137137

138138
#ifndef __ASSEMBLY__
139+
#ifndef __BPF__
139140
/*
140141
* This output constraint should be used for any inline asm which has a "call"
141142
* instruction. Otherwise the asm may be inserted before the frame pointer
@@ -145,5 +146,6 @@
145146
register unsigned long current_stack_pointer asm(_ASM_SP);
146147
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
147148
#endif
149+
#endif
148150

149151
#endif /* _ASM_X86_ASM_H */
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _ASM_S390_PERF_REGS_H
3+
#define _ASM_S390_PERF_REGS_H
4+
5+
enum perf_event_s390_regs {
6+
PERF_REG_S390_R0,
7+
PERF_REG_S390_R1,
8+
PERF_REG_S390_R2,
9+
PERF_REG_S390_R3,
10+
PERF_REG_S390_R4,
11+
PERF_REG_S390_R5,
12+
PERF_REG_S390_R6,
13+
PERF_REG_S390_R7,
14+
PERF_REG_S390_R8,
15+
PERF_REG_S390_R9,
16+
PERF_REG_S390_R10,
17+
PERF_REG_S390_R11,
18+
PERF_REG_S390_R12,
19+
PERF_REG_S390_R13,
20+
PERF_REG_S390_R14,
21+
PERF_REG_S390_R15,
22+
PERF_REG_S390_FP0,
23+
PERF_REG_S390_FP1,
24+
PERF_REG_S390_FP2,
25+
PERF_REG_S390_FP3,
26+
PERF_REG_S390_FP4,
27+
PERF_REG_S390_FP5,
28+
PERF_REG_S390_FP6,
29+
PERF_REG_S390_FP7,
30+
PERF_REG_S390_FP8,
31+
PERF_REG_S390_FP9,
32+
PERF_REG_S390_FP10,
33+
PERF_REG_S390_FP11,
34+
PERF_REG_S390_FP12,
35+
PERF_REG_S390_FP13,
36+
PERF_REG_S390_FP14,
37+
PERF_REG_S390_FP15,
38+
PERF_REG_S390_MASK,
39+
PERF_REG_S390_PC,
40+
41+
PERF_REG_S390_MAX
42+
};
43+
44+
#endif /* _ASM_S390_PERF_REGS_H */

tools/perf/Makefile.config

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ ifdef PYTHON_CONFIG
188188
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
189189
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
190190
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
191-
ifeq ($(CC_NO_CLANG), 1)
192-
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
193-
endif
191+
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
194192
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
195193
endif
196194

@@ -576,14 +574,15 @@ ifndef NO_GTK2
576574
endif
577575
endif
578576

579-
580577
ifdef NO_LIBPERL
581578
CFLAGS += -DNO_LIBPERL
582579
else
583580
PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
584581
PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
585582
PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
586-
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
583+
PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
584+
PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
585+
PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
587586
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
588587

589588
ifneq ($(feature-libperl), 1)

tools/perf/arch/s390/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 <linux/types.h>
6-
#include <../../../../arch/s390/include/uapi/asm/perf_regs.h>
6+
#include <asm/perf_regs.h>
77

88
void perf_regs_load(u64 *regs);
99

tools/perf/check-headers.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ arch/x86/include/asm/cpufeatures.h
2121
arch/arm/include/uapi/asm/perf_regs.h
2222
arch/arm64/include/uapi/asm/perf_regs.h
2323
arch/powerpc/include/uapi/asm/perf_regs.h
24+
arch/s390/include/uapi/asm/perf_regs.h
2425
arch/x86/include/uapi/asm/perf_regs.h
2526
arch/x86/include/uapi/asm/kvm.h
2627
arch/x86/include/uapi/asm/kvm_perf.h

tools/perf/jvmti/jvmti_agent.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ jvmti_write_code(void *agent, char const *sym,
384384
}
385385

386386
int
387-
jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
388-
jvmti_line_info_t *li, int nr_lines)
387+
jvmti_write_debug_info(void *agent, uint64_t code,
388+
int nr_lines, jvmti_line_info_t *li,
389+
const char * const * file_names)
389390
{
390391
struct jr_code_debug_info rec;
391-
size_t sret, len, size, flen;
392+
size_t sret, len, size, flen = 0;
392393
uint64_t addr;
393-
const char *fn = file;
394394
FILE *fp = agent;
395395
int i;
396396

@@ -405,7 +405,9 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
405405
return -1;
406406
}
407407

408-
flen = strlen(file) + 1;
408+
for (i = 0; i < nr_lines; ++i) {
409+
flen += strlen(file_names[i]) + 1;
410+
}
409411

410412
rec.p.id = JIT_CODE_DEBUG_INFO;
411413
size = sizeof(rec);
@@ -421,7 +423,7 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
421423
* file[] : source file name
422424
*/
423425
size += nr_lines * sizeof(struct debug_entry);
424-
size += flen * nr_lines;
426+
size += flen;
425427
rec.p.total_size = size;
426428

427429
/*
@@ -452,7 +454,7 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
452454
if (sret != 1)
453455
goto error;
454456

455-
sret = fwrite_unlocked(fn, flen, 1, fp);
457+
sret = fwrite_unlocked(file_names[i], strlen(file_names[i]) + 1, 1, fp);
456458
if (sret != 1)
457459
goto error;
458460
}

tools/perf/jvmti/jvmti_agent.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ typedef struct {
1414
unsigned long pc;
1515
int line_number;
1616
int discrim; /* discriminator -- 0 for now */
17+
jmethodID methodID;
1718
} jvmti_line_info_t;
1819

1920
void *jvmti_open(void);
@@ -22,11 +23,9 @@ int jvmti_write_code(void *agent, char const *symbol_name,
2223
uint64_t vma, void const *code,
2324
const unsigned int code_size);
2425

25-
int jvmti_write_debug_info(void *agent,
26-
uint64_t code,
27-
const char *file,
26+
int jvmti_write_debug_info(void *agent, uint64_t code, int nr_lines,
2827
jvmti_line_info_t *li,
29-
int nr_lines);
28+
const char * const * file_names);
3029

3130
#if defined(__cplusplus)
3231
}

0 commit comments

Comments
 (0)