Re: Flushing whole page instead of work for ptrace

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roland McGrath
Date: Tuesday, November 30, 2010 - 4:32 pm

This is a VM question more than a ptrace question.  
I can't give you any authoritative answers about the VM issues.

Documentation/cachetlb.txt says:

	Any time the kernel writes to a page cache page, _OR_
	the kernel is about to read from a page cache page and
	user space shared/writable mappings of this page potentially
	exist, this routine is called.

In your case, the kernel is only reading (write=0 passed to
access_process_vm and get_user_pages).  In normal situations,
the page in question will have only a private and read-only
mapping in user space.  So the call should not be required in
these cases--if the code can tell that's so.

Perhaps something like the following would be safe.
But you really need some VM folks to tell you for sure.

diff --git a/mm/memory.c b/mm/memory.c
index 02e48aa..2864ee7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1484,7 +1484,8 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 				pages[i] = page;
 
 				flush_anon_page(vma, page, start);
-				flush_dcache_page(page);
+				if ((vm_flags & VM_WRITE) || (vma->vm_flags & VM_SHARED)
+					flush_dcache_page(page);
 			}
 			if (vmas)
 				vmas[i] = vma;


Thanks,
Roland
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Flushing whole page instead of work for ptrace, Michal Simek, (Fri Nov 26, 5:31 am)
Re: Flushing whole page instead of work for ptrace, Roland McGrath, (Tue Nov 30, 4:32 pm)
Re: Flushing whole page instead of work for ptrace, Michal Simek, (Wed Dec 1, 10:10 am)
Re: Flushing whole page instead of work for ptrace, David Miller, (Wed Dec 1, 10:57 am)
Re: Flushing whole page instead of work for ptrace, Oleg Nesterov, (Fri Dec 3, 8:00 am)
Re: Flushing whole page instead of work for ptrace, Minchan Kim, (Fri Dec 3, 9:28 am)
Re: Flushing whole page instead of work for ptrace, Oleg Nesterov, (Fri Dec 3, 10:07 am)
Re: Flushing whole page instead of work for ptrace, Minchan Kim, (Sat Dec 4, 7:57 am)