Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp93749pxv; Wed, 14 Jul 2021 23:37:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1GytfG0vJbZ/tOO0l7N9FdMaifgyEG+4aDygJ0zqAG2ZQo3zJpAT0cQPOeYrVwV1z+yi7 X-Received: by 2002:aa7:d48f:: with SMTP id b15mr4515436edr.271.1626331059530; Wed, 14 Jul 2021 23:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626331059; cv=none; d=google.com; s=arc-20160816; b=thYlTQmDLnQhA9tmn9tH6EqyaEmCHlKxxN6EEoWiy/6nNEwHB039vyCyAvi7hYiOP1 iavWATjmjVlcKrgoJxAdj5Ebfx7EqvmgTnwoX8LenTONqKCp9My39JHFt9YDFA9rLUp7 gHSdNKVgD8gqaqOelhWts2qX2Wwc3RzoWDeioxrJgnDYJhJ3rlsltr0e9CeLJnajdosj ll2f81nafTVIAGxHNmDv9ZM34RorUUJRChIJMPeNhG5dg29rEIbAtRW/52Fly8oCjk/c DgvHBzALXzbPxBBX492/Jcp5Tu8GZCMONbNSsVUF32Oi2JPDSovCW/VIeEyhLOIOhh3K q01A== 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=N4ZTZot+vt+8KjslbnqTsaCIrlOXYH7ezn6cHh84c28=; b=GRqRUdRwRDiOd/+vQPXtETJCCQuHPwSu4rJDzizrquVR11Q/0WDHtyhyBA4iznNRHX MpxqPHTzkOnSNWTLq8H1wYfKivF2GDJrJX1q6VfKMDFTHllNqlMoT4Y8rUTxyuYxKdy2 ftmmMePn+pLAfGLy7t2Fgxen+0pmF6AzjP4W2rkcqTCLaJ/uJhwpd+PoSYjygSFq/oB0 WCNH8AutLbdv33efYz4ljzg7tn7Ep4hs4PvgOZupbqLlyAma5pr7EmzXuSZi7cFORF/u n08Z8EGwqgXI4AuRBmEnMKeITXSXPUga3B7wIh9+s/Nw9FkC1dspflZ4NA060GwR5eG0 iGdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=I2NAAnFR; 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 qk8si5997478ejb.342.2021.07.14.23.37.16; Wed, 14 Jul 2021 23:37:39 -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=I2NAAnFR; 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 S231352AbhGOECn (ORCPT + 99 others); Thu, 15 Jul 2021 00:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbhGOECm (ORCPT ); Thu, 15 Jul 2021 00:02:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21948C06175F; Wed, 14 Jul 2021 20:59:50 -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=N4ZTZot+vt+8KjslbnqTsaCIrlOXYH7ezn6cHh84c28=; b=I2NAAnFRjFgCXwxN/BTAkcsRzD g1vSHcTfsgjcdaW8siam6p7pCtU+KzFbu74U7ig1wGrUmsHV16/2T3CMWeAtODAtCqijqd/PcNtor uqM7gr2SubWx0LK3Cl4LH5fqF/oA+C+4kttJZOdsb4evb2zJjJABFZfVQejsXF14kpA/4GID07G3U QnTiAkHQKGyEpxbDrYJukIqRPajHYxIDmyCVCGVmDLYSqCeaPmd33y/+vn7LlrHdU795tdr4QA0El WRU/u4iiv5zR94jpiSEE4cv/0XDaqvr7Z129cf0gaFAQCwmJMPEj4Upj8it/yqvkaxcQAA8esLi3q kw752PxQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3sWB-002vYF-Ty; Thu, 15 Jul 2021 03:58:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , Jeff Layton , "Kirill A . Shutemov" , Vlastimil Babka , William Kucharski , David Howells Subject: [PATCH v14 026/138] mm/writeback: Add folio_wait_stable() Date: Thu, 15 Jul 2021 04:35:12 +0100 Message-Id: <20210715033704.692967-27-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 Move wait_for_stable_page() into the folio compatibility file. folio_wait_stable() avoids a call to compound_head() and is 14 bytes smaller than wait_for_stable_page() was. The net text size grows by 16 bytes as a result of this patch. We can also remove thp_head() as this was the last user. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton Acked-by: Kirill A. Shutemov Acked-by: Vlastimil Babka Reviewed-by: William Kucharski Reviewed-by: David Howells --- include/linux/huge_mm.h | 15 --------------- include/linux/pagemap.h | 1 + mm/folio-compat.c | 6 ++++++ mm/page-writeback.c | 24 ++++++++++++++---------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index f123e15d966e..f280f33ff223 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -250,15 +250,6 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, return NULL; } -/** - * thp_head - Head page of a transparent huge page. - * @page: Any page (tail, head or regular) found in the page cache. - */ -static inline struct page *thp_head(struct page *page) -{ - return compound_head(page); -} - /** * thp_order - Order of a transparent huge page. * @page: Head page of a transparent huge page. @@ -336,12 +327,6 @@ static inline struct list_head *page_deferred_list(struct page *page) #define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; }) #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; }) -static inline struct page *thp_head(struct page *page) -{ - VM_BUG_ON_PGFLAGS(PageTail(page), page); - return page; -} - static inline unsigned int thp_order(struct page *page) { VM_BUG_ON_PGFLAGS(PageTail(page), page); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0c5f53368fe9..96b62a2331fb 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -772,6 +772,7 @@ int folio_wait_writeback_killable(struct folio *folio); void end_page_writeback(struct page *page); void folio_end_writeback(struct folio *folio); void wait_for_stable_page(struct page *page); +void folio_wait_stable(struct folio *folio); void __set_page_dirty(struct page *, struct address_space *, int warn); int __set_page_dirty_nobuffers(struct page *page); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 41275dac7a92..3c83f03b80d7 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -29,3 +29,9 @@ void wait_on_page_writeback(struct page *page) return folio_wait_writeback(page_folio(page)); } EXPORT_SYMBOL_GPL(wait_on_page_writeback); + +void wait_for_stable_page(struct page *page) +{ + return folio_wait_stable(page_folio(page)); +} +EXPORT_SYMBOL_GPL(wait_for_stable_page); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c2c00e1533ad..a078e9786cc4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2877,17 +2877,21 @@ int folio_wait_writeback_killable(struct folio *folio) EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); /** - * wait_for_stable_page() - wait for writeback to finish, if necessary. - * @page: The page to wait on. + * folio_wait_stable() - 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 folio_wait_stable(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) + folio_wait_writeback(folio); } -EXPORT_SYMBOL_GPL(wait_for_stable_page); +EXPORT_SYMBOL_GPL(folio_wait_stable); -- 2.30.2