Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1727687pxb; Thu, 4 Mar 2021 20:29:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWNZS5WVZvfVGY7pXXUSM2CmY4jQHyNqA25UqP4U6OOS6nJMnr2KXLkv/t0gUmWeRtdp2+ X-Received: by 2002:a05:6e02:e87:: with SMTP id t7mr6921136ilj.211.1614918583547; Thu, 04 Mar 2021 20:29:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614918583; cv=none; d=google.com; s=arc-20160816; b=CK6QoHYgVWVzSSjCv7onlHoZ96aPTiHI68U+4wh6TNkIQ70sCzl73Oe+aWRXbm+y+O t8Cn5FGQNGVHp/Tdwnsd7JUWjVCNQOFkZmsUw+rgZVOOyH/qHpPjDJllG71uMUjWO/1q bAljf6lri+bKNroUnnq9wwZVr2jBX0u7fe057Vi0Vku7KsB6ZbvQhw9p4o5HUo8TYlDG 1U77N6r/WOi2IuCT6bIJBRzFCB8/OXZ+JnZDqu8fSYJlKTnIvp2VGQuOWIe0xba5+S5d tOf94vfCeQFfW8xUt4ze7sq9sMJmDNg2MzJUPHC+RDP8n/XfMBFi419UjEVDumir9mFp cIWw== 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=xwpBIqAEuLM6Zld1KeVwy1SyI/6FWtXxGIYJ0bk67Ms=; b=mKl+LKKLyi/bK1cqJbty76RmGytFo4ZGWFTR4Y9TPGxZF//P4WwZdFlKzafcObuQ29 +iZHC7hgb/BWQ7GUq9RSJsoAjIGGn43iIhCCY/I8dFqo1FjTz6VMvWQPuNPgqvy0HdSs vh1VblS9kkoshn2+tkiCGugi+31U9SjZS2zua1X20F7zQrTCUuSfL0Cem2lgPsb+rX7U fh131xktGHb8eELwTdq5Y9EIInvQeEVom+qIH+Pw1X2FvTZa8R+VOl/KG9o4kNR7IWon 1xpN7q0tvgUnbv8hxqW3sb+ZuNPwrHJ3pOFuO7ikCCiK/SQONsCredfwFnLG63j0xwnf DKgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nZiEQlDA; 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 x6si1123184jas.100.2021.03.04.20.29.30; Thu, 04 Mar 2021 20:29:43 -0800 (PST) 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=nZiEQlDA; 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 S229573AbhCEE2D (ORCPT + 99 others); Thu, 4 Mar 2021 23:28:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhCEE2C (ORCPT ); Thu, 4 Mar 2021 23:28:02 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE74FC061574; Thu, 4 Mar 2021 20:28:02 -0800 (PST) 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=xwpBIqAEuLM6Zld1KeVwy1SyI/6FWtXxGIYJ0bk67Ms=; b=nZiEQlDA3UiHbQK+LAi8BPFS61 pB+mHWU8LiaXKjDF3kxZeSTkTK3OkjP4umVg2cdiABFuLz6H45hnwPCd0a7ybRUwVsyHA1OIzANUT 5Q2d/uFqBS1raiTwf8RvPqhUP7VGa6jAU6vtBF8Za/ihsNvQdLSZLKCarFURQFzlNWGxNao0bxhCh eG6rqCE1S/m/nstsiTogOdORYksqHAXQoQHAhzbOFgXwtEvgJe40VyiAUdoL6xPLtsvnUs3MrDkNa 9y1pNasEG50jfZqfwtvdyp0yOl2S0mWayXvU4qK2tjHz8PFmnp9X1PXmxxwvSn7xOXabyy9fWkbYy APFybfzA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lI23F-00A4qX-PL; Fri, 05 Mar 2021 04:26:58 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v4 24/25] mm/filemap: Convert page wait queues to be folios Date: Fri, 5 Mar 2021 04:19:00 +0000 Message-Id: <20210305041901.2396498-25-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210305041901.2396498-1-willy@infradead.org> References: <20210305041901.2396498-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reinforce that if we're waiting for a bit in a struct page, that's actually in the head page by changing the type from page to folio. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 6 +++--- mm/filemap.c | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 6ee4bc843f98..2236f726bf01 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -611,13 +611,13 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, /* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */ struct wait_page_key { - struct page *page; + struct folio *folio; int bit_nr; int page_match; }; struct wait_page_queue { - struct page *page; + struct folio *folio; int bit_nr; wait_queue_entry_t wait; }; @@ -625,7 +625,7 @@ struct wait_page_queue { static inline bool wake_page_match(struct wait_page_queue *wait_page, struct wait_page_key *key) { - if (wait_page->page != key->page) + if (wait_page->folio != key->folio) return false; key->page_match = 1; diff --git a/mm/filemap.c b/mm/filemap.c index 57f46ff2f230..1cdd565c69a6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -992,11 +992,11 @@ EXPORT_SYMBOL(__page_cache_alloc); */ #define PAGE_WAIT_TABLE_BITS 8 #define PAGE_WAIT_TABLE_SIZE (1 << PAGE_WAIT_TABLE_BITS) -static wait_queue_head_t page_wait_table[PAGE_WAIT_TABLE_SIZE] __cacheline_aligned; +static wait_queue_head_t folio_wait_table[PAGE_WAIT_TABLE_SIZE] __cacheline_aligned; -static wait_queue_head_t *page_waitqueue(struct page *page) +static wait_queue_head_t *folio_waitqueue(struct folio *folio) { - return &page_wait_table[hash_ptr(page, PAGE_WAIT_TABLE_BITS)]; + return &folio_wait_table[hash_ptr(folio, PAGE_WAIT_TABLE_BITS)]; } void __init pagecache_init(void) @@ -1004,7 +1004,7 @@ void __init pagecache_init(void) int i; for (i = 0; i < PAGE_WAIT_TABLE_SIZE; i++) - init_waitqueue_head(&page_wait_table[i]); + init_waitqueue_head(&folio_wait_table[i]); page_writeback_init(); } @@ -1059,10 +1059,11 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, */ flags = wait->flags; if (flags & WQ_FLAG_EXCLUSIVE) { - if (test_bit(key->bit_nr, &key->page->flags)) + if (test_bit(key->bit_nr, &key->folio->page.flags)) return -1; if (flags & WQ_FLAG_CUSTOM) { - if (test_and_set_bit(key->bit_nr, &key->page->flags)) + if (test_and_set_bit(key->bit_nr, + &key->folio->page.flags)) return -1; flags |= WQ_FLAG_DONE; } @@ -1096,12 +1097,12 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, static void wake_up_folio_bit(struct folio *folio, int bit_nr) { - wait_queue_head_t *q = page_waitqueue(&folio->page); + wait_queue_head_t *q = folio_waitqueue(folio); struct wait_page_key key; unsigned long flags; wait_queue_entry_t bookmark; - key.page = &folio->page; + key.folio = folio; key.bit_nr = bit_nr; key.page_match = 0; @@ -1193,7 +1194,7 @@ int sysctl_page_lock_unfairness = 5; static inline int wait_on_folio_bit_common(struct folio *folio, int bit_nr, int state, enum behavior behavior) { - wait_queue_head_t *q = page_waitqueue(&folio->page); + wait_queue_head_t *q = folio_waitqueue(folio); int unfairness = sysctl_page_lock_unfairness; struct wait_page_queue wait_page; wait_queue_entry_t *wait = &wait_page.wait; @@ -1213,7 +1214,7 @@ static inline int wait_on_folio_bit_common(struct folio *folio, int bit_nr, init_wait(wait); wait->func = wake_page_function; - wait_page.page = &folio->page; + wait_page.folio = folio; wait_page.bit_nr = bit_nr; repeat: @@ -1370,12 +1371,13 @@ int put_and_wait_on_page_locked(struct page *page, int state) */ void add_page_wait_queue(struct page *page, wait_queue_entry_t *waiter) { - wait_queue_head_t *q = page_waitqueue(page); + struct folio *folio = page_folio(page); + wait_queue_head_t *q = folio_waitqueue(folio); unsigned long flags; spin_lock_irqsave(&q->lock, flags); __add_wait_queue_entry_tail(q, waiter); - SetPageWaiters(page); + SetFolioWaiters(folio); spin_unlock_irqrestore(&q->lock, flags); } EXPORT_SYMBOL_GPL(add_page_wait_queue); @@ -1503,10 +1505,10 @@ EXPORT_SYMBOL_GPL(__lock_folio_killable); int __lock_folio_async(struct folio *folio, struct wait_page_queue *wait) { - struct wait_queue_head *q = page_waitqueue(&folio->page); + struct wait_queue_head *q = folio_waitqueue(folio); int ret = 0; - wait->page = &folio->page; + wait->folio = folio; wait->bit_nr = PG_locked; spin_lock_irq(&q->lock); -- 2.30.0