Skip to content

Commit fd89a65

Browse files
Davidlohr Buesotorvalds
authored andcommitted
powerpc/oprofile: reduce mmap_sem hold for exe_file
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1116334 commit fd89a65

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎arch/powerpc/oprofile/cell/spu_task_sync.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/kref.h>
2323
#include <linux/mm.h>
2424
#include <linux/fs.h>
25+
#include <linux/file.h>
2526
#include <linux/module.h>
2627
#include <linux/notifier.h>
2728
#include <linux/numa.h>
@@ -322,18 +323,20 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
322323
unsigned long app_cookie = 0;
323324
unsigned int my_offset = 0;
324325
struct vm_area_struct *vma;
326+
struct file *exe_file;
325327
struct mm_struct *mm = spu->mm;
326328

327329
if (!mm)
328330
goto out;
329331

330-
down_read(&mm->mmap_sem);
331-
332-
if (mm->exe_file) {
333-
app_cookie = fast_get_dcookie(&mm->exe_file->f_path);
334-
pr_debug("got dcookie for %pD\n", mm->exe_file);
332+
exe_file = get_mm_exe_file(mm);
333+
if (exe_file) {
334+
app_cookie = fast_get_dcookie(&exe_file->f_path);
335+
pr_debug("got dcookie for %pD\n", exe_file);
336+
fput(exe_file);
335337
}
336338

339+
down_read(&mm->mmap_sem);
337340
for (vma = mm->mmap; vma; vma = vma->vm_next) {
338341
if (vma->vm_start > spu_ref || vma->vm_end <= spu_ref)
339342
continue;

0 commit comments

Comments
 (0)