All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v2] mm/msync: tweak tmpfs patch for syscall msync
@ 2012-04-26  2:46 Kang Kai
  2012-04-26  2:46 ` [PATCH " Kang Kai
  2012-04-26 18:50 ` [Patch " Bruce Ashfield
  0 siblings, 2 replies; 3+ messages in thread
From: Kang Kai @ 2012-04-26  2:46 UTC (permalink / raw)
  To: bruce.ashfield; +Cc: yocto

Hi Bruce,

This Version 2 just update the commit header.

Regards,
Kai



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] mm/msync: tweak tmpfs patch for syscall msync
  2012-04-26  2:46 [Patch v2] mm/msync: tweak tmpfs patch for syscall msync Kang Kai
@ 2012-04-26  2:46 ` Kang Kai
  2012-04-26 18:50 ` [Patch " Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Kang Kai @ 2012-04-26  2:46 UTC (permalink / raw)
  To: bruce.ashfield; +Cc: yocto

Commit 1c3ae5441 "mm: msync: fix issues of sys_msync on tmpfs"
fixes the problem that sys_msync fails with tmpfs on MIPS CPU which
has feature "cache alias".

But it makes POSIX test cases mlockall/3-6 3-7 fail on MIPS.
Case mlockall/3-6 creates a share memory, and maps it to memory.
  fd = shm_open(SHM_NAME, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
  foo = mmap(NULL, BUF_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);
Then calls mlockall to lock all of the virtual address space:
  if (mlockall(MCL_CURRENT) == -1) {
At last tests whether the virtual address spaces are locked:
  page_ptr = (void*) ((long)foo - ((long)foo % page_size));
  result = msync(page_ptr, page_size, MS_SYNC|MS_INVALIDATE);
It espects msync returns -1 with EBUSY but returns 0.
Case mlockall/3-7 creates a normal file to mmap, and it fails too.

Tweak the patch to:
1 Moved the CONFIG_TMPFS block down in the loop so that the normal
  vma flag checking will perform.
2 There may be other VMAs in the list after this VMA which belongs
  to tmpfs file, and we should sync them after the tmpfs one. So
  remove the break loop clauses.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 mm/msync.c |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/mm/msync.c b/mm/msync.c
index ced6215..31cd311 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -60,23 +60,6 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 	down_read(&mm->mmap_sem);
 	vma = find_vma(mm, start);
 
-#ifdef CONFIG_TMPFS
-	/*
-	 * For tmpfs, no matter which flag(ASYNC or SYNC) gets from msync,
-	 * there is not so much thing to do for CPUs without cache alias,
-	 * But for some CPUs with cache alias, msync has to flush cache
-	 * explicitly, which makes sure the data coherency between memory
-	 * file and cache.
-	 */
-	file =  vma->vm_file;
-	if (file && (file->f_op == &shmem_file_operations)) {
-		if(CPU_HAS_CACHE_ALIAS)
-			flush_cache_range(vma, start, start+len);
-		error = 0;
-		goto out_unlock;
-	}
-#endif
-
 	for (;;) {
 
 		/* Still start < end. */
@@ -97,6 +80,19 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 			goto out_unlock;
 		}
 		file = vma->vm_file;
+#ifdef CONFIG_TMPFS
+		/*
+		 * For tmpfs, no matter which flag(ASYNC or SYNC) gets from msync,
+		 * there is not so much thing to do for CPUs without cache alias,
+		 * But for some CPUs with cache alias, msync has to flush cache
+		 * explicitly, which makes sure the data coherency between memory
+		 * file and cache.
+		 */
+		if (file && (file->f_op == &shmem_file_operations)) {
+			if(CPU_HAS_CACHE_ALIAS)
+				flush_cache_range(vma, start, start+len);
+		}
+#endif
 		start = vma->vm_end;
 		if ((flags & MS_SYNC) && file &&
 				(vma->vm_flags & VM_SHARED)) {
-- 
1.7.5.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch v2] mm/msync: tweak tmpfs patch for syscall msync
  2012-04-26  2:46 [Patch v2] mm/msync: tweak tmpfs patch for syscall msync Kang Kai
  2012-04-26  2:46 ` [PATCH " Kang Kai
@ 2012-04-26 18:50 ` Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2012-04-26 18:50 UTC (permalink / raw)
  To: Kang Kai; +Cc: yocto

On 12-04-25 10:46 PM, Kang Kai wrote:
> Hi Bruce,
>
> This Version 2 just update the commit header.

Looks good. Merging to the routerstation pro branch.

Bruce

>
> Regards,
> Kai
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-26 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-26  2:46 [Patch v2] mm/msync: tweak tmpfs patch for syscall msync Kang Kai
2012-04-26  2:46 ` [PATCH " Kang Kai
2012-04-26 18:50 ` [Patch " Bruce Ashfield

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.