perf fixes
Subsystems (2)
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
# HEAD: 9f0bff1180efc9ea988fed3fd93da7647151ac8b perf/core: Add SRCU annotation for pmus list walk
Misc fixes: a BTS fix, a PT NMI handling fix, a PMU sysfs fix and an SRCU annotation.
Thanks,
Ingo
------------------>
Alexander Shishkin (2):
perf/x86/intel/bts: Fix the use of page_private() perf/x86/intel: Fix PT PMI handling
Peter Zijlstra (1):
perf/x86: Fix potential out-of-bounds access
Sebastian Andrzej Siewior (1):
perf/core: Add SRCU annotation for pmus list walk
arch/x86/events/core.c | 19 +++++++++++++++---- arch/x86/events/intel/bts.c | 16 +++++++++++----- kernel/events/core.c | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-)
arch/x86/events/core.c +15 -4
@@ -376,7 +376,7 @@ int x86_add_exclusive(unsigned int what)* LBR and BTS are still mutually exclusive. */ if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) -return 0 ; + goto out;if (!atomic_inc_not_zero (&x86_pmu.lbr_exclusive[what])) {mutex_lock (&pmc_reserve_mutex);
@@ -388,6 +388,7 @@ int x86_add_exclusive(unsigned int what)mutex_unlock (&pmc_reserve_mutex); } +out:atomic_inc (&active_events);return 0 ;
@@ -398,11 +399,15 @@ int x86_add_exclusive(unsigned int what)void x86_del_exclusive (unsigned int what) { +atomic_dec (&active_events); + +/* +* See the comment in x86_add_exclusive(). +*/ if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt)return ;atomic_dec (&x86_pmu.lbr_exclusive[what]); -atomic_dec (&active_events); }int x86_setup_perfctr (struct perf_event *event)
@@ -1642,9 +1647,12 @@ static struct attribute_group x86_pmu_format_group __ro_after_init = {ssize_t events_sysfs_show (struct device *dev,struct device_attribute *attr,char *page) { -struct perf_pmu_events_attr *pmu_attr = \ +struct perf_pmu_events_attr *pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr); -u64 config = x86_pmu.event_map (pmu_attr->id); +u64 config =0 ; + +if (pmu_attr->id < x86_pmu.max_events) + config = x86_pmu.event_map (pmu_attr->id);/* string trumps id */ if (pmu_attr->event_str)
@@ -1713,6 +1721,9 @@ is_visible(struct kobject *kobj, struct attribute *attr, int idx) {struct perf_pmu_events_attr *pmu_attr; +if (idx >= x86_pmu.max_events) +return 0 ; + pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr);/* str trumps id */ return pmu_attr->event_str || x86_pmu.event_map (idx) ? attr->mode :0 ;
arch/x86/events/intel/bts.c +11 -5
@@ -63,9 +63,17 @@ struct bts_buffer {static struct pmu bts_pmu; +static int buf_nr_pages (struct page *page) +{ +if (!PagePrivate (page)) +return 1 ; + +return 1 <<page_private (page); +} +static size_t buf_size (struct page *page) { -return 1 << (PAGE_SHIFT +page_private (page)); +return buf_nr_pages (page) *PAGE_SIZE ; } static void *
@@ -83,9 +91,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,/* count all the high order buffers */ for (pg =0 , nbuf =0 ; pg < nr_pages;) { page =virt_to_page (pages[pg]); -if (WARN_ON_ONCE (!PagePrivate (page) && nr_pages >1 )) -return NULL ; - pg +=1 <<page_private (page); + pg +=buf_nr_pages (page); nbuf++; }
@@ -109,7 +115,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,unsigned int __nr_pages; page =virt_to_page (pages[pg]); - __nr_pages =PagePrivate (page) ?1 <<page_private (page) :1 ; + __nr_pages =buf_nr_pages (page); buf->buf[nbuf].page = page; buf->buf[nbuf].offset = offset; buf->buf[nbuf].displacement = (pad ?BTS_RECORD_SIZE - pad :0 );
kernel/events/core.c +1 -1
@@ -10523,7 +10523,7 @@ static struct pmu *perf_init_event(struct perf_event *event) goto unlock; } -list_for_each_entry_rcu (pmu, &pmus, entry) { +list_for_each_entry_rcu (pmu, &pmus, entry,lockdep_is_held (&pmus_srcu)) { ret =perf_try_init_event (pmu, event);if (!ret) goto unlock;
The pull request you sent on Sat, 21 Dec 2019 17:16:24 +0100:
The pull request you sent on Sat, 21 Dec 2019 17:16:24 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitperf-urgent-for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/c4ff10efe8e487cd35f4475ed2dd1e5e0c6f784a
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker