From f4b77e465648e87b19a7df4bb2a121ac8ac1b851 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Thu, 16 Jun 2016 17:31:45 -0700 Subject: gpu: nvgpu: process granularity for FECS traces When processing FECS traces, a hash table is used to retrieve the 'pid' of the process that created the channel/TSG. Report process identifer (aka tgid in kernel) instead of thread identifier (aka pid) for FECS traces. Bug 1736423 Change-Id: I54cb9d298b9fe3e1cccdd7145604cd01c5758c9d Signed-off-by: Thomas Fleury Reviewed-on: http://git-master/r/1166501 (cherry picked from commit f7fd1f6d7ad0753b787ec20604a08a1f4882fe6f) Reviewed-on: http://git-master/r/1168728 (cherry picked from commit 97a62e5b89352fce576f1bca71b38bf2242ff047) Reviewed-on: http://git-master/r/1177823 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Richard Zhao GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 1 + drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 1 + drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c | 2 +- drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c | 6 +++++- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 2 +- drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index e631b836..d5457d10 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -1171,6 +1171,7 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, * alive and used (i.e. get-able) yet */ ch->pid = current->pid; + ch->tgid = current->tgid; /* process granularity for FECS traces */ /* By default, channel is regular (non-TSG) channel */ ch->tsgid = NVGPU_INVALID_TSG_ID; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index c5a1bd24..4b5fe1b3 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -117,6 +117,7 @@ struct channel_gk20a { bool vpr; bool cde; pid_t pid; + pid_t tgid; struct mutex ioctl_lock; int tsgid; diff --git a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c index d43c06be..1f18d9cf 100644 --- a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c @@ -657,7 +657,7 @@ void gk20a_ctxsw_trace_channel_reset(struct gk20a *g, struct channel_gk20a *ch) .vmid = 0, .tag = NVGPU_CTXSW_TAG_ENGINE_RESET, .context_id = 0, - .pid = ch->pid, + .pid = ch->tgid, }; if (!g->ctxsw_trace) diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c index 15e645f2..abf1cc55 100644 --- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c @@ -631,10 +631,14 @@ static int gk20a_fecs_trace_bind_channel(struct gk20a *g, GK20A_FECS_TRACE_NUM_RECORDS)); gk20a_mem_end(g, mem); + + /* pid (process identifier) in user space, corresponds to tgid (thread + * group id) in kernel space. + */ if (gk20a_is_channel_marked_as_tsg(ch)) pid = tsg_gk20a_from_ch(ch)->tgid; else - pid = ch->pid; + pid = ch->tgid; gk20a_fecs_trace_hash_add(g, context_ptr, pid); return 0; diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index 8c82fc68..5133f86a 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -2999,7 +2999,7 @@ static int gk20a_fifo_sched_debugfs_seq_show( seq_printf(s, "%-8d %-8d %-8d %-9d %-8d %-10d %-8d %-8d\n", ch->hw_chid, ch->tsgid, - ch->pid, + ch->tgid, tsg ? tsg->timeslice_us : ch->timeslice_us, ch->timeout_ms_max, ch->interleave_level, diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 29692573..8d3a5e9f 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c @@ -74,7 +74,7 @@ static int vgpu_channel_alloc_inst(struct gk20a *g, struct channel_gk20a *ch) msg.cmd = TEGRA_VGPU_CMD_CHANNEL_ALLOC_HWCTX; msg.handle = platform->virt_handle; p->id = ch->hw_chid; - p->pid = (u64)current->pid; + p->pid = (u64)current->tgid; err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); if (err || msg.ret) { gk20a_err(dev_from_gk20a(g), "fail"); -- cgit v1.2.2