Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1605963pxb; Thu, 4 Nov 2021 05:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmdlaP0FaSyQKoE6xLBIRb4I9TcVsUs190Zv3SQsd/Ansm2NoOt+8S/QNDWfl7a3Le9DNQ X-Received: by 2002:a05:6402:51ca:: with SMTP id r10mr13879580edd.0.1636028924439; Thu, 04 Nov 2021 05:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636028924; cv=none; d=google.com; s=arc-20160816; b=EQAdoJ2CrKw/MclWAs6CG67QglRv4EK8aJ1H7xz/JK2/OJK08hCRU7GAoiGhxtnBal QHvpARMyUHqcIjENijfHbxQxfIhCLki87PHAYgvP0LT7pMQjxmaAAQzOu2a7czwunZ7n u/e/GJ1iqWt/uy2FJM0t52SHGu1+xxc+XutvjviXug3Q6nSDFX6SoAKQ+8YCAnyhEK6I o4aOTl39zZlKzeOsJwyJRLO4JvKB2FcyRWk3M6AKOayPIwppx7Mc3wlIE+m9Fxa/stWi a0DIl4X+YeMc9W4/6+JQ0kwNzr5pY2bpM3fW1y68E0da1bYlLbrjhSDWhnNtWypiz9oM /9jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kvPhcl8s+fMEqS/cULaE6wmnEx5WH+3Y6yjBqC86VnA=; b=oLj2bClPWvcBN+hRQOS5K4JF5Btqu2eTZut+tG77W0Vxi35ouckLe22y4KshPAjEL5 Gk06Nxpdl26DLM+2AYwz9WY1n3GHQw7wx9P9Ts35//qxg9KP0VtHlYjKTMFnmT7KcDsv nHrGWVDAgw9EN+bqChBBnPTLanK9HZVgjkwJdi9sQYLhkeW5Qa+TGLmTmaoToZpVnA9L 7f2deVJ2LQZGdjjd1H5u1y5H8Iabhg54RB8TuGotVdZPHillMFFWPVs/fTbQxoCtWyUh RKXZxXrqIgimcHXsImmvuagNa3e19Zm6Lmm4Rzi0JxTc9fpahJRCTPDdl69oCU0lmkHh T1wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=scbFgVK7; 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 q9si1309335edd.89.2021.11.04.05.28.17; Thu, 04 Nov 2021 05:28:44 -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=scbFgVK7; 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 S230420AbhKDM0q (ORCPT + 99 others); Thu, 4 Nov 2021 08:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230148AbhKDM0p (ORCPT ); Thu, 4 Nov 2021 08:26:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D1EC061714 for ; Thu, 4 Nov 2021 05:24:07 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.