Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1921466rdb; Mon, 9 Oct 2023 07:11:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgv3ngolxHdoTops/gmlu3QVHQw6wC9Qd/eBjetpgrMbIXPCAPLIGUbhee+g27DKCjG3IJ X-Received: by 2002:a05:6a00:248a:b0:68e:29a6:e247 with SMTP id c10-20020a056a00248a00b0068e29a6e247mr14688090pfv.10.1696860661611; Mon, 09 Oct 2023 07:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696860661; cv=none; d=google.com; s=arc-20160816; b=CTRd8Akmk/aYq2gPmSqdXmXKe+Az7yYBjOT1QHIede2agBBY0vYg7jE18ut7HIuawc i4YbXHthgvkvf4z/HP+WpS9yQCD8OgZ1zlyZXmSizcCdP4gZ305l7B+2ri2oO6ej30CN IjKZikd2UhQ2Y7jz6LHiZwQ1WdCcsYbISp1a1CgNRuVKDTlnG9tdo1hTLxuAssEgRkCU Nlolk899Kf8WEcP3BZS5JdRzL5AS3/dcZgSneD08Ze3USKzwDahAkopOMCI/kv6KR8kM GqvDxQZ2IDEuM1W9wjj2SdJ4PuTjYm8jqboJKHQOxYZQ8vZz7xGON69mFCS/JHVSa9zw O08w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=79Nu6aDnUNOp0xKmkAqXyUEewz7aA+1Dj0+dHr/xEbY=; fh=WOkSvEsC7aF3fXFrBKvWAK82oDJ2sLIVI1iaooVXMKE=; b=gNa29F/lr23bElzoJ1PwE6KvhAwZ95L2O2ZvBNI1ITOu1kWcwljC92Z46eAXmKJBef iQGvSMwu+GPfRPkF012gk624A8JucwcMoiFuH4d+YnuTmcvBs51LZJQjbYW+yC3YOlWM V+sHAJ1N/U1Xa0zxVVCMpR0zJ05ZedRdwgrjLuN6DBItJyZ+OhozmkrNlhws/TMYC9ox eiSIP3E7nlF2MMxRzeSwJPptDgTFmIydR6jdxbJ31lFpJJWSRMJPTDFA4JXw3LUTNvDS 5WT/Z3oQSU+q3PS+RO66tqNlMoaJt8Sy5dr2IEvl4zACy5OJCrKJNNDaLr+L68/LFShb q4fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c5-20020a6566c5000000b005859e224617si10012264pgw.818.2023.10.09.07.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 07:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B87B380F7F21; Mon, 9 Oct 2023 07:10:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343878AbjJIOKv (ORCPT + 99 others); Mon, 9 Oct 2023 10:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234549AbjJIOKu (ORCPT ); Mon, 9 Oct 2023 10:10:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7204691 for ; Mon, 9 Oct 2023 07:10:48 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A3F201FB; Mon, 9 Oct 2023 07:11:28 -0700 (PDT) Received: from [10.57.66.97] (unknown [10.57.66.97]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B917F3F5A1; Mon, 9 Oct 2023 07:10:45 -0700 (PDT) Message-ID: <13347394-fc63-44b2-9fa0-455f56d9b19d@arm.com> Date: Mon, 9 Oct 2023 15:10:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/4] Enable >0 order folio memory compaction Content-Language: en-GB To: Zi Yan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , "Matthew Wilcox (Oracle)" , David Hildenbrand , "Yin, Fengwei" , Yu Zhao , Vlastimil Babka , Johannes Weiner , Baolin Wang , Kemeng Shi , Mel Gorman , Rohan Puri , Mcgrof Chamberlain , Adam Manzanares , John Hubbard References: <20230912162815.440749-1-zi.yan@sent.com> <5caf5aee-9142-46f6-9a04-5b6e36880b21@arm.com> <3430F048-0B75-4D2F-A097-753E8B1866B2@nvidia.com> From: Ryan Roberts In-Reply-To: <3430F048-0B75-4D2F-A097-753E8B1866B2@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 07:10:58 -0700 (PDT) X-Spam-Level: ** On 09/10/2023 14:24, Zi Yan wrote: > On 2 Oct 2023, at 8:32, Ryan Roberts wrote: > >> Hi Zi, >> >> On 12/09/2023 17:28, Zi Yan wrote: >>> From: Zi Yan >>> >>> Hi all, >>> >>> This patchset enables >0 order folio memory compaction, which is one of >>> the prerequisitions for large folio support[1]. It is on top of >>> mm-everything-2023-09-11-22-56. >> >> I've taken a quick look at these and realize I'm not well equipped to provide >> much in the way of meaningful review comments; All I can say is thanks for >> putting this together, and yes, I think it will become even more important for >> my work on anonymous large folios. >> >> >>> >>> Overview >>> === >>> >>> To support >0 order folio compaction, the patchset changes how free pages used >>> for migration are kept during compaction. Free pages used to be split into >>> order-0 pages that are post allocation processed (i.e., PageBuddy flag cleared, >>> page order stored in page->private is zeroed, and page reference is set to 1). >>> Now all free pages are kept in a MAX_ORDER+1 array of page lists based >>> on their order without post allocation process. When migrate_pages() asks for >>> a new page, one of the free pages, based on the requested page order, is >>> then processed and given out. >>> >>> >>> Optimizations >>> === >>> >>> 1. Free page split is added to increase migration success rate in case >>> a source page does not have a matched free page in the free page lists. >>> Free page merge is possible but not implemented, since existing >>> PFN-based buddy page merge algorithm requires the identification of >>> buddy pages, but free pages kept for memory compaction cannot have >>> PageBuddy set to avoid confusing other PFN scanners. >>> >>> 2. Sort source pages in ascending order before migration is added to >>> reduce free page split. Otherwise, high order free pages might be >>> prematurely split, causing undesired high order folio migration failures. >> >> Not knowing much about how compaction actually works, naively I would imagine >> that if you are just trying to free up a known amount of contiguous physical >> space, then working through the pages in PFN order is more likely to yield the >> result quicker? Unless all of the pages in the set must be successfully migrated >> in order to free up the required amount of space... > > During compaction, pages are not freed, since that is the job of page reclaim. Sorry yes - my fault for using sloppy language. When I said "free up a known amount of contiguous physical space", I really meant "move pages in order to recover an amount of contiguous physical space". But I still think the rest of what I said applies; wouldn't you be more likely to reach your goal quicker if you sort by PFN? > The goal of compaction is to get a high order free page without freeing existing > pages to avoid potential high cost IO operations. If compaction does not work, > page reclaim would free pages to get us there (and potentially another follow-up > compaction). So either pages are migrated or stay where they are during compaction. > > BTW compaction works by scanning in use pages from lower PFN to higher PFN, > and free pages from higher PFN to lower PFN until two scanners meet in the middle. > > -- > Best Regards, > Yan, Zi