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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40048C4332F for ; Mon, 17 Oct 2022 19:43:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D43C76B0078; Mon, 17 Oct 2022 15:43:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF37D6B007B; Mon, 17 Oct 2022 15:43:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE3576B007D; Mon, 17 Oct 2022 15:43:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AF7F06B0078 for ; Mon, 17 Oct 2022 15:43:49 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 839D3C0B44 for ; Mon, 17 Oct 2022 19:43:49 +0000 (UTC) X-FDA: 80031466578.23.01F96CE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 3449E40042 for ; Mon, 17 Oct 2022 19:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eMB2pSDfV1bvP74oVN4aFjBLP7duahTznx7nvBtIcM4=; b=EmLMG3n6bQLAwe5nnRsLuJ4ZBS cjHOQcsxuhlbPqT0a3g5qKJtSobZMizB4tJnZEuAoh8ZE5XdFetLn8HpSeXwIvWe3qhwOaPqONtAt 96/FVt8rbsIJTPaK4ebs73/f7bGN3D8q0l5dqqPUQIXrRLMhVkXDm14+xDGb/3ls4aBSB80WQShhb v729KoAFrHiSm5OTzznGNoomhcnGdYS0DCAgXSMLkGs8hf68yZMkxSh2jzaj1ZLTvS6Fd5V+n96k0 LHaXY1tU9GF7kVFi+Sdy3uNzK3dlBai/XDQK/VRqvsyXh/R/0oQH4yryDspeZMg0msyUmVB23yxKN n7pbe8Tw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1okW1a-00A5Lc-LA; Mon, 17 Oct 2022 19:43:46 +0000 Date: Mon, 17 Oct 2022 20:43:46 +0100 From: Matthew Wilcox To: Vishal Moola Cc: akpm@linux-foundation.org, hughd@google.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] filemap: find_lock_entries() now updates start offset Message-ID: References: <20221017161800.2003-1-vishal.moola@gmail.com> <20221017161800.2003-2-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666035829; a=rsa-sha256; cv=none; b=kGI6lv+gNw2zvuKH5RMXkSQjH9t4E6uSpvyfHiDhVPKahxRusuybHDPlwGXQyfrkRL/FG2 TSpfW2tpuYApDw1b0lUnndU5GzbzGN4VeTCre86myrVdvweHEcBKtKl28SliXHZInNcG86 kvgKpaI3sHwDqDGQeimUorwlcI3NWb0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EmLMG3n6; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666035829; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eMB2pSDfV1bvP74oVN4aFjBLP7duahTznx7nvBtIcM4=; b=AmyywjzXXSy73g8v78An4KlKegbYbYe6fu+s3B1xCNvWr3k5QdgwtM01En8uGuqj+Ggubx +GA3n6zP6Rg+cTL217slBAzJdtCSNiTKB3Tc85qkAhY0yo6apk5SPv5ev4c7VEZClaPVE8 wOZG2nWJz0/4TgHHvanFpVVJU5rl6xE= X-Stat-Signature: 6ibwwdkshuqmq9bt41qb7eezjn1jy4m1 X-Rspamd-Queue-Id: 3449E40042 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EmLMG3n6; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam11 X-HE-Tag: 1666035827-787805 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: On Mon, Oct 17, 2022 at 12:37:48PM -0700, Vishal Moola wrote: > On Mon, Oct 17, 2022 at 9:56 AM Matthew Wilcox wrote: > > > > On Mon, Oct 17, 2022 at 09:17:59AM -0700, Vishal Moola (Oracle) wrote: > > > +++ b/mm/shmem.c > > > @@ -932,21 +932,18 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > > > > > > folio_batch_init(&fbatch); > > > index = start; > > > - while (index < end && find_lock_entries(mapping, index, end - 1, > > > + while (index < end && find_lock_entries(mapping, &index, end - 1, > > > > Sorry for not spotting this in earlier revisions, but this is wrong. > > Before, find_lock_entries() would go up to (end - 1) and then the > > index++ at the end of the loop would increment index to "end", causing > > the loop to terminate. Now we don't increment index any more, so the > > condition is wrong. > > The condition is correct. Index maintains the exact same behavior. > If a find_lock_entries() finds a folio, index is set to be directly after > the last page in that folio, or simply incrementing for a value entry. > The only time index is not changed at all is when find_lock_entries() > finds no folios, which is the same as the original behavior as well. Uh, right. I had the wrong idea in my head that index wouldn't increase past end-1, but of course it can. > > I suggest just removing the 'index < end" half of the condition. > > I hadn't thought about it earlier but this index < end check seems > unnecessary anyways. If index > end then find_lock_entries() > shouldn't find any folios which would cause the loop to terminate. > > I could send an updated version getting rid of the "index < end" > condition as well if you would like? Something to consider is that if end is 0 then end-1 is -1, which is effectively infinity, and we'll do the wrong thing? So maybe just leave it alone, and go with v3 as-is?