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 X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4081FC433E6 for ; Fri, 5 Mar 2021 04:25:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA99865009 for ; Fri, 5 Mar 2021 04:25:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA99865009 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6F2FB6B000D; Thu, 4 Mar 2021 23:25:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67BCB6B000E; Thu, 4 Mar 2021 23:25:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F68C6B0010; Thu, 4 Mar 2021 23:25:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 2F93E6B000D for ; Thu, 4 Mar 2021 23:25:17 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E9E25181B04B3 for ; Fri, 5 Mar 2021 04:25:16 +0000 (UTC) X-FDA: 77884531032.18.72C4091 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id ACB772000382 for ; Fri, 5 Mar 2021 04:25:16 +0000 (UTC) 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=ByBvZRAgYRACtY2rVghjrF+s5V0nWEFj/GUpqmY/krg=; b=bdhen0e0A+TMa408MU8/lgkXfj tjTiCKz2w10Kbk5JviHWXpBE+ZxYrTDcBZDzM5esN+e1I2n44YqOa4Le8lUl/Ky/CoVNpWQ1XQbty 65cLZ8HbD/GcFhxKjmU/W5DBmdMhriRhVi3WkLBW4I8MuCCZGVhP/bqE3O5Y7vDCvByMa0IPN2vqS cOjr3BpbSvWV1LWwYZKg1Ufd6BBgPn86nGGLlrGhYNeo5sLiM4cI4W2LyoS39JSchQYsdoA2pK8fm KP/HWKLkt93OIea0kGGllnKQccsmjdLu5JYm0NsRnYTJDW0DeLM7OWcu6UzFg8TD9+Jj/chiHvV++ FcIiqP/A==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lI216-00A409-R4; Fri, 05 Mar 2021 04:24:48 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v4 18/25] mm/page-writeback: Add wait_on_folio_writeback Date: Fri, 5 Mar 2021 04:18:54 +0000 Message-Id: <20210305041901.2396498-19-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210305041901.2396498-1-willy@infradead.org> References: <20210305041901.2396498-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: azdeuakrmnjbjq9c1othnhhtfwuwo3eo X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: ACB772000382 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614918316-448672 Content-Transfer-Encoding: quoted-printable 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: This eliminates a call to compound_head() by turning PageWriteback() into FolioWriteback(), which saves 8 bytes. That is more than offset by adding the wait_on_page_writeback compatibility wrapper for a net increase in text of 30 bytes. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 1 + mm/folio-compat.c | 6 ++++++ mm/page-writeback.c | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index c53743f24550..7d797847633c 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -763,6 +763,7 @@ static inline int wait_on_page_locked_killable(struct= page *page) =20 int put_and_wait_on_page_locked(struct page *page, int state); void wait_on_page_writeback(struct page *page); +void wait_on_folio_writeback(struct folio *folio); void end_page_writeback(struct page *page); void end_folio_writeback(struct folio *folio); void wait_for_stable_page(struct page *page); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index d1a1dfe52589..6aadecc39fba 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -23,3 +23,9 @@ void end_page_writeback(struct page *page) return end_folio_writeback(page_folio(page)); } EXPORT_SYMBOL(end_page_writeback); + +void wait_on_page_writeback(struct page *page) +{ + return wait_on_folio_writeback(page_folio(page)); +} +EXPORT_SYMBOL_GPL(wait_on_page_writeback); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index eb34d204d4ee..968579452ea4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2821,17 +2821,24 @@ int __test_set_page_writeback(struct page *page, = bool keep_write) } EXPORT_SYMBOL(__test_set_page_writeback); =20 -/* - * Wait for a page to complete writeback +/** + * wait_on_folio_writeback - Wait for a folio to complete writeback. + * @folio: The folio to wait for. + * + * If the folio is currently being written back to storage, waits for th= e + * I/O to complete. + * + * Context: Sleeps; must be called in process context and with no spinlo= cks + * held. */ -void wait_on_page_writeback(struct page *page) +void wait_on_folio_writeback(struct folio *folio) { - while (PageWriteback(page)) { - trace_wait_on_page_writeback(page, page_mapping(page)); - wait_on_page_bit(page, PG_writeback); + while (FolioWriteback(folio)) { + trace_wait_on_page_writeback(&folio->page, folio_mapping(folio)); + wait_on_page_bit(&folio->page, PG_writeback); } } -EXPORT_SYMBOL_GPL(wait_on_page_writeback); +EXPORT_SYMBOL_GPL(wait_on_folio_writeback); =20 /** * wait_for_stable_page() - wait for writeback to finish, if necessary. --=20 2.30.0