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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>

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.

---
  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







[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux