From patchwork Fri Oct 6 11:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13411278 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 2585FE936FB for ; Fri, 6 Oct 2023 11:01:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C75D6B011B; Fri, 6 Oct 2023 07:01:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24DA46B011D; Fri, 6 Oct 2023 07:01:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EECB6B011E; Fri, 6 Oct 2023 07:01:32 -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 F01C26B011B for ; Fri, 6 Oct 2023 07:01:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BC4EE1A0440 for ; Fri, 6 Oct 2023 11:01:31 +0000 (UTC) X-FDA: 81314745582.01.78E733E Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf21.hostedemail.com (Postfix) with ESMTP id D54C81C002F for ; Fri, 6 Oct 2023 11:01:28 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=RRNKycN0; dmarc=none; spf=pass (imf21.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696590089; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=7Xbpc76QqDf9iPooRjIH3Xrrud0vO4BKu7rmjONR5S4=; b=6F2zZ9x7/tDYlnbl66oy8TNm1QiCpMAFlpElhUNYWul1bOxxvPDBj/ZXBCAOJkCqmUisu1 eMdVr5Zmi4HLLYRvxTPUSOnxwSHg6KbTtYFnL3qzfcP45p/9woBTy2c6vUsjlL3nUXg83h To2yE2eNAYvftrP0gJJeSyCjVRCiTMM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=RRNKycN0; dmarc=none; spf=pass (imf21.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696590089; a=rsa-sha256; cv=none; b=35yiackZhAAm8qHHinOOkX1wyisnwOFKpkcjzESGi0pmG78wRDTRsBwRVs/9RFaXismVVM glXbnLnZs2Cs1mTNFcB4z/xhHB5qewT5kdxn9CW4yfBuUKBUWwqDJwRyo7mVlG4NyTXJOU 4O3MoT06Z1A/Q/ndZutwaivfQbEjCGk= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4S258N085Bz9sp9; Fri, 6 Oct 2023 13:01:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1696590084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7Xbpc76QqDf9iPooRjIH3Xrrud0vO4BKu7rmjONR5S4=; b=RRNKycN0CdxUtskp7qqEKSR0HoUKIzy9XEteOBbIh8fZe061MJQlcu0FSZ0sqy6UG0TbKW UG+NmEczMEGdqQleZEkZjt/JRy2j0X5+Hl1up+8FitOPTXzuFhh+XDq6g5pUUVg+FDgS6e dLSA21gaVfCD1ybLSxr0NoIsYIy7igKAfWcGscbJM2bNdTHn8PYMsrBqDOSFiHfTPAofc4 wZROTi0Bo/aheTNRURsc4fM8WdzVgpcpoeXcZHjB7r3IqGqDXeeocya1ymoaTeH+aLjY3c H4tsbeIvpJ2aLn87xnHA0++awUSVarHa8BRFRskcnRTxtNFQ19c/RQDWrp8rVg== From: Pankaj Raghav To: willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, gost.dev@samsung.com, linux-kernel@vger.kernel.org, Pankaj Raghav Subject: [PATCH] filemap: call filemap_get_folios_tag() from filemap_get_folios() Date: Fri, 6 Oct 2023 13:01:20 +0200 Message-Id: <20231006110120.136809-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D54C81C002F X-Stat-Signature: o6b6n8fb6enn9wzonf87fecuqptt76p5 X-Rspam-User: X-HE-Tag: 1696590088-712272 X-HE-Meta: U2FsdGVkX19ssOp8K+2CVvMQwgFX4vt1s++25DMYD+HkkD0PiPe+MMvpDrJBjx/7dLTuE/BcNSnAZSe7lofcrTUUxe2TGj3weHQXmUryomQYAILaCLmkBdsxJIN9z/VIM7oJ+WZZDsEDwNgtHg9KDWSvnoyRw9gZXplvw7wPRvDkmHLCJdrJ5QNZFywTEGOJT4EvWMGIXIgy+ARUkuYFvmAIaj/mZTwgpdzX9+tPPVr81aSwRSjXK3Nfi3QY0szekzyZU9DGTAgrpiZywEE4rHyhPi3z+S7GLAF7t48que/4ov9vX39RRbRW5XRun8FwkA548qVhy+vyv7UPCeCMSg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: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Pankaj Raghav filemap_get_folios() is filemap_get_folios_tag() with XA_PRESENT as the tag that is being matched. Return filemap_get_folios_tag() with XA_PRESENT as the tag instead of duplicating the code in filemap_get_folios(). No functional changes. Signed-off-by: Pankaj Raghav Reviewed-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 695cf0e643da..525b8d68b4b1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2120,48 +2120,13 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t *start, * index @start and up to index @end (inclusive). The folios are returned * in @fbatch with an elevated reference count. * - * The first folio may start before @start; if it does, it will contain - * @start. The final folio may extend beyond @end; if it does, it will - * contain @end. The folios have ascending indices. There may be gaps - * between the folios if there are indices which have no folio in the - * page cache. If folios are added to or removed from the page cache - * while this is running, they may or may not be found by this call. - * * Return: The number of folios which were found. * We also update @start to index the next folio for the traversal. */ unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch) { - XA_STATE(xas, &mapping->i_pages, *start); - struct folio *folio; - - rcu_read_lock(); - while ((folio = find_get_entry(&xas, end, XA_PRESENT)) != NULL) { - /* Skip over shadow, swap and DAX entries */ - if (xa_is_value(folio)) - continue; - if (!folio_batch_add(fbatch, folio)) { - unsigned long nr = folio_nr_pages(folio); - *start = folio->index + nr; - goto out; - } - } - - /* - * We come here when there is no page beyond @end. We take care to not - * overflow the index @start as it confuses some of the callers. This - * breaks the iteration when there is a page at index -1 but that is - * already broken anyway. - */ - if (end == (pgoff_t)-1) - *start = (pgoff_t)-1; - else - *start = end + 1; -out: - rcu_read_unlock(); - - return folio_batch_count(fbatch); + return filemap_get_folios_tag(mapping, start, end, XA_PRESENT, fbatch); } EXPORT_SYMBOL(filemap_get_folios); @@ -2240,7 +2205,13 @@ EXPORT_SYMBOL(filemap_get_folios_contig); * @tag: The tag index * @fbatch: The batch to fill * - * Same as filemap_get_folios(), but only returning folios tagged with @tag. + * The first folio may start before @start; if it does, it will contain + * @start. The final folio may extend beyond @end; if it does, it will + * contain @end. The folios have ascending indices. There may be gaps + * between the folios if there are indices which have no folio in the + * page cache. If folios are added to or removed from the page cache + * while this is running, they may or may not be found by this call. + * Only returns folios that are tagged with @tag. * * Return: The number of folios found. * Also update @start to index the next folio for traversal.