From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EF8BC433EF for ; Thu, 4 Nov 2021 12:24:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 01FA9611C3 for ; Thu, 4 Nov 2021 12:24:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01FA9611C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6EF076B006C; Thu, 4 Nov 2021 08:24:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 650A6940008; Thu, 4 Nov 2021 08:24:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 518B7940007; Thu, 4 Nov 2021 08:24:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 4261B6B006C for ; Thu, 4 Nov 2021 08:24:08 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F058A18478DB0 for ; Thu, 4 Nov 2021 12:24:07 +0000 (UTC) X-FDA: 78771164934.02.67E7B56 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 2E83310000B4 for ; Thu, 4 Nov 2021 12:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kvPhcl8s+fMEqS/cULaE6wmnEx5WH+3Y6yjBqC86VnA=; b=scbFgVK7CaJK9pBBTNZP3VS7Dr Je5lwmD2hXfS2o/ckGm9yYsYKDxHT9R7NINusm+P7s51+WjacR697MYsYKzGQiJdoewlWfX6iMMq4 LVMfW+mHSFqhtf66Hz9vQBjp7ArM7VokDVWE7sPuXEPhEOtQSw4DXYujEN4zj2Gmt9PVR7N8t/NdV N/UTRd8fU69+vOmBCW6TQ8eKZOicv2sBejeLCgZvhha7uYO4fkIBWe0WrSUoZmm5ocgWd2Cl8zk8/ nJkrlwIPRMRkjJi20BVa/ER0xfWco665pMZUTox/zw0f5u2i68u/h1QgyhF1gTo1NqW6HkhANTb8J 5/zgY5tQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mibkd-005rNG-CC; Thu, 04 Nov 2021 12:22:07 +0000 Date: Thu, 4 Nov 2021 12:21:51 +0000 From: Matthew Wilcox To: Alistair Popple Cc: akpm@linux-foundation.org, dhowells@redhat.com, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jglisse@redhat.com, jgg@nvidia.com, rcampbell@nvidia.com, jhubbard@nvidia.com Subject: Re: [PATCH] mm/migrate.c: Rework migration_entry_wait() to not take a pageref Message-ID: References: <20211104103338.891258-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211104103338.891258-1-apopple@nvidia.com> X-Rspamd-Queue-Id: 2E83310000B4 X-Stat-Signature: hsxwub8z97wtocnme9nmsa4wjifhkmdz Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=scbFgVK7; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam01 X-HE-Tag: 1636028647-790396 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 04, 2021 at 09:33:38PM +1100, Alistair Popple wrote: > +++ b/mm/filemap.c > @@ -1356,6 +1356,88 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q, > return wait->flags & WQ_FLAG_WOKEN ? 0 : -EINTR; > } > > +/** > + * migration_entry_wait_on_locked - Wait for a migration entry to be removed > + * @page: page referenced by the migration entry. > + * @ptep: mapped pte pointer. This function will return with the ptep unmapped. > + * @ptl: already locked ptl. This function will drop the lock. > + * > + * Wait for a migration entry referencing the given page to be removed. This is > + * equivalent to put_and_wait_on_page_locked(page, TASK_UNINTERRUPTIBLE) except > + * this can be called without taking a reference on the page. Instead this > + * should be called while holding the ptl for the migration entry referencing > + * the page. > + * > + * Returns after unmapping and unlocking the pte/ptl with pte_unmap_unlock(). > + * > + * This follows the same logic as wait_on_page_bit_common() so see the comments > + * there. > + */ > +void migration_entry_wait_on_locked(struct page *page, pte_t *ptep, > + spinlock_t *ptl) > +{ > + struct wait_page_queue wait_page; > + wait_queue_entry_t *wait = &wait_page.wait; > + bool thrashing = false; > + bool delayacct = false; > + unsigned long pflags; > + wait_queue_head_t *q; > + > + q = page_waitqueue(page); You're going to need to update this patch to apply to Linus' current tree; page_waitqueue() went away in favour of folio_waitqueue(). It seems like it would look simpler if this were a patch which modified folio_wait_bit_common() instead of doing a manual inline of it into this function.