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=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E61F3C388F7 for ; Tue, 20 Oct 2020 14:38:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D47A92224F for ; Tue, 20 Oct 2020 14:38:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D47A92224F 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 38E2F6B0062; Tue, 20 Oct 2020 10:38:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33D796B006C; Tue, 20 Oct 2020 10:38:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DDDD6B0072; Tue, 20 Oct 2020 10:38:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id E1E8C6B0062 for ; Tue, 20 Oct 2020 10:38:13 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 891F71EE6 for ; Tue, 20 Oct 2020 14:38:13 +0000 (UTC) X-FDA: 77392558866.05.bomb22_621294b27240 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 61E2918020B20 for ; Tue, 20 Oct 2020 14:38:13 +0000 (UTC) X-HE-Tag: bomb22_621294b27240 X-Filterd-Recvd-Size: 2395 Received: from mail.si-head.nl (si-head.tilaa.cloud [37.252.121.114]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 14:38:12 +0000 (UTC) Received: from [IPv6:::1] (si-head.tilaa.cloud [37.252.121.114]) by mail.si-head.nl (Postfix) with ESMTPSA id 994AFC16A0; Tue, 20 Oct 2020 17:38:10 +0300 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: [PATCH] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start From: Nikita In-Reply-To: Date: Tue, 20 Oct 2020 17:38:09 +0300 Cc: Andrew Morton Content-Transfer-Encoding: quoted-printable Message-Id: <92411D90-AD5D-44B9-8F52-C2FA222BB4EB@mail.si-head.nl> References: <20201012160911.6282-1-sh1r4s3@mail.si-head.nl> To: Vlastimil Babka , linux-mm@kvack.org X-Mailer: Apple Mail (2.3608.120.23.2.4) 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: Hi! > On 20 Oct 2020, at 13:19, Vlastimil Babka wrote: >=20 > 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 >=20 > 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. >=20 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 =3D=3D MS_ASYNC) >> + goto out_unlock; >> start =3D vma->vm_start; >> if (start >=3D end) >> goto out_unlock; >> base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8 >=20