Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sourab.gupta@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Insoo Woo <insoo.woo@intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jabin Wu <jabin.wu@intel.com>,
	Sourab Gupta <sourab.gupta@intel.com>
Subject: [RFC 7/8] drm/i915: Add support for having pid output with OA report
Date: Wed, 15 Jul 2015 14:17:02 +0530	[thread overview]
Message-ID: <1436950023-13940-8-git-send-email-sourab.gupta@intel.com> (raw)
In-Reply-To: <1436950023-13940-1-git-send-email-sourab.gupta@intel.com>

From: Sourab Gupta <sourab.gupta@intel.com>

This patch introduces flags and adds support for having pid output with the
OA reports generated through the RCS commands.

When the userspace expresses its interest in listening to the pid through
an oa_attr field during event init, the OA reports generated would have an
additional field appended with the pid information. The patches enables
this framework, which can be expanded upon to introduce further fields in
the OA report metadata.

Signed-off-by: Sourab Gupta <sourab.gupta@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h     |  3 +++
 drivers/gpu/drm/i915/i915_oa_perf.c | 19 ++++++++++++++++++-
 include/uapi/drm/i915_drm.h         |  8 +++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index fb296ae..337a721 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1671,6 +1671,7 @@ struct i915_oa_rcs_node {
 	u32 offset;
 	bool discard;
 	u32 ctx_id;
+	u32 pid;
 };
 
 extern const struct i915_oa_reg i915_oa_3d_mux_config_hsw[];
@@ -1978,6 +1979,8 @@ struct drm_i915_private {
 		struct list_head node_list;
 		struct work_struct work_timer;
 		struct work_struct work_event_destroy;
+#define I915_OA_SAMPLE_PID		(1<<0)
+		int sample_info_flags;
 	} oa_pmu;
 
 	void (*insert_profile_cmd[I915_PROFILE_MAX])
diff --git a/drivers/gpu/drm/i915/i915_oa_perf.c b/drivers/gpu/drm/i915/i915_oa_perf.c
index 9966e54..15920d1291 100644
--- a/drivers/gpu/drm/i915/i915_oa_perf.c
+++ b/drivers/gpu/drm/i915/i915_oa_perf.c
@@ -57,6 +57,8 @@ void i915_oa_insert_cmd(struct intel_ringbuffer *ringbuf, u32 ctx_id)
 		return;
 	}
 	entry->ctx_id = ctx_id;
+	if (dev_priv->oa_pmu.sample_info_flags & I915_OA_SAMPLE_PID)
+		entry->pid = current->pid;
 	i915_gem_request_assign(&entry->req, ring->outstanding_lazy_request);
 
 	spin_lock_irqsave(&dev_priv->oa_pmu.lock, lock_flags);
