Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2088419pxf; Sat, 20 Mar 2021 04:13:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIKhJuyrZjkR/kqVEdT0lvdWOvKZf6s+Ng9NiMvZpFOdne+WBRu6R2gR/WhKfE4wLxtFCy X-Received: by 2002:a05:6402:312b:: with SMTP id dd11mr14960278edb.149.1616238833886; Sat, 20 Mar 2021 04:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616238833; cv=none; d=google.com; s=arc-20160816; b=dPOZYWnDyEB02uq4wpa8tsQ68gMz5U3bSSULe7AzQqi1UzEecigLp6/4iawz8cs1O5 YkHxooi4ElfKmVHnelYShrk277hlEnaBNHnw1FyQFy+6wUF2zm+tPvIdaepJR0ho5o2j +bb7ps+pP0x5bpQI7PJ7N/uHaaMvirOMqdZeknVgGYGFlFX5O0blcU6ljB16gKR3vI3D PbstPtG1uEjVG0U8kOHcJ8uAu3tiWsmpaRE9lsVULInyvZvXP3EkswDXhjk9lH76cXZ/ N/GCwR2vf8dDQtoFgQajHkNLDLJZg+RQnEnr0GddtSazJ06ntHgR5oG3LF3uuYc6hBRF 76ig== 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=MGeBPoR/tv5xpwOSIW2JVU9MNvSKrQK5MirrXuh+2jU=; b=FGJzuZPq/XdDGipLByufQ9nd2xBje7QLN5qwEbiOZaA505xyugUu/rVSGNrghq9of6 nuMTGGiD+6wXo0J9SmnPdSZ1hq3CJeOzB2QPifgPEEJCzM2sifAg+koAy5jyvXVZ3gX9 /DuDe2/pxW760RQXhpjQ7eROAZohDbLeVrlGB+GzxqFEn6mJJHIaUZn7Yqwrd+9Wz7Ur 04gHgmKOD4ItBR1rnKb8f2T17dmc6yJ2hFoCt7Dq+zpm24IRuWMD7GnanLINMkvqnpxu AdOBMu7ZgSFMwifPleWhDTnOFfSmhTZ3c1AXbkEupUspdmABS1+IqJaPimYK0JTAeS0n AA1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EGzQIfwZ; 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 z21si6027541edr.51.2021.03.20.04.13.24; Sat, 20 Mar 2021 04:13:53 -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=EGzQIfwZ; 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 S230201AbhCTFoJ (ORCPT + 99 others); Sat, 20 Mar 2021 01:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhCTFnn (ORCPT ); Sat, 20 Mar 2021 01:43:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A36C061762; Fri, 19 Mar 2021 22:43:42 -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=MGeBPoR/tv5xpwOSIW2JVU9MNvSKrQK5MirrXuh+2jU=; b=EGzQIfwZFtmuVcJ8+b8T0Gzts2 vNfmRm/XvfK3p4jOSRzdNu9bZgr1x6aKV61QuaFLr9fzeW3z43T5kr12li9ie7RqE12mpmacsid8S JyYpfY20Ls0G/GlipJBBIgYBXegIbuodJTOZTDg/GsglHN3auXqIs3ad/6CBwkRcodtrVvZkaVxA8 p0qoNsWYz9lrOv9RVKFa3Rpn5lDiQ53NZUwNxZs7zb6Yu/JcCpIGtMu4oNMpbGjLvzlZl1JvQfBDO NeUYJueg7sfzDn/kb6ZSDvx0rfYr4Q3zx+oxE+9RUu0iV5OjmJQRea57ugbwDwb+dMWbl+YAwIztZ xwyYkZsA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lNUOT-005Sen-SX; Sat, 20 Mar 2021 05:43:26 +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 Subject: [PATCH v5 20/27] mm/filemap: Add wait_on_folio_locked Date: Sat, 20 Mar 2021 05:40:57 +0000 Message-Id: <20210320054104.1300774-21-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210320054104.1300774-1-willy@infradead.org> References: <20210320054104.1300774-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) --- 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 38f4ee28a3a5..a8e19e4e0b09 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -777,23 +777,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 35e16db2e2be..99758045ec2d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1604,9 +1604,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