Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1589465pxf; Fri, 9 Apr 2021 12:12:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX2PoRvl8uQDSCy8b3grpK439i7XGxPiBM1rzZ+rjClJ7u3UUjvMNvxcKvrd9PCwaFgvpn X-Received: by 2002:a63:7e52:: with SMTP id o18mr14952477pgn.416.1617995551600; Fri, 09 Apr 2021 12:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617995551; cv=none; d=google.com; s=arc-20160816; b=NFtcKk4ffEOFUp/aXWFclfp3smX0yfrVtFuvUKp9vheBIhNvIocCnxLA0N+VN2h3Ay VauGlaOGiUCX7q9OnIQKFMJuYerlJ6EpajmA49XYIyp+3outsJh3MSlI4HKXaWg1Yxtv hvkCniuHgXyNwFjBdadtVq17Cgd3X40wJHbJ47xOXOGsX0A2yfcfuB5RnkWxtgYf/V2I JHJ+8wSmN1ZC1Ovj5lFZI9t21j34K/PrP/GAg9Ad6lOsFsyy26eQ2jfy4aOoXVFB1WQM 4OM0VTxrVax5tyq38ECsgijV1B8vYFGn6lvb7++yDNH30Zsg0v/NwAMqN+RQX6iIhhP+ t/KA== 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=c6bF0o530sEFfUOMYKiuz98B39kHRlFATNnIYOB0g+s=; b=MF74uhT1qZkQmUsHtnIZr+jn7E8CZzpM5/WJev+E/vrZSsx0B1IFQ8dmQTwqC7Ru8M CGL4PK3K7ZU3KEqeHZe1rKkbCcyMrfrbvIUAs2AdpLdX8/4727jb4iMCDuFQVTtWTuCE aobZnHGprgs+MitTr2rS5HHe+It/7t0EyQvoxpjx1jMcJ07O1VeqtYWUjK2eLEca+K9L 8eueawcthm0wx9xqf7xMyv9I3uws48ouZSycmVSxvRjfrf5IBrDNGNtUcLvFWj0nWG4f hWxmHCCNOhaZ+xLWEKnKLGdGjIpA3B5LXV7pnVyoMp3/8hIT7r56tCcCywMsAIfMXRyw nKeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NLy3Kc8I; 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 c15si4081478pjq.30.2021.04.09.12.12.17; Fri, 09 Apr 2021 12:12:31 -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=NLy3Kc8I; 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 S234919AbhDITLi (ORCPT + 99 others); Fri, 9 Apr 2021 15:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234692AbhDITLh (ORCPT ); Fri, 9 Apr 2021 15:11:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B41C061762; Fri, 9 Apr 2021 12:11:23 -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=c6bF0o530sEFfUOMYKiuz98B39kHRlFATNnIYOB0g+s=; b=NLy3Kc8IJA0Z9nJex8rikMcRPq kFaBIqGGoW0m2L0+vR03kv6LYIgM0CUtRY/idHgu8/gEnMXHYGhyPIAQfTvk7m4RQg6lERJZauk3c JmlkoPe6pffNiyAV6WRxA+AA1/reFta1fkrDzqqwG05sNCFL7kyNiUmA0yXEl6uABbp8Vzgw/EajQ mi1x6GEocmC78mAXCVgs4G9bjXdmXqM5lUD65wv8pEkyXzBAliZeOyzVIluQZQyIumgn538n8RpPc YVypm1imLLt+HUpsBy8pV3QFa37S9czp9BtcTVwadTFdQ7mU6Xe/gB3yF4ri7/ZojIhUhxyc7DTrB TbmRVOuw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUwVY-000oZV-25; Fri, 09 Apr 2021 19:09: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, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, Christoph Hellwig , Jeff Layton Subject: [PATCH v7 25/28] mm/writeback: Add wait_for_stable_folio Date: Fri, 9 Apr 2021 19:51:02 +0100 Message-Id: <20210409185105.188284-26-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210409185105.188284-1-willy@infradead.org> References: <20210409185105.188284-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move wait_for_stable_page() into the folio compatibility file. wait_for_stable_folio() avoids a call to compound_head() and is 14 bytes smaller than wait_for_stable_page() was. The net text size grows by 24 bytes as a result of this patch. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton --- include/linux/pagemap.h | 1 + mm/folio-compat.c | 6 ++++++ mm/page-writeback.c | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 99331c35c89c..d50fc5adbee1 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -833,6 +833,7 @@ int wait_on_folio_writeback_killable(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); +void wait_for_stable_folio(struct folio *folio); void page_endio(struct page *page, bool is_write, int err); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 6aadecc39fba..335594fe414e 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -29,3 +29,9 @@ void wait_on_page_writeback(struct page *page) return wait_on_folio_writeback(page_folio(page)); } EXPORT_SYMBOL_GPL(wait_on_page_writeback); + +void wait_for_stable_page(struct page *page) +{ + return wait_for_stable_folio(page_folio(page)); +} +EXPORT_SYMBOL_GPL(wait_for_stable_page); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 8271f9b24b69..9d55ceec05c0 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2865,17 +2865,21 @@ int wait_on_folio_writeback_killable(struct folio *folio) EXPORT_SYMBOL_GPL(wait_on_folio_writeback_killable); /** - * wait_for_stable_page() - wait for writeback to finish, if necessary. - * @page: The page to wait on. + * wait_for_stable_folio() - wait for writeback to finish, if necessary. + * @folio: The folio to wait on. * - * This function determines if the given page is related to a backing device - * that requires page contents to be held stable during writeback. If so, then - * it will wait for any pending writeback to complete. + * This function determines if the given folio is related to a backing + * device that requires folio contents to be held stable during writeback. + * If so, then it will wait for any pending writeback to complete. + * + * Context: Sleeps. Must be called in process context and with + * no spinlocks held. Caller should hold a reference on the folio. + * If the folio is not locked, writeback may start again after writeback + * has finished. */ -void wait_for_stable_page(struct page *page) +void wait_for_stable_folio(struct folio *folio) { - page = thp_head(page); - if (page->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES) - wait_on_page_writeback(page); + if (folio->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES) + wait_on_folio_writeback(folio); } -EXPORT_SYMBOL_GPL(wait_for_stable_page); +EXPORT_SYMBOL_GPL(wait_for_stable_folio); -- 2.30.2