Skip to content

Commit 29d14f0

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: "This is much bigger than typical fixes, but Peter found a category of races that spurred more fixes and more debugging enhancements. Work started before the merge window, but got finished only now. Aside of that this contains the usual small fixes to perf and tools. Nothing particular exciting" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (43 commits) perf: Remove/simplify lockdep annotation perf: Synchronously clean up child events perf: Untangle 'owner' confusion perf: Add flags argument to perf_remove_from_context() perf: Clean up sync_child_event() perf: Robustify event->owner usage and SMP ordering perf: Fix STATE_EXIT usage perf: Update locking order perf: Remove __free_event() perf/bpf: Convert perf_event_array to use struct file perf: Fix NULL deref perf/x86: De-obfuscate code perf/x86: Fix uninitialized value usage perf: Fix race in perf_event_exit_task_context() perf: Fix orphan hole perf stat: Do not clean event's private stats perf hists: Fix HISTC_MEM_DCACHELINE width setting perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed perf tests: Remove wrong semicolon in while loop in CQM test perf: Synchronously free aux pages in case of allocation failure ...
2 parents bbfb239 + 28fb8a5 commit 29d14f0

19 files changed

Lines changed: 746 additions & 667 deletions

File tree

‎arch/x86/kernel/cpu/perf_event_intel.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,8 @@ intel_bts_constraints(struct perf_event *event)
19601960

