linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nikita <sh1r4s3@mail.si-head.nl>
To: Vlastimil Babka <vbabka@suse.cz>, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start
Date: Tue, 20 Oct 2020 17:38:09 +0300	[thread overview]
Message-ID: <92411D90-AD5D-44B9-8F52-C2FA222BB4EB@mail.si-head.nl> (raw)
In-Reply-To: <aaaaadff-977a-0e53-afe5-044889455fd6@suse.cz>

Hi!

> On 20 Oct 2020, at 13:19, Vlastimil Babka <vbabka@suse.cz> wrote:
> 
> On 10/12/20 6:09 PM, Nikita Ermakov wrote:
>> Exit from the loop over the VMA in the case when the flags
>> contain only an MS_ASYNC and start < vm_start. In this case msync()
>> would return with -ENOMEM anyway so make it return early.
>> Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
> 
> AFAICS it can still return -EBUSY if there's MS_INVALIDATE and a mlocked vma. This is all subtle and I don't think we should risk breaking something for this optimization.
> 
Yes, it could. But in this patch the optimization works only in the case if the flag is MS_ASYNC. If the flag is (MS_ASYNC | MS_INVALIDATE).

>> ---
>>  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) {
>> +			if (flags == MS_ASYNC)
>> +				goto out_unlock;
>>  			start = vma->vm_start;
>>  			if (start >= end)
>>  				goto out_unlock;
>> base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8
> 



  reply	other threads:[~2020-10-20 14:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 16:09 [PATCH] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start Nikita Ermakov
2020-10-20 10:19 ` Vlastimil Babka
2020-10-20 14:38   ` Nikita [this message]
2020-10-20 15:03     ` Vlastimil Babka
2020-10-20 16:19       ` Nikita
2020-10-20 20:56         ` [PATCH v2] " Nikita Ermakov
2020-10-23 11:12           ` Vlastimil Babka
2020-10-25  9:29             ` [PATCH v3] " Nikita Ermakov
2020-10-25  9:38             ` [PATCH v2] " Nikita Ermakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92411D90-AD5D-44B9-8F52-C2FA222BB4EB@mail.si-head.nl \
    --to=sh1r4s3@mail.si-head.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).