gpu: pvr: get proc name during process attach time
authorImre Deak <imre.deak@nokia.com>
Fri, 1 Apr 2011 15:05:39 +0000 (18:05 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:43:05 +0000 (21:43 +0300)
This will be needed by the upcoming patches where we need a cheap way
to get to the current process name.

Signed-off-by: Imre Deak <imre.deak@nokia.com>
Reviewed-by: Luc Verhaegen <libv@codethink.co.uk>
pvr/osfunc.c
pvr/osfunc.h
pvr/perproc.c
pvr/perproc.h

index c3c36ac..b14994c 100644 (file)
@@ -1122,6 +1122,16 @@ enum PVRSRV_ERROR OSCopyFromUser(void *pvProcess, void *pvDest,
                return PVRSRV_ERROR_GENERIC;
 }
 
+void get_proc_name(int pid, char *buf, size_t buf_size)
+{
+       struct task_struct *tsk;
+
+       rcu_read_lock();
+       tsk = pid_task(find_vpid(pid), PIDTYPE_PID);
+       strlcpy(buf, tsk->comm, buf_size);
+       rcu_read_unlock();
+}
+
 IMG_BOOL OSAccessOK(enum IMG_VERIFY_TEST eVerification,
                    const void __user *pvUserPtr, u32 ui32Bytes)
 {
index 0419d4f..158034c 100644 (file)
@@ -216,4 +216,6 @@ enum PVRSRV_ERROR OSAcquirePhysPageAddr(void *pvCPUVAddr, u32 ui32Bytes,
                                        void **phOSWrapMem);
 enum PVRSRV_ERROR OSReleasePhysPageAddr(void *hOSWrapMem);
 
+void get_proc_name(int pid, char *buf, size_t buf_size);
+
 #endif
index d0d4f4c..1aae887 100644 (file)
@@ -134,6 +134,9 @@ enum PVRSRV_ERROR PVRSRVPerProcessDataConnect(u32 ui32PID)
                OSMemSet(psPerProc, 0, sizeof(*psPerProc));
                psPerProc->hBlockAlloc = hBlockAlloc;
 
+               get_proc_name(ui32PID, psPerProc->name,
+                             sizeof(psPerProc->name));
+
                if (!HASH_Insert(psHashTab, (u32) ui32PID, (u32)psPerProc)) {
                        PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: "
                           "Couldn't insert per-process data into hash table");
index a89b0e4..3a8810c 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef __PERPROC_H__
 #define __PERPROC_H__
 
+#include <linux/sched.h>
+
 #include "img_types.h"
 #include "resman.h"
 
@@ -34,6 +36,7 @@
 
 struct PVRSRV_PER_PROCESS_DATA {
        u32 ui32PID;
+       char name[TASK_COMM_LEN];
        void *hBlockAlloc;
        struct RESMAN_CONTEXT *hResManContext;
        void *hPerProcData;