19611961
static int intel_alt_er(int idx, u64 config)
19621962
{
1963-
int alt_idx;
1963+
int alt_idx = idx;
1964+
19641965
if (!(x86_pmu.flags & PMU_FL_HAS_RSP_1))
19651966
return idx;
19661967

@@ -2897,14 +2898,12 @@ static void intel_pmu_cpu_starting(int cpu)
28972898
return;
28982899

28992900
if (!(x86_pmu.flags & PMU_FL_NO_HT_SHARING)) {
2900-
void **onln = &cpuc->kfree_on_online[X86_PERF_KFREE_SHARED];
2901-
29022901
for_each_cpu(i, topology_sibling_cpumask(cpu)) {
29032902
struct intel_shared_regs *pc;
29042903

29052904
pc = per_cpu(cpu_hw_events, i).shared_regs;
29062905
if (pc && pc->core_id == core_id) {
2907-
*onln = cpuc->shared_regs;
2906+
cpuc->kfree_on_online[0] = cpuc->shared_regs;
29082907
cpuc->shared_regs = pc;
29092908
break;
29102909
}

‎arch/x86/kernel/cpu/perf_event_intel_uncore.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,9 @@ static int __init uncore_pci_init(void)
995995
case 87: /* Knights Landing */
996996
ret = knl_uncore_pci_init();
997997
break;
998+
case 94: /* SkyLake */
999+
ret = skl_uncore_pci_init();
1000+
break;
9981001
default:
9991002
return 0;
10001003
}

‎arch/x86/kernel/cpu/perf_event_intel_uncore.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ int snb_uncore_pci_init(void);
336336
int ivb_uncore_pci_init(void);
337337
int hsw_uncore_pci_init(void);
338338
int bdw_uncore_pci_init(void);
339+
int skl_uncore_pci_init(void);
339340
void snb_uncore_cpu_init(void);
340341
void nhm_uncore_cpu_init(void);
341342
int snb_pci2phy_map_init(int devid);

‎arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define PCI_DEVICE_ID_INTEL_HSW_IMC 0x0c00
99
#define PCI_DEVICE_ID_INTEL_HSW_U_IMC 0x0a04
1010
#define PCI_DEVICE_ID_INTEL_BDW_IMC 0x1604
11+
#define PCI_DEVICE_ID_INTEL_SKL_IMC 0x191f
1112

1213
/* SNB event control */
1314
#define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff
@@ -524,6 +525,14 @@ static const struct pci_device_id bdw_uncore_pci_ids[] = {
524525
{ /* end: all zeroes */ },
525526
};
526527

528+
static const struct pci_device_id skl_uncore_pci_ids[] = {
529+
{ /* IMC */
530+
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_IMC),
531+
.driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
532+
},
533+
{ /* end: all zeroes */ },
534+
};
535+
527536
static struct pci_driver snb_uncore_pci_driver = {
528537
.name = "snb_uncore",
529538
.id_table = snb_uncore_pci_ids,
@@ -544,6 +553,11 @@ static struct pci_driver bdw_uncore_pci_driver = {
544553
.id_table = bdw_uncore_pci_ids,
545554
};
546555

556+
static struct pci_driver skl_uncore_pci_driver = {
557+
.name = "skl_uncore",
558+
.id_table = skl_uncore_pci_ids,
559+
};
560+
547561
struct imc_uncore_pci_dev {
548562
__u32 pci_id;
549563
struct pci_driver *driver;
@@ -558,6 +572,7 @@ static const struct imc_uncore_pci_dev desktop_imc_pci_ids[] = {
558572
IMC_DEV(HSW_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core Processor */
559573
IMC_DEV(HSW_U_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core ULT Mobile Processor */
560574
IMC_DEV(BDW_IMC, &bdw_uncore_pci_driver), /* 5th Gen Core U */
575+
IMC_DEV(SKL_IMC, &skl_uncore_pci_driver), /* 6th Gen Core */
561576
{ /* end marker */ }
562577
};
563578

@@ -610,6 +625,11 @@ int bdw_uncore_pci_init(void)
610625
return imc_uncore_pci_init();
611626
}
612627

628+
int skl_uncore_pci_init(void)
629+
{
630+
return imc_uncore_pci_init();
631+
}
632+
613633
/* end of Sandy Bridge uncore support */
614634

615635
/* Nehalem uncore support */

‎include/linux/perf_event.h‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,6 @@ struct perf_event_context {
634634
int nr_cgroups; /* cgroup evts */
635635
void *task_ctx_data; /* pmu specific data */
636636
struct rcu_head rcu_head;
637-
638-
struct delayed_work orphans_remove;
639-
bool orphans_remove_sched;
640637
};
641638

642639
/*
@@ -729,7 +726,7 @@ extern int perf_event_init_task(struct task_struct *child);
729726
extern void perf_event_exit_task(struct task_struct *child);
730727
extern void perf_event_free_task(struct task_struct *task);
731728
extern void perf_event_delayed_put(struct task_struct *task);
732-
extern struct perf_event *perf_event_get(unsigned int fd);
729+
extern struct file *perf_event_get(unsigned int fd);
733730
extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
734731
extern void perf_event_print_debug(void);
735732
extern void perf_pmu_disable(struct pmu *pmu);
@@ -1044,7 +1041,7 @@ extern void perf_swevent_put_recursion_context(int rctx);
10441041
extern u64 perf_swevent_set_period(struct perf_event *event);
10451042
extern void perf_event_enable(struct perf_event *event);
10461043
extern void perf_event_disable(struct perf_event *event);
1047-
extern int __perf_event_disable(void *info);
1044+
extern void perf_event_disable_local(struct perf_event *event);
10481045
extern void perf_event_task_tick(void);
10491046
#else /* !CONFIG_PERF_EVENTS: */
10501047
static inline void *
@@ -1070,7 +1067,7 @@ static inline int perf_event_init_task(struct task_struct *child) { return 0; }
10701067
static inline void perf_event_exit_task(struct task_struct *child) { }
10711068
static inline void perf_event_free_task(struct task_struct *task) { }
10721069
static inline void perf_event_delayed_put(struct task_struct *task) { }
1073-
static inline struct perf_event *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); }
1070+
static inline struct file *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); }
10741071
static inline const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
10751072
{
10761073
return ERR_PTR(-EINVAL);

‎kernel/bpf/arraymap.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,13 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd)
291291
{
292292
struct perf_event *event;
293293
const struct perf_event_attr *attr;
294+
struct file *file;
294295

295-
event = perf_event_get(fd);
296-
if (IS_ERR(event))
297-
return event;
296+
file = perf_event_get(fd);
297+
if (IS_ERR(file))
298+
return file;
299+
300+
event = file->private_data;
298301

299302
attr = perf_event_attrs(event);
300303
if (IS_ERR(attr))
@@ -304,24 +307,22 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd)
304307
goto err;
305308

306309
if (attr->type == PERF_TYPE_RAW)
307-
return event;
310+
return file;
308311

309312
if (attr->type == PERF_TYPE_HARDWARE)
310-
return event;
313+
return file;
311314

312315
if (attr->type == PERF_TYPE_SOFTWARE &&
313316
attr->config == PERF_COUNT_SW_BPF_OUTPUT)
314-
return event;
317+
return file;
315318
err:
316-
perf_event_release_kernel(event);
319+
fput(file);
317320
return ERR_PTR(-EINVAL);
318321
}
319322

320323
static void perf_event_fd_array_put_ptr(void *ptr)
321324
{
322-
struct perf_event *event = ptr;
323-
324-
perf_event_release_kernel(event);
325+
fput((struct file *)ptr);
325326
}
326327

327328
static const struct bpf_map_ops perf_event_array_ops = {

0 commit comments

Comments
 (0)