LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Yuri Nudelman <ynudelman@habana.ai>
Subject: [PATCH 03/16] habanalabs: save pid per userptr
Date: Wed, 18 Aug 2021 16:39:09 +0300	[thread overview]
Message-ID: <20210818133922.63637-3-ogabbay@kernel.org> (raw)
In-Reply-To: <20210818133922.63637-1-ogabbay@kernel.org>

From: Yuri Nudelman <ynudelman@habana.ai>

Currently userptr endpoint in debugfs prints out virtual addresses
in the user process memory space, without specifying their owner process
ID. User space virtual address is meaningless without knowing the owner
process.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/misc/habanalabs/common/debugfs.c    | 8 ++++----
 drivers/misc/habanalabs/common/habanalabs.h | 2 ++
 drivers/misc/habanalabs/common/memory.c     | 1 +
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/habanalabs/common/debugfs.c b/drivers/misc/habanalabs/common/debugfs.c
index 2c587af28f9b..264424c96959 100644
--- a/drivers/misc/habanalabs/common/debugfs.c
+++ b/drivers/misc/habanalabs/common/debugfs.c
@@ -209,12 +209,12 @@ static int userptr_show(struct seq_file *s, void *data)
 		if (first) {
 			first = false;
 			seq_puts(s, "\n");
-			seq_puts(s, " user virtual address     size             dma dir\n");
+			seq_puts(s, " pid      user virtual address     size             dma dir\n");
 			seq_puts(s, "----------------------------------------------------------\n");
 		}
-		seq_printf(s,
-			"    0x%-14llx      %-10llu    %-30s\n",
-			userptr->addr, userptr->size, dma_dir[userptr->dir]);
+		seq_printf(s, " %-7d  0x%-14llx      %-10llu    %-30s\n",
+				userptr->pid, userptr->addr, userptr->size,
+				dma_dir[userptr->dir]);
 	}
 
 	spin_unlock(&dev_entry->userptr_spinlock);
diff --git a/drivers/misc/habanalabs/common/habanalabs.h b/drivers/misc/habanalabs/common/habanalabs.h
index d40778eccb14..b950b5140610 100644
--- a/drivers/misc/habanalabs/common/habanalabs.h
+++ b/drivers/misc/habanalabs/common/habanalabs.h
@@ -1452,6 +1452,7 @@ struct hl_ctx_mgr {
  * @sgt: pointer to the scatter-gather table that holds the pages.
  * @dir: for DMA unmapping, the direction must be supplied, so save it.
  * @debugfs_list: node in debugfs list of command submissions.
+ * @pid: the pid of the user process owning the memory
  * @addr: user-space virtual address of the start of the memory area.
  * @size: size of the memory area to pin & map.
  * @dma_mapped: true if the SG was mapped to DMA addresses, false otherwise.
@@ -1464,6 +1465,7 @@ struct hl_userptr {
 	struct sg_table		*sgt;
 	enum dma_data_direction dir;
 	struct list_head	debugfs_list;
+	pid_t			pid;
 	u64			addr;
 	u64			size;
 	u8			dma_mapped;
diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c
index a75207611b9b..2f990d185cfd 100644
--- a/drivers/misc/habanalabs/common/memory.c
+++ b/drivers/misc/habanalabs/common/memory.c
@@ -2276,6 +2276,7 @@ int hl_pin_host_memory(struct hl_device *hdev, u64 addr, u64 size,
 		return -EINVAL;
 	}
 
+	userptr->pid = current->pid;
 	userptr->sgt = kzalloc(sizeof(*userptr->sgt), GFP_KERNEL);
 	if (!userptr->sgt)
 		return -ENOMEM;
-- 
2.17.1


  parent reply	other threads:[~2021-08-18 13:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 13:39 [PATCH 01/16] habanalabs/gaudi: scrub HBM to a specific value Oded Gabbay
2021-08-18 13:39 ` [PATCH 02/16] habanalabs/gaudi: move scrubbing to late init Oded Gabbay
2021-08-18 13:39 ` Oded Gabbay [this message]
2021-08-18 13:39 ` [PATCH 04/16] habanalabs: fix mmu node address resolution in debugfs Oded Gabbay
2021-08-18 13:39 ` [PATCH 05/16] habanalabs/gaudi: minimize number of register reads Oded Gabbay
2021-08-18 13:39 ` [PATCH 06/16] habanalabs: update to latest firmware headers Oded Gabbay
2021-08-18 13:39 ` [PATCH 07/16] habanalabs/gaudi: increase boot fit timeout Oded Gabbay
2021-08-18 13:39 ` [PATCH 08/16] habanalabs/gaudi: restore user registers when context opens Oded Gabbay
2021-08-18 13:39 ` [PATCH 09/16] habanalabs/gaudi: add monitored SOBs to state dump Oded Gabbay
2021-08-18 13:39 ` [PATCH 10/16] habanalabs: modify multi-CS to wait on stream masters Oded Gabbay
2021-08-18 13:39 ` [PATCH 11/16] habanalabs/gaudi: fetch TPC/MME ECC errors from F/W Oded Gabbay
2021-08-18 13:39 ` [PATCH 12/16] habanalabs: add userptr_lookup node in debugfs Oded Gabbay
2021-08-18 13:39 ` [PATCH 13/16] habanalabs/gaudi: unmask out of bounds SLM access interrupt Oded Gabbay
2021-08-18 13:39 ` [PATCH 14/16] habanalabs/gaudi: define DC POWER for secured PMC Oded Gabbay
2021-08-18 13:39 ` [PATCH 15/16] habanalabs/gaudi: size should be printed in decimal Oded Gabbay
2021-08-18 13:39 ` [PATCH 16/16] habanalabs/gaudi: invalidate PMMU mem cache on init Oded Gabbay

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=20210818133922.63637-3-ogabbay@kernel.org \
    --to=ogabbay@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ynudelman@habana.ai \
    /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).