linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
	peterz@infradead.org, mingo@redhat.com, acme@kernel.org
Cc: gavin.hindman@intel.com, jithu.joseph@intel.com,
	dave.hansen@intel.com, hpa@zytor.com, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Reinette Chatre <reinette.chatre@intel.com>
Subject: [PATCH V3 1/6] perf/core: Add sanity check to deal with pinned event failure
Date: Tue, 11 Sep 2018 10:14:32 -0700	[thread overview]
Message-ID: <6486385d1f30336e9973b24c8c65f5079543d3d3.1536685533.git.reinette.chatre@intel.com> (raw)
In-Reply-To: <cover.1536685533.git.reinette.chatre@intel.com>
In-Reply-To: <cover.1536685533.git.reinette.chatre@intel.com>

It is possible that a failure can occur during the scheduling of a
pinned event. The initial portion of perf_event_read_local() contains
the various error checks an event should pass before it can be
considered valid. Ensure that the potential scheduling failure
of a pinned event is checked for and have a credible error.

Link: http://lkml.kernel.org/r/20180807093615.GY2494@hirez.programming.kicks-ass.net
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 kernel/events/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2a62b96600ad..191c0c2e10de 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3940,6 +3940,12 @@ int perf_event_read_local(struct perf_event *event, u64 *value,
 		goto out;
 	}
 
+	/* If this is a pinned event it must be running on this CPU */
+	if (event->attr.pinned && event->oncpu != smp_processor_id()) {
+		ret = -EBUSY;
+		goto out;
+	}
+
 	/*
 	 * If the event is currently on this CPU, its either a per-task event,
 	 * or local to this CPU. Furthermore it means its ACTIVE (otherwise
-- 
2.17.0


  reply	other threads:[~2018-09-11 17:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 17:14 [PATCH V3 0/6] perf/core and x86/intel_rdt: Fix lack of coordination with perf Reinette Chatre
2018-09-11 17:14 ` Reinette Chatre [this message]
2018-09-11 17:14 ` [PATCH V3 2/6] perf/core: Add helper to obtain performance counter index Reinette Chatre
2018-09-17  8:23   ` Peter Zijlstra
2018-09-17 16:37     ` Reinette Chatre
2018-09-17 23:07       ` Peter Zijlstra
2018-09-18 17:54         ` Reinette Chatre
2018-09-19  9:17           ` Peter Zijlstra
2018-09-11 17:14 ` [PATCH V3 3/6] x86/intel_rdt: Remove local register variables Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 4/6] x86/intel_rdt: Create required perf event attributes Reinette Chatre
2018-09-12  5:49   ` kbuild test robot
2018-09-12  7:20   ` kbuild test robot
2018-09-12 19:54   ` [PATCH V4 " Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 5/6] x86/intel_rdt: Use perf infrastructure for measurements Reinette Chatre
2018-09-17  8:58   ` Peter Zijlstra
2018-09-17 16:54     ` Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 6/6] x86/intel_rdt: Re-enable pseudo-lock measurements Reinette Chatre

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=6486385d1f30336e9973b24c8c65f5079543d3d3.1536685533.git.reinette.chatre@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=acme@kernel.org \
    --cc=dave.hansen@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=gavin.hindman@intel.com \
    --cc=hpa@zytor.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@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).