Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1726250pxb; Thu, 4 Mar 2021 20:26:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxztIcZoQdYouFQv4NpANZFT2WUeCMmbQ12ZPsNmrQ9maSfTq9nFJzRiaQ2g1/s70EiaELU X-Received: by 2002:a5d:93c2:: with SMTP id j2mr6626183ioo.166.1614918376013; Thu, 04 Mar 2021 20:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614918376; cv=none; d=google.com; s=arc-20160816; b=MWi4OsyNqxW6A6tn72VAkzagGYnHLq2ZW00vUssRN8cCdCliIhChOPIBBSYWhMRCSr J8zZbbAoRqUMYpHyVV1hd9TJmRKpJD1FF//1LA0rS4X0CWhYE9sBIPmxqu9QvCGpq8Ol kYLHcpPPI3gDDmV1MSZbf9E3UYMRh/sOinqIH3I9O+ckh6xCkVYv8WgVX5mBM/zVs8ak xt/zLHPXBICOD8SAM9Kp/mb9chJWOEroMTtM7YfftcBCyDIc7b3+Pt30jjTGl7dnvp9P rhTLT+u/YB7AalO0zP0ksqIGaL9GtcMGzQwy4XgUPI/nlfrB+jb1qMQqoO/b11FQomB4 9esA== 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=ByBvZRAgYRACtY2rVghjrF+s5V0nWEFj/GUpqmY/krg=; b=RPW1mI+WYe2tc1S6FuBqAlADry/6+lCrW6kj3wwrLhy/i6Y5OSCGxGWNT6fjgt0f0V X66PUbCe2TpP/+HL0I0Fj/uQocA8byOOGstFAAzj5xyxySS6izHNyzlwYdp3H/7trzl5 XHsiMeoxM68Wk1cessQSIic/Le/XzGS7FFjKJNrh7G/s+vmEAn62RtkABKlbNbz3Nqjm PnojziDtIxk7V+mE+LJz1pQm2OhwaCmlkzRKoNrqjZ1VFksEdV9JwkQ6xbLpeZNkW+4B OW4iNpdLgcPDXcwv4BC7YlAgEiAQdp471z7jlS8IvOM4XMDJBkHwPKyZs91GvNM8earM BZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bdhen0e0; 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 j3si1242163jam.97.2021.03.04.20.26.02; Thu, 04 Mar 2021 20:26:16 -0800 (PST) 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=bdhen0e0; 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 S230135AbhCEEZS (ORCPT + 99 others); Thu, 4 Mar 2021 23:25:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbhCEEZR (ORCPT ); Thu, 4 Mar 2021 23:25:17 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE991C061574; Thu, 4 Mar 2021 20:25:16 -0800 (PST) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) 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); -/* - * 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 the + * I/O to complete. + * + * Context: Sleeps; must be called in process context and with no spinlocks + * 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); /** * wait_for_stable_page() - wait for writeback to finish, if necessary. -- 2.30.0