All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Kuehling <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	oded.gabbay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: Felix Kuehling <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 08/14] drm/amdkfd: Get reference to lead_thread task struct
Date: Mon, 27 Nov 2017 18:29:50 -0500	[thread overview]
Message-ID: <1511825396-24579-9-git-send-email-Felix.Kuehling@amd.com> (raw)
In-Reply-To: <1511825396-24579-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>

Increment the kfd_process.lead_thread's reference counter to make
it safe to dereference. This is needed for getting a safe reference
to the process' mm_struct.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 99c18ee..660d8bc 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -24,6 +24,7 @@
 #include <linux/log2.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
+#include <linux/sched/task.h>
 #include <linux/slab.h>
 #include <linux/amd-iommu.h>
 #include <linux/notifier.h>
@@ -191,6 +192,8 @@ static void kfd_process_wq_release(struct work_struct *work)
 
 	mutex_destroy(&p->mutex);
 
+	put_task_struct(p->lead_thread);
+
 	kfree(p);
 
 	kfree(work);
@@ -342,6 +345,7 @@ static struct kfd_process *create_process(const struct task_struct *thread)
 			(uintptr_t)process->mm);
 
 	process->lead_thread = thread->group_leader;
+	get_task_struct(process->lead_thread);
 
 	INIT_LIST_HEAD(&process->per_device_data);
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-11-27 23:29 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 23:29 [PATCH 00/14] KFD upstreaming 20171127 Felix Kuehling
     [not found] ` <1511825396-24579-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-11-27 23:29   ` [PATCH 01/14] drm/amdgpu: fix get_max_engine_clock_in_mhz Felix Kuehling
     [not found]     ` <1511825396-24579-2-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-11-30 16:03       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 02/14] drm/amdkfd: Add crash protection in debugger register path Felix Kuehling
     [not found]     ` <1511825396-24579-3-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-11-30 16:14       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 03/14] drm/amdkfd: map multiple processes to HW scheduler Felix Kuehling
     [not found]     ` <1511825396-24579-4-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:04       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 04/14] drm/amdkfd: Fix oversubscription accounting Felix Kuehling
     [not found]     ` <1511825396-24579-5-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:10       ` Oded Gabbay
     [not found]         ` <CAFCwf11eM8pYmBOHdD1o4NVDj9nesJwp3Ny9dGukzstM5iP=Ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-05 19:27           ` Felix Kuehling
     [not found]             ` <9f625c72-a44e-6560-1d2b-6d998ad0e2e2-5C7GfCeVMHo@public.gmane.org>
2017-12-10  9:00               ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 05/14] drm/amdgpu: Fix definition of KFD_CIK_SDMA_QUEUE_OFFSET Felix Kuehling
     [not found]     ` <1511825396-24579-6-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:15       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 06/14] drm/amdgpu: Add kfd2kgd APIs for dumping HQDs Felix Kuehling
     [not found]     ` <1511825396-24579-7-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:23       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 07/14] drm/amdkfd: Add debugfs support to KFD Felix Kuehling
     [not found]     ` <1511825396-24579-8-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:27       ` Oded Gabbay
2017-11-27 23:29   ` Felix Kuehling [this message]
     [not found]     ` <1511825396-24579-9-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-05  8:43       ` [PATCH 08/14] drm/amdkfd: Get reference to lead_thread task struct Oded Gabbay
     [not found]         ` <CAFCwf12ELNgXW7bL+zb2F3v1XWn914maeRP3e3M+3U15B521wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-05 19:14           ` Felix Kuehling
     [not found]             ` <e23118b1-eb9b-6a2b-e937-09747b4a9aac-5C7GfCeVMHo@public.gmane.org>
2017-12-10  9:04               ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 09/14] drm/amdkfd: Make kfd_process reference counted Felix Kuehling
     [not found]     ` <1511825396-24579-10-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-10 10:00       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 10/14] drm/amdkfd: Use ref count to prevent kfd_process destruction Felix Kuehling
     [not found]     ` <1511825396-24579-11-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-11-28  9:52       ` Christian König
     [not found]         ` <7fb6a8a7-5616-95d6-c2c9-3b69a75a3613-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-01 21:17           ` Felix Kuehling
     [not found]             ` <ab143937-aca3-9f3e-b6f4-4d354fde3c05-5C7GfCeVMHo@public.gmane.org>
2017-12-10  9:59               ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 11/14] drm/amdkfd: Return NULL if kfd_lookup_process_by_pasid fails Felix Kuehling
     [not found]     ` <1511825396-24579-12-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-10 10:12       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 12/14] drm/amdkfd: Reduce nesting in kfd_create_process_device_data Felix Kuehling
     [not found]     ` <1511825396-24579-13-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-10 10:13       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 13/14] drm/amdkfd: Factor PDD destruction out of kfd_process_wq_release Felix Kuehling
     [not found]     ` <1511825396-24579-14-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-10 10:15       ` Oded Gabbay
2017-11-27 23:29   ` [PATCH 14/14] drm/amdkfd: Simplify locking during process creation Felix Kuehling
     [not found]     ` <1511825396-24579-15-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2017-12-10 10:22       ` 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=1511825396-24579-9-git-send-email-Felix.Kuehling@amd.com \
    --to=felix.kuehling-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=oded.gabbay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.