Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3917339pxj; Tue, 11 May 2021 15:05:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVhaE8LC4F2XgZ72chHQvmYWWjmMaAUk35V+EH/6nEVW3/LTDc29yxL6M77oJIdfBNACAB X-Received: by 2002:aa7:d955:: with SMTP id l21mr38750696eds.118.1620770745971; Tue, 11 May 2021 15:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620770745; cv=none; d=google.com; s=arc-20160816; b=rA7lQ7AZB4oLwV6MwDdBkRbMAIyHmXl1PQu6sZlxv+K/QPxEJRcza6wOCCMtuWwkmw 6Z4yXH0TedNYWdMqlVm0EpEzkOKcaMPeG0GstmrXBNcXEXYOnI2kx4OXQ8yAp1kGg2VF 9qZI0mDV7uozPeKNoovlQ38uIzOkZeGluTR5HMAkeEB3TIUBEPRzDZ0piDbeL6daOSHC +fqwM7wdF6Cy1svryg7NJ9vchTkmuTqOJEftnyubF7x6yIt0EzFjiAFYTHrz+VWOqLU0 tPVgFfJ4O4WxOs6Jk+tb6N+LBpXv1mEu0XEL7tUCvLmjVDKCedUkANa/knIEsXMQx6E0 FPLw== 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=AtVyZwPq9MHbp7AqRYfbY7+rK/M2+SCPfu6LCiQJBE8=; b=0cco5cQjoTufmVEn7r+AI8T5BhhtfL5/FD/+cyZB9Q/p6x7Ry84iW+5DtCwOQiIiBN k8VIZi7kMIWzR+s0z652U4Kp+X/L+SvBb9/QHeHHT3CBiJCzmtQJj68iso7dZtMJti4O GelowjKdcRuBtwSPCQ8PZl5wgj5+3Omr63rg3/+y+upOAL2pe8lvs+uynK8EghCcawqS Cwomqsa4F/k3yqDjhYeLsocm3+VCM7w1HgfKyD3hN3jg19LlQgMiU2LURuJJi4nXddCH RHWvf7W2pTuypHK6PDHHKtEUo8BR1VcVEuMb6QpcVUHx2DAfCPtWv4yGyxfghbqtyHSl GCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CoB+CYcM; 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 zb13si4861948ejb.487.2021.05.11.15.05.17; Tue, 11 May 2021 15:05:45 -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=CoB+CYcM; 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 S230111AbhEKWEw (ORCPT + 99 others); Tue, 11 May 2021 18:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKWEw (ORCPT ); Tue, 11 May 2021 18:04:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341FFC061574; Tue, 11 May 2021 15:03:45 -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=AtVyZwPq9MHbp7AqRYfbY7+rK/M2+SCPfu6LCiQJBE8=; b=CoB+CYcM5vJd4w6etnKmPctSnK IKZyckvZTDPxb00YEHFa3ZQvveFTTxULBR4SE2TGanktcX2QMMLqlvcqw6FwSX4VqFoMZqWxHDpjV gpGgUHLNDysqpa3AkLUaENrI9AA86SOc3eK0xcPNq5vV78odD6FkqTQh8be2hPY5zmg9sCWV48vtb L2jWKGsqaH4GMwHlFhY2FWV64nDRQCjjGpTdm+k5FGD5AwzpFypSDrE7QQI7cvBj2DDHdGVRHryRV yAh8YWQwJz54Y+rDtjPbsUi5ENyTJtF5PXQM35t49e/fZ5EaCRyiePyEGDR0mm5uRGhfEXfweqpII qOQmcgwg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lgaSi-007iUD-Fm; Tue, 11 May 2021 22:02:53 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Jeff Layton Subject: [PATCH v10 23/33] mm/filemap: Add folio_wait_locked Date: Tue, 11 May 2021 22:47:25 +0100 Message-Id: <20210511214735.1836149-24-willy@infradead.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210511214735.1836149-1-willy@infradead.org> References: <20210511214735.1836149-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 folio_wait_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 21e394964288..e2648d906a84 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -721,23 +721,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 folio_wait_locked(struct folio *folio) +{ + if (folio_locked(folio)) + wait_on_page_bit(&folio->page, PG_locked); +} + +static inline int folio_wait_locked_killable(struct folio *folio) +{ + if (!folio_locked(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); + folio_wait_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 folio_wait_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 28bf50041671..73c31b63392f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1645,9 +1645,9 @@ int __folio_lock_or_retry(struct folio *folio, struct mm_struct *mm, mmap_read_unlock(mm); if (flags & FAULT_FLAG_KILLABLE) - wait_on_page_locked_killable(page); + folio_wait_locked_killable(folio); else - wait_on_page_locked(page); + folio_wait_locked(folio); return 0; } if (flags & FAULT_FLAG_KILLABLE) { -- 2.30.2