Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1587990pxf; Fri, 9 Apr 2021 12:10:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVZVxOs1N4Z4zBCx1mqWqjL8VVgc0SzoUyo3nB78+aYxOqIu9m/VSBH6R29wUHtZGhmtnT X-Received: by 2002:a17:90a:498d:: with SMTP id d13mr15978201pjh.47.1617995413996; Fri, 09 Apr 2021 12:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617995413; cv=none; d=google.com; s=arc-20160816; b=OzqT8Q8OWo5hkmjaM18Q+qhNEMXd1QouEbvWJZQDA1jbjm+G3TOtolwWBfIkOSl68D G+TPtkd3d7AsC596F4eWGZ91vjyP8jUb63sBsjn2gK/YKMAmBy4tZa1YMnB4Y397Tuk9 ydbJnn6PElrusJY6ljrx7BF1bImjk76Seyazwo3U63LhxtBZU5PtXzaiFm++MDvR5SBE NBr1PGN3+joLtTNQGGVeyTfJqSOhprndJu2dhFbnho7tm9NZwrCXM81Axm5RthFKhLtJ swDsob6LZnrHSlPnylXFpZ+MXgOWe9HQ4QnLA5jnCIemohOBXseX+VcA3Qxt5GGRwmit W/8w== 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=3OiOISSuA2SH6R+I8ePIgoOcVjWcdXLcZNZAVLZj/Ik=; b=uA6EuDSTypdHWZ84Dli03sdbQrrUN0+hL1jshlKiC7hJwwSPZLmcjE1OihNtAZgpdA fIecCWfuxJ5P8QkZP979bv30dP5GnTIUotY9GeSLjGLOApVuj+0ZwGsa2p/3IHO9BrFu j2W5R5l7F0lg9TwrYBvHLFeujH6irQ7ljcFSQRMkgYv68esxMDTInofMhbpVuBYB091a u4hhQxyXdstd3Gv5Wora9K3ghKWdf4DVnoMm4KL6qVVJ888VvxBLWAMA5uBYyV5761uU FANkB1VdePejkpds568slceqL1jU5r3521QRGK6lOwY716aAGhxmwqOelktm8gTqd1s0 pq+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="BTTj/YJV"; 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 p69si3753247pgp.313.2021.04.09.12.10.00; Fri, 09 Apr 2021 12:10:13 -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="BTTj/YJV"; 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 S234826AbhDITJf (ORCPT + 99 others); Fri, 9 Apr 2021 15:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234816AbhDITJc (ORCPT ); Fri, 9 Apr 2021 15:09:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B188C061762; Fri, 9 Apr 2021 12:09:17 -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=3OiOISSuA2SH6R+I8ePIgoOcVjWcdXLcZNZAVLZj/Ik=; b=BTTj/YJVJCB7p0wptPQZ/SEn3w gH7J6RYldNBQRbQd4AEF269OtGzrq7hZpKFIc4VjAu71k5IwtqDE0PmLOGZjXFuy73W0kpVEPP+0D J2x3aED8b3Xze98nL2CGDrIxsmaLAUFfRTe0/hfJvUSKpl0PwANGYd0niYPNMWnlDuuTYuh+RWlDO TAHFCZw0gbjywakSa5SRHQqcgEJI4LmGidD7dDS+vxQ+BEn1MAJ9+6Hy/ZaGslEYwJ/LIERzhpSOB XujYsAzMohTCT+BrXbxjw6bhtRWAq8+F/qQWrQgWoAsQh3diNyLWDv9Kuoa2RZL7A5TqBrCxKRBEg oWleqCtA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUwU4-000oTh-4r; Fri, 09 Apr 2021 19:08:04 +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 22/28] mm/filemap: Add wait_on_folio_locked Date: Fri, 9 Apr 2021 19:50:59 +0100 Message-Id: <20210409185105.188284-23-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 Also add wait_on_folio_locked_killable(). Turn wait_on_page_locked() and wait_on_page_locked_killable() into wrappers. This eliminates a call to compound_head() from each call-site, reducing text size by 200 bytes for me. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton --- include/linux/pagemap.h | 26 ++++++++++++++++++-------- mm/filemap.c | 4 ++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 00864e098693..18c4c2ae8074 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -797,23 +797,33 @@ extern void wait_on_page_bit(struct page *page, int bit_nr); extern int wait_on_page_bit_killable(struct page *page, int bit_nr); /* - * Wait for a page to be unlocked. + * Wait for a folio to be unlocked. * - * This must be called with the caller "holding" the page, - * ie with increased "page->count" so that the page won't + * This must be called with the caller "holding" the folio, + * ie with increased "page->count" so that the folio won't * go away during the wait.. */ +static inline void wait_on_folio_locked(struct folio *folio) +{ + if (FolioLocked(folio)) + wait_on_page_bit(&folio->page, PG_locked); +} + +static inline int wait_on_folio_locked_killable(struct folio *folio) +{ + if (!FolioLocked(folio)) + return 0; + return wait_on_page_bit_killable(&folio->page, PG_locked); +} + static inline void wait_on_page_locked(struct page *page) { - if (PageLocked(page)) - wait_on_page_bit(compound_head(page), PG_locked); + wait_on_folio_locked(page_folio(page)); } static inline int wait_on_page_locked_killable(struct page *page) { - if (!PageLocked(page)) - return 0; - return wait_on_page_bit_killable(compound_head(page), PG_locked); + return wait_on_folio_locked_killable(page_folio(page)); } int put_and_wait_on_page_locked(struct page *page, int state); diff --git a/mm/filemap.c b/mm/filemap.c index 73c8d7102157..d23430ad5bbc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1643,9 +1643,9 @@ int __lock_folio_or_retry(struct folio *folio, struct mm_struct *mm, mmap_read_unlock(mm); if (flags & FAULT_FLAG_KILLABLE) - wait_on_page_locked_killable(page); + wait_on_folio_locked_killable(folio); else - wait_on_page_locked(page); + wait_on_folio_locked(folio); return 0; } if (flags & FAULT_FLAG_KILLABLE) { -- 2.30.2