* [PATCH] madvise_need_mmap_write() usage
@ 2007-06-15 15:20 Jason Baron
2007-06-16 19:41 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Jason Baron @ 2007-06-15 15:20 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-mm, nickpiggin, Rik van Riel
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 <jbaron@redhat.com>
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(¤t->mm->mmap_sem);
else
down_read(¤t->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(¤t->mm->mmap_sem);
else
up_read(¤t->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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] madvise_need_mmap_write() usage
2007-06-15 15:20 [PATCH] madvise_need_mmap_write() usage Jason Baron
@ 2007-06-16 19:41 ` Christoph Hellwig
2007-06-18 15:35 ` Jason Baron
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2007-06-16 19:41 UTC (permalink / raw)
To: Jason Baron; +Cc: linux-kernel, linux-mm, nickpiggin, Rik van Riel
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] madvise_need_mmap_write() usage
2007-06-16 19:41 ` Christoph Hellwig
@ 2007-06-18 15:35 ` Jason Baron
2007-06-18 16:51 ` Nish Aravamudan
0 siblings, 1 reply; 4+ messages in thread
From: Jason Baron @ 2007-06-18 15:35 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, linux-mm, nickpiggin, Rik van Riel
On Sat, 16 Jun 2007, Christoph Hellwig wrote:
> 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.
>
ok, here's an updated version:
Signed-off-by: Jason Baron <jbaron@redhat.com>
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(¤t->mm->mmap_sem);
else
down_read(¤t->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(¤t->mm->mmap_sem);
else
up_read(¤t->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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] madvise_need_mmap_write() usage
2007-06-18 15:35 ` Jason Baron
@ 2007-06-18 16:51 ` Nish Aravamudan
0 siblings, 0 replies; 4+ messages in thread
From: Nish Aravamudan @ 2007-06-18 16:51 UTC (permalink / raw)
To: Jason Baron
Cc: Christoph Hellwig, linux-kernel, linux-mm, nickpiggin, Rik van Riel
On 6/18/07, Jason Baron <jbaron@redhat.com> wrote:
>
> On Sat, 16 Jun 2007, Christoph Hellwig wrote:
>
> > 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.
> >
>
> 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>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-06-18 16:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-15 15:20 [PATCH] madvise_need_mmap_write() usage Jason Baron
2007-06-16 19:41 ` Christoph Hellwig
2007-06-18 15:35 ` Jason Baron
2007-06-18 16:51 ` Nish Aravamudan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox