diff mbox series

[v2] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start

Message ID 20201020205640.48257-1-sh1r4s3@mail.si-head.nl (mailing list archive)
State New, archived
Headers show
Series [v2] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start | expand

Commit Message

Nikita Ermakov Oct. 20, 2020, 8:56 p.m. UTC
If an unmapped region was found and the flag is MS_ASYNC (without
MS_INVALIDATE) there is nothing to do and the result would be always
-ENOMEM, so return immediately.

Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
---
 mm/msync.c | 2 ++
 1 file changed, 2 insertions(+)


base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8

Comments

Vlastimil Babka Oct. 23, 2020, 11:12 a.m. UTC | #1
On 10/20/20 10:56 PM, Nikita Ermakov wrote:
> If an unmapped region was found and the flag is MS_ASYNC (without
> MS_INVALIDATE) there is nothing to do and the result would be always
> -ENOMEM, so return immediately.
> 
> Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
> ---
>   mm/msync.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/mm/msync.c b/mm/msync.c
> index 69c6d2029531..ed20c3621d4c 100644
> --- a/mm/msync.c
> +++ b/mm/msync.c
> @@ -69,6 +69,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
>   			goto out_unlock;
>   		/* Here start < vma->vm_end. */
>   		if (start < vma->vm_start) {

I hoped it would become a code comment.

> +			if (flags == MS_ASYNC)
> +				goto out_unlock;
>   			start = vma->vm_start;
>   			if (start >= end)
>   				goto out_unlock;
> 
> base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8
>
Nikita Ermakov Oct. 25, 2020, 9:38 a.m. UTC | #2
> On 23 Oct 2020, at 14:12, Vlastimil Babka <vbabka@suse.cz> wrote:
> 
> On 10/20/20 10:56 PM, Nikita Ermakov wrote:
>> If an unmapped region was found and the flag is MS_ASYNC (without
>> MS_INVALIDATE) there is nothing to do and the result would be always
>> -ENOMEM, so return immediately.
>> Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
>> ---
>>  mm/msync.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> diff --git a/mm/msync.c b/mm/msync.c
>> index 69c6d2029531..ed20c3621d4c 100644
>> --- a/mm/msync.c
>> +++ b/mm/msync.c
>> @@ -69,6 +69,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
>>  			goto out_unlock;
>>  		/* Here start < vma->vm_end. */
>>  		if (start < vma->vm_start) {
> 
> I hoped it would become a code comment.
> 

Ops, I'm sorry. I've implemented this suggestion in the v3.

>> +			if (flags == MS_ASYNC)
>> +				goto out_unlock;
>>  			start = vma->vm_start;
>>  			if (start >= end)
>>  				goto out_unlock;
>> base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8

--
Thanks,
Nikita
B8 00 4C CD 21
diff mbox series

Patch

diff --git a/mm/msync.c b/mm/msync.c
index 69c6d2029531..ed20c3621d4c 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -69,6 +69,8 @@  SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 			goto out_unlock;
 		/* Here start < vma->vm_end. */
 		if (start < vma->vm_start) {
+			if (flags == MS_ASYNC)
+				goto out_unlock;
 			start = vma->vm_start;
 			if (start >= end)
 				goto out_unlock;