Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp101457pxv; Wed, 14 Jul 2021 23:49:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU8dUREF5tT7l6Z38dsdM75goIJuvpPIcNSA6vJzQHNbiJdgY5LH0zC7rUnv8IoCvhuYI5 X-Received: by 2002:a17:906:2844:: with SMTP id s4mr3493369ejc.263.1626331741506; Wed, 14 Jul 2021 23:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626331741; cv=none; d=google.com; s=arc-20160816; b=tbtDmI3NOyyFaP4XPnMRE1XKoDsWUv01wAVOZPRI9FQMCzPrtwGU+GFjVG9TWxUM0y HbFWaMt6cZNTHckCXhXKS9lWtGuVxFQet2BVDe1uJpJ8ZkFyKfE93djWW0bxnM7dUDHn oOKUUZE/oTePoNGoFQLalsaO8x2XH/IEiYrr8G3GeT9e9AAGRx7nB7G/zTIWLEcC/jLJ VSQik5VUEMSYsNg5mEj92zmxCl/0CCFbMtdXSXkoGg7t02RGwH5GJQW2Hx+qkuvrDxou MH6SZ1w5AuFavdN5NGZfA4VxqgbUTU134rxd+al+DXl9NvoN6UNSAmHW3w24UEStEK9V x3Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hntnIK0rh4NoYP7JLuJMNeJXtUgKUH/MeKkNIOw/DoE=; b=gEEh18kdTHEe/sd8Fw8CIApG58FqSjCA43t3yBVV9HOlXDsEKcdLhPUlP6V9ENpSWh r/EKkf7/8qpWgvWNqPJcpYSWJr7D7GUIX9E2UYAQgp8XOvWXM/+EU/OCBflu4Z8r35nl ZZp+4LR2PTgl7dVCdvWrvirk+Jwfuh2exw2NC+0sBLABgvtNo0HR0LtVg7I3DG4bjAVb 7rvU+VDuuowj/EAzre1itZKWVeeybkZTSPgU11CgM3SJQbhRIxZhg0S5SMw5yIWvcNLL 1WqwAozo2+ZyOG81fSTyz1yDBDj0zNRAQXwbjvH5ybxxadIS3q4IRMkLU2GPw0Vl7jEN WyoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BSFiK66t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si6374139ejb.77.2021.07.14.23.48.39; Wed, 14 Jul 2021 23:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BSFiK66t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbhGOEFe (ORCPT + 99 others); Thu, 15 Jul 2021 00:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhGOEFe (ORCPT ); Thu, 15 Jul 2021 00:05:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA6EC06175F; Wed, 14 Jul 2021 21:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hntnIK0rh4NoYP7JLuJMNeJXtUgKUH/MeKkNIOw/DoE=; b=BSFiK66t9lDGI8XD4vhlbG6Y48 oNS+eMRM484RMuRqbLpjjZLUgsuSbHYWJpjIxOiIo3fkCxutEBELqAGluL5y3ehTBbdFWZxPG9pwY YwGsiweVSp61gMskh85mEm+KvVVdYsB4k+uB7c9oqRSZESCYGnZQugyf/SHG4db+yHEwnOafYO7LL 5vrAeybiKitVa8SzU09TSMWYFGrOVIyQLCp/EU4nN2n8cPub5aMOt/q3utTceRMKRKuBfQ+YDaLlG ibj9cFfgbg7w5ppH1Z4S4PYNKUt23SZ5ZJBwad6J0hPjh2S9ztxHPFlJ6/1HkOVuR5F7q4S9+bJ7P OHXDyE0A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3sYz-002vir-4g; Thu, 15 Jul 2021 04:01:41 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Vlastimil Babka , William Kucharski , Christoph Hellwig , David Howells , "Kirill A . Shutemov" Subject: [PATCH v14 030/138] mm/filemap: Add folio private_2 functions Date: Thu, 15 Jul 2021 04:35:16 +0100 Message-Id: <20210715033704.692967-31-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org end_page_private_2() becomes folio_end_private_2(), wait_on_page_private_2() becomes folio_wait_private_2() and wait_on_page_private_2_killable() becomes folio_wait_private_2_killable(). Adjust the fscache equivalents to call page_folio() before calling these functions to avoid adding wrappers. Ends up costing 1 byte of text in ceph & netfs, but the core shrinks by three calls to page_folio(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Vlastimil Babka Reviewed-by: William Kucharski Reviewed-by: Christoph Hellwig Reviewed-by: David Howells Acked-by: Kirill A. Shutemov --- include/linux/netfs.h | 6 +++--- include/linux/pagemap.h | 6 +++--- mm/filemap.c | 37 ++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 9062adfa2fb9..fad8c6209edd 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -55,7 +55,7 @@ static inline void set_page_fscache(struct page *page) */ static inline void end_page_fscache(struct page *page) { - end_page_private_2(page); + folio_end_private_2(page_folio(page)); } /** @@ -66,7 +66,7 @@ static inline void end_page_fscache(struct page *page) */ static inline void wait_on_page_fscache(struct page *page) { - wait_on_page_private_2(page); + folio_wait_private_2(page_folio(page)); } /** @@ -82,7 +82,7 @@ static inline void wait_on_page_fscache(struct page *page) */ static inline int wait_on_page_fscache_killable(struct page *page) { - return wait_on_page_private_2_killable(page); + return folio_wait_private_2_killable(page_folio(page)); } enum netfs_read_source { diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index c8e74d67b01f..edf58a581bce 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -796,9 +796,9 @@ static inline void set_page_private_2(struct page *page) SetPagePrivate2(page); } -void end_page_private_2(struct page *page); -void wait_on_page_private_2(struct page *page); -int wait_on_page_private_2_killable(struct page *page); +void folio_end_private_2(struct folio *folio); +void folio_wait_private_2(struct folio *folio); +int folio_wait_private_2_killable(struct folio *folio); /* * Add an arbitrary waiter to a page's wait queue diff --git a/mm/filemap.c b/mm/filemap.c index 1ecaece68019..a5d02ec62eb6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1451,56 +1451,51 @@ void folio_unlock(struct folio *folio) EXPORT_SYMBOL(folio_unlock); /** - * end_page_private_2 - Clear PG_private_2 and release any waiters - * @page: The page + * folio_end_private_2 - Clear PG_private_2 and wake any waiters. + * @folio: The folio. * - * Clear the PG_private_2 bit on a page and wake up any sleepers waiting for - * this. The page ref held for PG_private_2 being set is released. + * Clear the PG_private_2 bit on a folio and wake up any sleepers waiting for + * it. The page ref held for PG_private_2 being set is released. * * This is, for example, used when a netfs page is being written to a local * disk cache, thereby allowing writes to the cache for the same page to be * serialised. */ -void end_page_private_2(struct page *page) +void folio_end_private_2(struct folio *folio) { - struct folio *folio = page_folio(page); - VM_BUG_ON_FOLIO(!folio_test_private_2(folio), folio); clear_bit_unlock(PG_private_2, folio_flags(folio, 0)); folio_wake_bit(folio, PG_private_2); folio_put(folio); } -EXPORT_SYMBOL(end_page_private_2); +EXPORT_SYMBOL(folio_end_private_2); /** - * wait_on_page_private_2 - Wait for PG_private_2 to be cleared on a page - * @page: The page to wait on + * folio_wait_private_2 - Wait for PG_private_2 to be cleared on a page. + * @folio: The folio to wait on. * - * Wait for PG_private_2 (aka PG_fscache) to be cleared on a page. + * Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio. */ -void wait_on_page_private_2(struct page *page) +void folio_wait_private_2(struct folio *folio) { - struct folio *folio = page_folio(page); - while (folio_test_private_2(folio)) folio_wait_bit(folio, PG_private_2); } -EXPORT_SYMBOL(wait_on_page_private_2); +EXPORT_SYMBOL(folio_wait_private_2); /** - * wait_on_page_private_2_killable - Wait for PG_private_2 to be cleared on a page - * @page: The page to wait on + * folio_wait_private_2_killable - Wait for PG_private_2 to be cleared on a folio. + * @folio: The folio to wait on. * - * Wait for PG_private_2 (aka PG_fscache) to be cleared on a page or until a + * Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio or until a * fatal signal is received by the calling task. * * Return: * - 0 if successful. * - -EINTR if a fatal signal was encountered. */ -int wait_on_page_private_2_killable(struct page *page) +int folio_wait_private_2_killable(struct folio *folio) { - struct folio *folio = page_folio(page); int ret = 0; while (folio_test_private_2(folio)) { @@ -1511,7 +1506,7 @@ int wait_on_page_private_2_killable(struct page *page) return ret; } -EXPORT_SYMBOL(wait_on_page_private_2_killable); +EXPORT_SYMBOL(folio_wait_private_2_killable); /** * folio_end_writeback - End writeback against a folio. -- 2.30.2