]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/oprofile: reduce mmap_sem hold for exe_file
authorDavidlohr Bueso <dave@stgolabs.net>
Tue, 7 Apr 2015 23:57:05 +0000 (09:57 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 9 Apr 2015 09:07:11 +0000 (19:07 +1000)
In the future mm->exe_file will be done without mmap_sem serialization,
thus isolate and reorganize the related code to make the transition
easier.  Good users will, make use of the more standard get_mm_exe_file(),
requiring only holding the mmap_sem to read the value, and relying on
reference counting to make sure that the exe file won't dissappear
underneath us while getting the dcookie.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Robert Richter <rric@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/powerpc/oprofile/cell/spu_task_sync.c

index 1c27831df1ac4b70cc24c680b2e7f432bf20e945..ed7b0977072adedde84af9bf72577ace97a5f143 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kref.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/file.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
 #include <linux/numa.h>
@@ -322,18 +323,20 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
        unsigned long app_cookie = 0;
        unsigned int my_offset = 0;
        struct vm_area_struct *vma;
+       struct file *exe_file;
        struct mm_struct *mm = spu->mm;
 
        if (!mm)
                goto out;
 
-       down_read(&mm->mmap_sem);
-
-       if (mm->exe_file) {
-               app_cookie = fast_get_dcookie(&mm->exe_file->f_path);
-               pr_debug("got dcookie for %pD\n", mm->exe_file);
+       exe_file = get_mm_exe_file(mm);
+       if (exe_file) {
+               app_cookie = fast_get_dcookie(&exe_file->f_path);
+               pr_debug("got dcookie for %pD\n", exe_file);
+               fput(exe_file);
        }
 
+       down_read(&mm->mmap_sem);
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                if (vma->vm_start > spu_ref || vma->vm_end <= spu_ref)
                        continue;