Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5013511pxj; Wed, 9 Jun 2021 07:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJworZfqPN778vv40hXHwQI0XYFAm467YMZ7BKe8FeTPnxJ+IuWPT4PXax/zBQZACqXStiOm X-Received: by 2002:a05:6402:1216:: with SMTP id c22mr30792273edw.36.1623248280892; Wed, 09 Jun 2021 07:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623248280; cv=none; d=google.com; s=arc-20160816; b=jp802jvYjGNECnCYIwrCqi/LdcsQMRDIrnOu4P8wpBrwvRRYjiQXUKzraO6qyC0yXs sPXnA9ll0eHbT8fJC1mf+DidtSYnN3kwxfKrnEtBJORG2pLxq4h6DIrDwYFMeUD6lMwa N9luMzEwXGe+FIiK4TM39BoPUkzSo3SlU/LPB7Gj1APFZ7OMtmo4aTYtCeSAYDE469vF xYQ1XG8UmrHrNhbtW0IvLsRAWnY4LoZQuhXItdodo2g7cZtaBbzzn372QLd1gngjqqy+ QMbDgdTdmx/uq+VrbyfTDJagEg3PedM8mrrEfLH+dioYLVHzxeN3VzSeBkHpv8AaqW36 OZUw== 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=VU9NxlTxI6RSkxw6tvgV5z3t/ysaeFQxXfksToOwW18=; b=Kl8uk2nbsKtCQSFSrX7n3/8mDXPut/skrdw8ho/teMb3isQDlaGYGXCbF5HbQu804y s/I1xwO1mQsNhNnBMpaNweXSF6KN66P7rEaGswYfhcsbAsLItCWhRd3UMCjDYIEjUxAa lZ04LwpMfjMZMTQhsYGMdQu7hzwSQmEmujF8svEcY2sun8vaj5p5GfVqtujIl9UkeXYv WKNaxf/TtXKVtAOpiM6HoN3fO9E8YoBuQ6dydTFbhKiuSJLI/N/TkK41sEvc1ScGwkeD /ckBHNOqz61r/zyhjBChEk91p8gGGUV6hxIA432GN717B5R5uzX6SLaAqg/rI2QA29Na Kzuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=XdlwuXVI; 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 m20si2590995ejl.598.2021.06.09.07.17.36; Wed, 09 Jun 2021 07:18:00 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=XdlwuXVI; 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 S235224AbhFIKBf (ORCPT + 99 others); Wed, 9 Jun 2021 06:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbhFIKBe (ORCPT ); Wed, 9 Jun 2021 06:01:34 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47562C061574 for ; Wed, 9 Jun 2021 02:59:40 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id c11so30906649ljd.6 for ; Wed, 09 Jun 2021 02:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VU9NxlTxI6RSkxw6tvgV5z3t/ysaeFQxXfksToOwW18=; b=XdlwuXVIHAqyX/dYnfnFhPrOEtblNWpTNalxKuzxbtmlQla8K1FKw1xGx0KUCSsjyM LHEcJfxueEq74pMSguJ/gwmu0qKeuwQEH0wt6omaYGb+bhZzGBliVhqqYFmV5WRwRMBW WQ/KGuEMPwerlHG84QzM3QN5rS3ttjTHB/NjPbdGcAaZ/Qxd+/royNrzU3nL1dJPqwB7 T0Zh37PWLQhPQAmKAnMRWvTqJghMSdZjw9Ttq1etJtDNFkfNAT+qGBw1jHRIVDr2y22L tuhTZsFI7K4tz+Kn0LnjeDJXpjckNQgMFUQVOllIXD7EQhh7OAoQjyJLTaEU8rNuIrRQ O+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VU9NxlTxI6RSkxw6tvgV5z3t/ysaeFQxXfksToOwW18=; b=CivOCq9ZkxCtxz+VvMcz80MAsvZUz3Fj4GUAelAEuYNXJo/AStLMF8zQfvcLD1Mr7h wvZ0OlodKzBWA24u5YlBgYnmM/DGwkszbMjxYiE8fszpr76+Ogaga/HF1kjm2l1ZFTz5 fS7Vh5VX1Fa0fyaEA5cFDNKk5RnWB2pbFKmO4fio1DnwYOmdhyQVTc7P+cZtAYuwv7ni fuK/dk+n2f2phQzWMKjR9GurcTz/wZNss6oa1MwyydDZttZ98W/5U7vy5uYannYSb/C/ AP8hOr0vBVbSGk4NPs72hAKaTtSzKqFd4sfshbi5mJBPx1wkOuCc1pGv7E8zdcpEWnsu mcWA== X-Gm-Message-State: AOAM531R4RllN2MrmEXngcoPcaHJ1GWrm1z0ICijOkF72nDinmHwiMCy rZxFCuWemM54s83+RG3lMIBtzQ== X-Received: by 2002:a2e:a16e:: with SMTP id u14mr20973564ljl.343.1623232778569; Wed, 09 Jun 2021 02:59:38 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id a22sm272105ljm.13.2021.06.09.02.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 02:59:37 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 136C410265B; Wed, 9 Jun 2021 12:59:53 +0300 (+03) Date: Wed, 9 Jun 2021 12:59:53 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: Xu Yu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, hughd@google.com, akpm@linux-foundation.org, gavin.dg@linux.alibaba.com Subject: Re: [PATCH v2] mm, thp: use head page in __migration_entry_wait Message-ID: <20210609095953.s6bgfjnwkwvjhfo3@box.shutemov.name> References: <20210608120026.ugfh72ydjeba44bo@box.shutemov.name> <20210608125838.6ixdlz3t334gjnp7@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 02:35:23PM +0100, Matthew Wilcox wrote: > On Tue, Jun 08, 2021 at 03:58:38PM +0300, Kirill A. Shutemov wrote: > > On Tue, Jun 08, 2021 at 01:32:21PM +0100, Matthew Wilcox wrote: > > > On Tue, Jun 08, 2021 at 03:00:26PM +0300, Kirill A. Shutemov wrote: > > > > But there's one quirk: if split succeed we effectively wait on wrong > > > > page to be unlocked. And it may take indefinite time if split_huge_page() > > > > was called on the head page. > > > > > > Hardly indefinite time ... callers of split_huge_page_to_list() usually > > > unlock the page soon after. Actually, I can't find one that doesn't call > > > unlock_page() within a few lines of calling split_huge_page_to_list(). > > > > I didn't check all callers, but it's not guaranteed by the interface and > > it's not hard to imagine a future situation when a page got split on the > > way to IO and kept locked until IO is complete. > > I would say that can't happen. Pages are locked when added to the page > cache and are !Uptodate. You can't put a PTE in a process page table > until it's Uptodate, and once it's Uptodate, the page is unlocked. So > any subsequent locks are transient, and not for the purposes of IO > (writebacks only take the page lock transiently). Documentation/filesystems/locking.rst: Note, if the filesystem needs the page to be locked during writeout, that is ok, too, the page is allowed to be unlocked at any point in time between the calls to set_page_writeback() and end_page_writeback(). I probably misinterpret what is written here. I know very little about writeback path. > > The wake up shouldn't have much overhead as in most cases split going to > > be called on the head page. > > I'm not convinced about that. We go out of our way to not wake up pages > (eg PageWaiters), and we've had some impressively long lists in the past > (which is why we now have the bookmarks). Maybe we should be smarter on when to wake up, I donno. I just notice that with the change we have /potential/ to wait long time on the wrong page to be unlocked. split_huge_page() interface doesn't enforce that the page gets split soon after split is complete. -- Kirill A. Shutemov