[PATCH] madvise_need_mmap_write() usage

Subsystems: memory management, memory mapping - madvise (memory advice), the rest

STALE7034d

4 messages, 3 authors, 2007-06-18 · open the first message on its own page

[PATCH] madvise_need_mmap_write() usage

From: Jason Baron <hidden>
Date: 2007-06-15 15:23:26

hi,

i was just looking at the new madvise_need_mmap_write() call...can we
avoid an extra case statement and function call as follows?

thanks,

-Jason


Signed-off-by: Jason Baron <redacted>
diff --git a/mm/madvise.c b/mm/madvise.c
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -287,9 +287,10 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
 	struct vm_area_struct * vma, *prev;
 	int unmapped_error = 0;
 	int error = -EINVAL;
+	int write;
 	size_t len;
 
-	if (madvise_need_mmap_write(behavior))
+	if (write = madvise_need_mmap_write(behavior))
 		down_write(&current->mm->mmap_sem);
 	else
 		down_read(&current->mm->mmap_sem);
@@ -354,7 +355,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
 			vma = find_vma(current->mm, start);
 	}
 out:
-	if (madvise_need_mmap_write(behavior))
+	if (write)
 		up_write(&current->mm->mmap_sem);
 	else
 		up_read(&current->mm->mmap_sem);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

Re: [PATCH] madvise_need_mmap_write() usage

From: Christoph Hellwig <hch@infradead.org>
Date: 2007-06-16 19:41:39

On Fri, Jun 15, 2007 at 11:20:31AM -0400, Jason Baron wrote:
hi,

i was just looking at the new madvise_need_mmap_write() call...can we
avoid an extra case statement and function call as follows?
Sounds like a good idea, but please move the assignment out of the
conditional.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

Re: [PATCH] madvise_need_mmap_write() usage

From: Jason Baron <hidden>
Date: 2007-06-18 15:38:50

On Sat, 16 Jun 2007, Christoph Hellwig wrote:
On Fri, Jun 15, 2007 at 11:20:31AM -0400, Jason Baron wrote:
quoted
hi,

i was just looking at the new madvise_need_mmap_write() call...can we
avoid an extra case statement and function call as follows?
Sounds like a good idea, but please move the assignment out of the
conditional.
ok, here's an updated version:


Signed-off-by: Jason Baron <redacted>

diff --git a/mm/madvise.c b/mm/madvise.c
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -287,9 +287,11 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
 	struct vm_area_struct * vma, *prev;
 	int unmapped_error = 0;
 	int error = -EINVAL;
+	int write;
 	size_t len;
 
-	if (madvise_need_mmap_write(behavior))
+	write = madvise_need_mmap_write(behavior);
+	if (write)
 		down_write(&current->mm->mmap_sem);
 	else
 		down_read(&current->mm->mmap_sem);
@@ -354,7 +356,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
 			vma = find_vma(current->mm, start);
 	}
 out:
-	if (madvise_need_mmap_write(behavior))
+	if (write)
 		up_write(&current->mm->mmap_sem);
 	else
 		up_read(&current->mm->mmap_sem);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

Re: [PATCH] madvise_need_mmap_write() usage

From: Nish Aravamudan <hidden>
Date: 2007-06-18 16:52:17

On 6/18/07, Jason Baron [off-list ref] wrote:
On Sat, 16 Jun 2007, Christoph Hellwig wrote:
quoted
On Fri, Jun 15, 2007 at 11:20:31AM -0400, Jason Baron wrote:
quoted
hi,

i was just looking at the new madvise_need_mmap_write() call...can we
avoid an extra case statement and function call as follows?
Sounds like a good idea, but please move the assignment out of the
conditional.
ok, here's an updated version:
You should always append the full patch, both the diff and the
rationale, I think. Even though it's quoted above, might make less
work for Andrew to pull in.

Thanks,
Nish

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help