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 7DC06C433FE for ; Fri, 14 Oct 2022 03:24:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1AE26B0072; Thu, 13 Oct 2022 23:24:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCA196B0075; Thu, 13 Oct 2022 23:24:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C91C66B0078; Thu, 13 Oct 2022 23:24:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B27826B0072 for ; Thu, 13 Oct 2022 23:24:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7E8AA1203BA for ; Fri, 14 Oct 2022 03:24:08 +0000 (UTC) X-FDA: 80018111376.30.37C1B8E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 8AC4C140032 for ; Fri, 14 Oct 2022 03:24:06 +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=k1olnhMeFRc72L34mxBEB4SzA8A37natGttf+ivr3P4=; b=YBejHR2p9R8AVJoQ/S7beTojDp 0d+esxsc8ZK7xqQTD4QbhTESxcj7VXIwDujaglOJLMkptWIeop5ac2Pa5FxuV2AIIshJY2C68FCh7 BgOGJSzIsdkTC/6bsf/n6xKXCgPZKk5135ZBUzbGKjt9kKBjj+NVrS3TGDoSDlWbCIN/qReKCRwtl skoEc7VZVWUEuGlbDBYURd4rEhiiJjUG9GI6eCaw1sRicXqr5fXmFMuH7rrxIPLOd6o0DlGJy3fJ9 5IbUIdFOT219fqArZJOlXSm9wTSFAEeWYUZ1NKN1bAxTAr0WFiXGT1oSSGtorOuab5iYsQCafznfr srem/QdA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojBIn-007IgQ-Ms; Fri, 14 Oct 2022 03:24:01 +0000 Date: Fri, 14 Oct 2022 04:24:01 +0100 From: Matthew Wilcox To: "Vishal Moola (Oracle)" 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 v2 1/2] filemap: find_lock_entries() now updates start offset Message-ID: References: <20221013225708.1879-1-vishal.moola@gmail.com> <20221013225708.1879-2-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221013225708.1879-2-vishal.moola@gmail.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665717847; 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=k1olnhMeFRc72L34mxBEB4SzA8A37natGttf+ivr3P4=; b=vRlv2LrCGB8kVBazm0o8/yzEnST4jZ+tL+Y4jO4mEvUIr40nDw0je9XFyhx7igasYoG/kv kTyphojCd1B0F8UNW2ucwRdpAvwtcyQYKxIyTnnMcLKx+xQunV4tflfps62UNBlrTPLSA9 nD6tPW48uLy1Ev0fBGE0bDPOQLt1iS4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YBejHR2p; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665717847; a=rsa-sha256; cv=none; b=SaweqzI02K5L0vCSXEBE9B0ZnRJjHchWEG1idT6ceDEvAXDhbgSQfCEqjmHmIYK5VcwTpR dHYeX1Z70T7Y6hXsazYDwHfgSWfuXymPovfeT8tiNVWL9u7toCzCwu0KnkzF7NLuCumxZ+ zf7CaVOntOVxp4pwEZx3GdOjdCiqOsU= X-Stat-Signature: 41eqbnezfxjqmeci4acbr6ioao56z8iw X-Rspamd-Queue-Id: 8AC4C140032 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YBejHR2p; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1665717846-575362 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 Thu, Oct 13, 2022 at 03:57:07PM -0700, Vishal Moola (Oracle) wrote: > Initially, find_lock_entries() was being passed in the start offset as a > value. That left the calculation of the offset to the callers. This led > to complexity in the callers trying to keep track of the index. > > Now find_lock_entires() takes in a pointer to the start offset and s/entires/entries/ > updates the value to be directly after the last entry found. If no entry is > found, the offset is not changed. This gets rid of multiple hacky > calculations that kept track of the start offset. > @@ -2120,8 +2120,17 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start, > put: > folio_put(folio); > } > - rcu_read_unlock(); > > + if (folio_batch_count(fbatch)) { > + unsigned long nr = 1; > + int idx = folio_batch_count(fbatch) - 1; > + > + folio = fbatch->folios[idx]; > + if (!xa_is_value(folio) && !folio_test_hugetlb(folio)) > + nr = folio_nr_pages(folio); > + *start = indices[idx] + nr; > + } > + rcu_read_unlock(); > return folio_batch_count(fbatch); Do we need to move the rcu_read_unlock()? Pretty sure we can do all these calculations without it. This all looks good. It's certainly more ergonomic to use. Reviewed-by: Matthew Wilcox (Oracle)