From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25379C388F7 for ; Sun, 25 Oct 2020 09:30:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 06BB82225E for ; Sun, 25 Oct 2020 09:30:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06BB82225E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mail.si-head.nl Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 311646B005D; Sun, 25 Oct 2020 05:30:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C1216B0062; Sun, 25 Oct 2020 05:30:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 189936B0068; Sun, 25 Oct 2020 05:30:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id DFC976B005D for ; Sun, 25 Oct 2020 05:30:40 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 755018249980 for ; Sun, 25 Oct 2020 09:30:40 +0000 (UTC) X-FDA: 77409927840.15.women42_2402a3f27269 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 4C1901814B0C1 for ; Sun, 25 Oct 2020 09:30:40 +0000 (UTC) X-HE-Tag: women42_2402a3f27269 X-Filterd-Recvd-Size: 2256 Received: from mail.si-head.nl (si-head.tilaa.cloud [37.252.121.114]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Sun, 25 Oct 2020 09:30:39 +0000 (UTC) Received: from localhost.localdomain (unknown [193.169.4.174]) by mail.si-head.nl (Postfix) with ESMTPSA id 555DFC12A7; Sun, 25 Oct 2020 12:30:37 +0300 (MSK) From: Nikita Ermakov To: linux-mm@kvack.org Cc: Nikita Ermakov , Andrew Morton , Vlastimil Babka Subject: [PATCH v3] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start Date: Sun, 25 Oct 2020 12:29:01 +0300 Message-Id: <20201025092901.56399-1-sh1r4s3@mail.si-head.nl> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- mm/msync.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/msync.c b/mm/msync.c index 69c6d2029531..137d1c104f3e 100644 --- a/mm/msync.c +++ b/mm/msync.c @@ -55,7 +55,9 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, le= n, int, flags) goto out; /* * If the interval [start,end) covers some unmapped address ranges, - * just ignore them, but return -ENOMEM at the end. + * just ignore them, but return -ENOMEM at the end. Besides, if the + * flag is MS_ASYNC (w/o MS_INVALIDATE) the result would be -ENOMEM + * anyway and there is nothing left to do, so return immediately. */ mmap_read_lock(mm); vma =3D find_vma(mm, start); @@ -69,6 +71,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, le= n, int, flags) goto out_unlock; /* Here start < vma->vm_end. */ if (start < vma->vm_start) { + if (flags =3D=3D MS_ASYNC) + goto out_unlock; start =3D vma->vm_start; if (start >=3D end) goto out_unlock; base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8 --=20 2.28.0