From nobody Thu Apr 9 14:15:41 2026 Received: from mail115-63.sinamail.sina.com.cn (mail115-63.sinamail.sina.com.cn [218.30.115.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5E4D13B5AE for ; Mon, 9 Mar 2026 05:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.63 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773032526; cv=none; b=ut9V5Vao+JmNX/sUn9oPZBJDmLi02a9IMpII2+42ZgUn9tkz8tOA//N6aojer+Q6GtDEsBvRfAfoACHNRwY4jPSLB+LEFigEQu+z4zeuA8xVD5exAjivHf7URkVKh9cb2Bympm3zrnbqhWJjgxmpPXkhDK5ogTeBUEvr5Sq22iA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773032526; c=relaxed/simple; bh=DJLFSDRnvAp3EhxzBvtGuKZeTxQH2D2T3rwd9dsdcao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nlsBHm0D3RxZUq5G4bdAXwzQ/rp3xjODWCffDNWhO0M4oQ84jWOl6Z7StEBh6TsSZmtN4kXZsOuFzUOVKwqV5fwZo3o8akyrYHv03HbfSJZMrc1aMybIzhpVU53F2J5yyub6kWNUMamoTmHXtzeOdbmYrFNwC4497tt2XLFm+Ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=wf8vdv8A; arc=none smtp.client-ip=218.30.115.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="wf8vdv8A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1773032521; bh=lq2pah/fq2C0/GQ5PtUTDXM7+bNvcgMJwTg7UFXIh1U=; h=From:Subject:Date:Message-Id; b=wf8vdv8ADUgZLvmbIyZhrB/o6KWUxmK/lVMs1cVTEaZ44sSTlPHMVne0PzJlA+dLP WoD/655X+1lvgh1tox6MXd3mapUNJM+6kXxPTnIijAdNFTiUMwUnLEbJVOUJqZ8BV5 1P0QotZik9unKQ89jEetqxsWnKBC8B8BZj9q128o= X-SMAIL-HELO: pek-lpg-core6.wrs.com Received: from unknown (HELO pek-lpg-core6.wrs.com)([60.247.85.88]) by sina.com (10.185.250.22) with ESMTP id 69AE542F00001DDF; Mon, 9 Mar 2026 13:01:52 +0800 (CST) X-Sender: johnny_haocn@sina.com X-Auth-ID: johnny_haocn@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=johnny_haocn@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=johnny_haocn@sina.com X-SMAIL-MID: 7435767602749 X-SMAIL-UIID: 7818163A509A42A8987FBEE18C4A2515-20260309-130152-1 From: Johnny Hao To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, slava@dubeyko.com, willy@infradead.org, vishal.moola@gmail.com, Andrew Morton , Johnny Hao Subject: [PATCH 6.1.y 1/3] pagemap: add filemap_grab_folio() Date: Mon, 9 Mar 2026 13:01:28 +0800 Message-Id: <20260309050130.912344-2-johnny_haocn@sina.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260309050130.912344-1-johnny_haocn@sina.com> References: <20260309050130.912344-1-johnny_haocn@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Vishal Moola (Oracle)" [ Upstream commit ee7a5906ff08e435ed95ec9fe7c7eed2c11015d2 ] Patch series "Convert to filemap_get_folios_tag()", v5. This patch series replaces find_get_pages_range_tag() with filemap_get_folios_tag(). This also allows the removal of multiple calls to compound_head() throughout. It also makes a good chunk of the straightforward conversions to folios, and takes the opportunity to introduce a function that grabs a folio from the pagecache. This patch (of 23): Add function filemap_grab_folio() to grab a folio from the page cache. This function is meant to serve as a folio replacement for grab_cache_page, and is used to facilitate the removal of find_get_pages_range_tag(). Link: https://lkml.kernel.org/r/20230104211448.4804-1-vishal.moola@gmail.com Link: https://lkml.kernel.org/r/20230104211448.4804-2-vishal.moola@gmail.com Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton Signed-off-by: Johnny Hao --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index dfaa09901867..be0eb05dbd14 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -582,6 +582,26 @@ static inline struct folio *filemap_lock_folio(struct = address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } =20 +/** + * filemap_grab_folio - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * + * Looks up the page cache entry at @mapping & @index. If no folio is foun= d, + * a new folio is created. The folio is locked, marked as accessed, and + * returned. + * + * Return: A found or created folio. NULL if no folio is found and failed = to + * create a folio. + */ +static inline struct folio *filemap_grab_folio(struct address_space *mappi= ng, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); +} + /** * find_get_page - find and get a page reference * @mapping: the address_space to search --=20 2.34.1