linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Leonard Crestez <leonard.crestez@nxp.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Frank Li <Frank.li@nxp.com>, Jiri Olsa <jolsa@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Will Deacon <will@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.9 22/22] perf/core: Fix creating kernel counters for PMUs that override event->cpu
Date: Fri,  2 Aug 2019 09:25:46 -0400	[thread overview]
Message-ID: <20190802132547.14517-22-sashal@kernel.org> (raw)
In-Reply-To: <20190802132547.14517-1-sashal@kernel.org>

From: Leonard Crestez <leonard.crestez@nxp.com>

[ Upstream commit 4ce54af8b33d3e21ca935fc1b89b58cbba956051 ]

Some hardware PMU drivers will override perf_event.cpu inside their
event_init callback. This causes a lockdep splat when initialized through
the kernel API:

 WARNING: CPU: 0 PID: 250 at kernel/events/core.c:2917 ctx_sched_out+0x78/0x208
 pc : ctx_sched_out+0x78/0x208
 Call trace:
  ctx_sched_out+0x78/0x208
  __perf_install_in_context+0x160/0x248
  remote_function+0x58/0x68
  generic_exec_single+0x100/0x180
  smp_call_function_single+0x174/0x1b8
  perf_install_in_context+0x178/0x188
  perf_event_create_kernel_counter+0x118/0x160

Fix this by calling perf_install_in_context with event->cpu, just like
perf_event_open

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Frank Li <Frank.li@nxp.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Link: https://lkml.kernel.org/r/c4ebe0503623066896d7046def4d6b1e06e0eb2e.1563972056.git.leonard.crestez@nxp.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 93d7333c64d89..5bbf7537a6121 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10130,7 +10130,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 		goto err_unlock;
 	}
 
-	perf_install_in_context(ctx, event, cpu);
+	perf_install_in_context(ctx, event, event->cpu);
 	perf_unpin_context(ctx);
 	mutex_unlock(&ctx->mutex);
 
-- 
2.20.1


      parent reply	other threads:[~2019-08-02 13:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 13:25 [PATCH AUTOSEL 4.9 01/22] netfilter: nfnetlink: avoid deadlock due to synchronous request_module Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 02/22] iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 03/22] mac80211: don't warn about CW params when not using them Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 04/22] hwmon: (nct6775) Fix register address and added missed tolerance for nct6106 Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 05/22] x86/mm: Check for pfn instead of page in vmalloc_sync_one() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 06/22] x86/mm: Sync also unmappings in vmalloc_sync_all() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 07/22] drm/msm: stop abusing dma_map/unmap for cache Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 08/22] cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 09/22] s390/qdio: add sanity checks to the fast-requeue path Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 10/22] ALSA: compress: Fix regression on compressed capture streams Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 11/22] ALSA: compress: Prevent bypasses of set_params Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 12/22] ALSA: compress: Don't allow paritial drain operations on capture streams Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 13/22] ALSA: compress: Be more restrictive about when a drain is allowed Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 14/22] perf probe: Avoid calling freeing routine multiple times for same pointer Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 15/22] drbd: dynamically allocate shash descriptor Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 16/22] ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 17/22] ARM: davinci: fix sleep.S build error on ARMv4 Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 18/22] scsi: megaraid_sas: fix panic on loading firmware crashdump Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 19/22] scsi: ibmvfc: fix WARN_ON during event pool release Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 20/22] scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 21/22] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop Sasha Levin
2019-08-02 13:25 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802132547.14517-22-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Frank.li@nxp.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).