@@ -315,8 +317,9 @@ static void forward_one_oa_rcs_sample(struct drm_i915_private *dev_priv,
 	struct perf_sample_data data;
 	struct perf_event *event = dev_priv->oa_pmu.exclusive_event;
 	int format_size, snapshot_size;
-	u8 *snapshot;
+	u8 *snapshot, *current_ptr;
 	struct drm_i915_oa_node_ctx_id *ctx_info;
+	struct drm_i915_oa_node_pid *pid_info;
 	struct perf_raw_record raw;
 	u64 snapshot_ts;
 
@@ -326,6 +329,14 @@ static void forward_one_oa_rcs_sample(struct drm_i915_private *dev_priv,
 
 	ctx_info = (struct drm_i915_oa_node_ctx_id *)(snapshot + format_size);
 	ctx_info->ctx_id = node->ctx_id;
+	current_ptr = snapshot + snapshot_size;
+
+	if (dev_priv->oa_pmu.sample_info_flags & I915_OA_SAMPLE_PID) {
+		pid_info = (struct drm_i915_oa_node_pid *)current_ptr;
+		pid_info->pid = node->pid;
+		snapshot_size += sizeof(*pid_info);
+		current_ptr = snapshot + snapshot_size;
+	}
 
 	/* Flush the periodic snapshots till the ts of this OA report */
 	snapshot_ts = *(u64 *)(snapshot + 4);
@@ -680,6 +691,9 @@ static int init_oa_rcs_buffer(struct perf_event *event)
 	node_size = dev_priv->oa_pmu.oa_rcs_buffer.format_size +
 			sizeof(struct drm_i915_oa_node_ctx_id);
 
+	if (dev_priv->oa_pmu.sample_info_flags & I915_OA_SAMPLE_PID)
+		node_size += sizeof(struct drm_i915_oa_node_pid);
+
 	/* node size has to be aligned to 64 bytes, since only 64 byte aligned
 	 * addresses can be given to OA unit for dumping OA reports */
 	node_size = ALIGN(node_size, 64);
@@ -833,6 +847,9 @@ static int i915_oa_event_init(struct perf_event *event)
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
 		dev_priv->oa_pmu.multiple_ctx_mode = true;
+		if (oa_attr.sample_pid)
+			dev_priv->oa_pmu.sample_info_flags |=
+					I915_OA_SAMPLE_PID;
 	}
 
 	report_format = oa_attr.format;
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index e97b2fd..65e8297 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -93,7 +93,8 @@ typedef struct _drm_i915_oa_attr {
 
 	__u64 single_context : 1,
 		multiple_context_mode:1,
-		__reserved_1:62;
+		sample_pid:1,
+		__reserved_1:61;
 } drm_i915_oa_attr_t;
 
 /* Header for PERF_RECORD_DEVICE type events */
@@ -128,6 +129,11 @@ struct drm_i915_oa_node_ctx_id {
 	__u32 pad;
 };
 
+struct drm_i915_oa_node_pid {
+	__u32 pid;
+	__u32 pad;
+};
+
 /* Each region is a minimum of 16k, and there are at most 255 of them.
  */
 #define I915_NR_TEX_REGIONS 255	/* table size 2k - maximum due to use
-- 
1.8.5.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-07-15  8:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  8:46 [RFC 0/8] Introduce framework to forward multi context OA snapshots sourab.gupta
2015-07-15  8:46 ` [RFC 1/8] drm/i915: Have globally unique context ids, as opposed to drm file specific sourab.gupta
2015-07-15  9:54   ` Chris Wilson
2015-07-15 10:31     ` Chris Wilson
2015-07-15 12:36       ` Daniel Vetter
2015-07-15  8:46 ` [RFC 2/8] drm/i915: Introduce mode for capture of multi ctx OA reports synchronized with RCS sourab.gupta
2015-07-15  8:46 ` [RFC 3/8] drm/i915: Add mechanism for forwarding CS based OA counter snapshots through perf sourab.gupta
2015-07-15  8:46 ` [RFC 4/8] drm/i915: Forward periodic and CS based OA reports sorted acc to timestamps sourab.gupta
2015-07-15  8:47 ` [RFC 5/8] drm/i915: Handle event stop and destroy for commands in flight sourab.gupta
2015-07-15  8:47 ` [RFC 6/8] drm/i915: Insert commands for capture of OA counters in the ring sourab.gupta
2015-07-15 10:26   ` Chris Wilson
2015-07-15  8:47 ` sourab.gupta [this message]
2015-07-15  8:47 ` [RFC 8/8] drm/i915: Add support to add execbuffer tags to OA counter reports sourab.gupta
2015-07-15 10:02   ` Chris Wilson
2015-07-15 10:04   ` Chris Wilson
2015-07-15 10:06   ` Chris Wilson
  -- strict thread matches above, loose matches on Subject: below --
2015-08-05  5:52 [RFC 0/8] Introduce framework to forward multi context OA snapshots sourab.gupta
2015-08-05  5:52 ` [RFC 7/8] drm/i915: Add support for having pid output with OA report sourab.gupta

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=1436950023-13940-8-git-send-email-sourab.gupta@intel.com \
    --to=sourab.gupta@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=insoo.woo@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jabin.wu@intel.com \
    /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