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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9281E77184 for ; Sat, 21 Dec 2024 14:32:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33FE26B007B; Sat, 21 Dec 2024 09:32:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EFE66B0082; Sat, 21 Dec 2024 09:32:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 144096B0083; Sat, 21 Dec 2024 09:32:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E81DA6B007B for ; Sat, 21 Dec 2024 09:32:23 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 219DD1A0F34 for ; Sat, 21 Dec 2024 14:32:22 +0000 (UTC) X-FDA: 82919204844.19.E1DA3CF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 4C988140014 for ; Sat, 21 Dec 2024 14:31:55 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IDKnGwTQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734791523; a=rsa-sha256; cv=none; b=xBiUWdimn7bgPuZHswYcQYRqseLGXWlSJ7rurdiIDuJFIBYtF9/hHrG3VkiSFve1WGuYfA PUMo1TJY1dyec7dc9E+ZrzkOLzHX3/gYrHpq2SxbNPh+harkCC8oGG9WyW5JreP6ZyqrzC Wj+xcUIwNAgZB7/908ViKPVzUF56EaA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IDKnGwTQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734791523; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=glzaZ4GMQ7kx43PeLKg9UKk4Yr/KeQENxPVtTJNPfys=; b=V4QQHus3zEw9rZ6spBrnD5VULR37x+GTrz25/cuZCboFHDvo+ZFsjW6jrsjkuDB5c4W0gB +pRB1WLBnsMEU2kSESkvgYRpwCui8zTEysNtR9jPC1IcYfWzkWKopMVNZEMBLdZXE8/0q4 6rPH/9zCz4ujPtoHdEEcmEA5FDWLMWQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734791539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=glzaZ4GMQ7kx43PeLKg9UKk4Yr/KeQENxPVtTJNPfys=; b=IDKnGwTQt0z0w/5spaYxsPt8jyciH8SsvzkI8K4h4nI9VHUqVUxD3IpXP3fwMPdbdO3o1c epV7x4LK7OvqpSvSzNxg6KylOcRIKubzsgk7w9rLanSb+iidFTj2zBUU9pdpPnuuruEwJc +kXKdHV12Fgy9H+85JgsI7OjHW7eFmI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-RtveDvBqMAOX9VnEAf8rEg-1; Sat, 21 Dec 2024 09:32:15 -0500 X-MC-Unique: RtveDvBqMAOX9VnEAf8rEg-1 X-Mimecast-MFC-AGG-ID: RtveDvBqMAOX9VnEAf8rEg Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3862b364578so1965385f8f.1 for ; Sat, 21 Dec 2024 06:32:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734791534; x=1735396334; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=glzaZ4GMQ7kx43PeLKg9UKk4Yr/KeQENxPVtTJNPfys=; b=sjmF2eF1v4lvF4/rvK9QYxCiN354BjZyGh12/4rUwomg4PKuwmBJxrtyHjtVrhG7E8 wazygacKdKmm3rRVY5JOCaGQRl+5k8ENtEilg/WVKDbjJX47nM4cZ5mErdCDw1/FMPSe LSH66wa3HFaaq18uN1ncgXnobJjeThjV6hs72uN4xnhSu9s32uiGRf01htNAyap71JxH AHyWK3O6drrBCLmJuQ+9JYP7i22cyxxi6bPv9VGoMGCnNU2mIiveMvZwsam//AxpxVpM i3jM++CAPM4s799fR4JY7UmwwknSBbiuzhDLxH2Zagnp0uYZSlLoVQ71Azzgass0FHsp QNJQ== X-Gm-Message-State: AOJu0YyV3fL5B4SzgZBbJUwQlWGSAWPASIa/4fPZquz+ikLMh4k+Z5gc ZOR8RQmG/xZTC5nScntH9MemVrNJR0Sg3q/u6QxnmVQ58a8pLrKdUaz2PeG2S9gGGoYhuW1mz+i qzuJsLpQadtYiiyW2pzDPRBfEgxnd9N4PRvUBbPLAorOXSdJZ X-Gm-Gg: ASbGnctyUK7f9k4+OoSkfLgQCLfycTKzFH7IdaXbxq/Rm8gTHLbUI9dUpR5vQnw0QCx EDJGiE03xhgqOakCBavzkuXvfRvCS9mGlkVY8ktY4hwb1qt3WLU4CJ0I9AJqiRp8vOkltJMMmjk Y91fG0veqz3chV+XzXNNnGRAXWVFvpXnH7tL47sXhBSU9mrv7y1kI5ZpXn/6JBWWPe/KCfr1egW Fd+qOrSnVsr+h6sWVnuUbUGzhE1NVtoG4/8om7Zp/zu9cer7Y6h66qdAI1u3vOGqTP55DefN1dJ oT8SFPRrf0uRkn8jBRlig8fB109GMkW1ox1LdTVRBUX9PGA4hzZleh5c0w7xmvwUWn6u3DbD6Ym rJ5rHxTgy X-Received: by 2002:a5d:5d09:0:b0:386:4570:ee3d with SMTP id ffacd0b85a97d-38a22a4c983mr5810363f8f.24.1734791534472; Sat, 21 Dec 2024 06:32:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCMDZk/93Kg60YQwF51fyaC60CAIZCXyZ7BqG62+zVeO+S8Cz54v+G8U7DmDs50F+Vm3RtSg== X-Received: by 2002:a5d:5d09:0:b0:386:4570:ee3d with SMTP id ffacd0b85a97d-38a22a4c983mr5810339f8f.24.1734791534022; Sat, 21 Dec 2024 06:32:14 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:d000:4622:73e7:6184:8f0d? (p200300cbc70ed000462273e761848f0d.dip0.t-ipconnect.de. [2003:cb:c70e:d000:4622:73e7:6184:8f0d]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8ace0esm6517219f8f.106.2024.12.21.06.32.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Dec 2024 06:32:12 -0800 (PST) Message-ID: <433fb64d-80e1-4d96-904e-10b51e40898d@redhat.com> Date: Sat, 21 Dec 2024 15:32:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] replace free hugepage folios after migration To: Ge Yang , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, 21cnbao@gmail.com, baolin.wang@linux.alibaba.com, muchun.song@linux.dev, liuzixing@hygon.cn, Oscar Salvador , Michal Hocko References: <1734503588-16254-1-git-send-email-yangge1116@126.com> <0b41cc6b-5c93-408f-801f-edd9793cb979@redhat.com> <1241b567-88b6-462c-9088-8f72a45788b7@126.com> <333e584c-2688-4a3f-bc1f-2e84d5215005@126.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwM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fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <333e584c-2688-4a3f-bc1f-2e84d5215005@126.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eD1z_VFsFpXeF0bSaLcGmnoM3vp0bp09umeriOck9kc_1734791534 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4C988140014 X-Stat-Signature: w7rt11emetua4c891pdnezqp3ajkk7t3 X-HE-Tag: 1734791515-449332 X-HE-Meta: U2FsdGVkX18zwfLhuqRUH6qaYmEH5JtLetM2cPEgkQVfOzPYKPAMCm1aluxAUBYoxEgqCgWGTnijjsDp61ck1bqn93gFVz7pEivn4px3H7hiLi1lRhT48fzdr5//VIXy1xBEsvU1C0L5pMDdzmN6vJqyAfhvaZQyX9vdrChXoyYOxm4tCTKXM/yE+SkuTREoPCpM1AAnyt2xOhzUBWLi+PCnMkThSf6fLwZh6Ke0Dnf1Jjx+WeKmnlC0M0AS6jYkRvqEHnEX5sttoDxKbLIP4lcGiQN1Lk9mCvdX6BlXeCXwpjBZqMjPCOFqbdRIoLSKs/KZ0tw9cRm0oMgeV287gVg/06McBVZgK6ztN3Q3sCDLpaI7MJV6zMT29yGT5iL9PWqYtEtsIzM0xGb1zdRrgJG3VRKGVvlhMzBqSwDmAwUQzYJl2HLxgiBgbAr89VI8paI5RxhhtrIMHIigTFZJUBSnLnN+Z3qyV1pL4yIgn19JQN5bE5+ZwXkPUQqrHsBmJjoKWFirVzCQzEE8O9sRHxQI8wzHFLNLRWXPeixuNMl/1B7P3Txi4LJzEQik7K12FCVYp07Ovq369gWQsqI/Z7xXiAESmuQ5W10887vxNS7+dITWdKfWswoYX370BIUZCiFKwybH0iNUbwl6Ov+2HlaP76z0eGMjqGltY+BJX8GuZEn4oPL1C8wdzUjmvHq6wn32vnth6dxE0wUa2W+bbYPyNIQUuaz5Rfw/wK2qHVto9S//9Hw8q79C7Mh5e+Sbb80TBMggKUy4o+s72OVQYjm/zHRRAiL1qP4+H3ExJTdHPQv/1zJ9L/Vhqjx5/3AgKVjDkxurU7xLHJcSvFWzwP/QVyj9v619lkuxAmjVMw2TPUwUGlIGcR67CA9xWROMgVqoSV+04dq0SBT7O94wuKbShM3A5zhruWGAD+M/Yollw9ClcIm41sVypsyY1an+bzAK+0V9mXGr8XRnDHR YpnyRIdF 7iD+PinyquKqEuc6QxTvp0yMoo11pJDgIzw5SriJLQDJO+j0MRvuuTRpbK5kLy856PpTPOLXzlDqGizEGe2GR5+8eWerN7Rz+bmQxFBoDJpTHuyI3ucL4Wm0g5/XQjSnlNbc/CrFmvFGftWl3cEaMvata2sxjQmmAxy/W0wwxR0l8Q1THz9PtBf5rPB58LXln7vBnXroDwOR/PoXviv0Pz6w+X/CC8kEBwP3aTgYZHiX6OwBWLlB0Sto3Anpp5dN0S75j6Jba61wJDJWu1YWDBdYxbHngzbXOjE9TICdbPTyMVY1qway6qlXZj/HdgjvWwdxlibNG1ivoFp4ew07Fhbn+G9fO2qQztvG4K3fXIqW1mTTgEAb7SMdVRcBb81sjfj6utaqHF3ycacaulTsoHN+ePXYZwQi86E0xDxfWjcNajh9GBtzIp5bDqHlJmeQLm4wAf0Mdxlsh5Bt1z2iRkzLyi5rwoBcOXw72 X-Bogosity: Ham, tests=bogofilter, spamicity=0.015014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 21.12.24 13:04, Ge Yang wrote: > > > 在 2024/12/21 0:30, David Hildenbrand 写道: >> On 20.12.24 09:56, Ge Yang wrote: >>> >>> >>> 在 2024/12/20 0:40, David Hildenbrand 写道: >>>> On 18.12.24 07:33, yangge1116@126.com wrote: >>>>> From: yangge >>>> >>>> CCing Oscar, who worked on migrating these pages during memory offlining >>>> and alloc_contig_range(). >>>> >>>>> >>>>> My machine has 4 NUMA nodes, each equipped with 32GB of memory. I >>>>> have configured each NUMA node with 16GB of CMA and 16GB of in-use >>>>> hugetlb pages. The allocation of contiguous memory via the >>>>> cma_alloc() function can fail probabilistically. >>>>> >>>>> The cma_alloc() function may fail if it sees an in-use hugetlb page >>>>> within the allocation range, even if that page has already been >>>>> migrated. When in-use hugetlb pages are migrated, they may simply >>>>> be released back into the free hugepage pool instead of being >>>>> returned to the buddy system. This can cause the >>>>> test_pages_isolated() function check to fail, ultimately leading >>>>> to the failure of the cma_alloc() function: >>>>> cma_alloc() >>>>>       __alloc_contig_migrate_range() // migrate in-use hugepage >>>>>       test_pages_isolated() >>>>>           __test_page_isolated_in_pageblock() >>>>>                PageBuddy(page) // check if the page is in buddy >>>> >>>> I thought this would be working as expected, at least we tested it with >>>> alloc_contig_range / virtio-mem a while ago. >>>> >>>> On the memory_offlining path, we migrate hugetlb folios, but also >>>> dissolve any remaining free folios even if it means that we will going >>>> below the requested number of hugetlb pages in our pool. >>>> >>>> During alloc_contig_range(), we only migrate them, to then free them up >>>> after migration. >>>> >>>> Under which circumstances doe sit apply that "they may simply be >>>> released back into the free hugepage pool instead of being returned to >>>> the buddy system"? >>>> >>> >>> After migration, in-use hugetlb pages are only released back to the >>> hugetlb pool and are not returned to the buddy system. >> >> We had >> >> commit ae37c7ff79f1f030e28ec76c46ee032f8fd07607 >> Author: Oscar Salvador >> Date:   Tue May 4 18:35:29 2021 -0700 >> >>     mm: make alloc_contig_range handle in-use hugetlb pages >>     alloc_contig_range() will fail if it finds a HugeTLB page within the >>     range, without a chance to handle them.  Since HugeTLB pages can be >>     migrated as any LRU or Movable page, it does not make sense to bail >> out >>     without trying.  Enable the interface to recognize in-use HugeTLB >> pages so >>     we can migrate them, and have much better chances to succeed the call. >> >> >> And I am trying to figure out if it never worked correctly, or if >> something changed that broke it. >> >> >> In start_isolate_page_range()->isolate_migratepages_block(), we do the >> >>     ret = isolate_or_dissolve_huge_page(page, &cc->migratepages); >> >> to add these folios to the cc->migratepages list. >> >> In __alloc_contig_migrate_range(), we migrate the pages using >> migrate_pages(). >> >> >> After that, the src hugetlb folios should still be isolated? > Yes. > > But I'm >> getting >> confused when these pages get un-silated and putback to hugetlb/freed. >> > If the migration is successful, call folio_putback_active_hugetlb to > release the src hugetlb folios back to the free hugetlb pool. > > trace: > unmap_and_move_huge_page > folio_putback_active_hugetlb > folio_put > free_huge_folio > > alloc_contig_range_noprof > __alloc_contig_migrate_range > if (test_pages_isolated()) //to determine if hugetlb pages in buddy > isolate_freepages_range //grab isolated pages from freelists. > else > undo_isolate_page_range //undo isolate Ah, now I remember, thanks. So when we free an ordinary page, we put it onto the buddy isolate list, from where we can grab it later and nobody can allocate it in the meantime. In case of hugetlb, we simply free it back to hugetlb, from where it can likely even get allocated immediately again. I think that can actually happen in your proposal: the now-free page will get reallocated, for example for migrating the next folio. Or some concurrent system activity can simply allocate the now-free folio. Or am I missing something that prevents these now-free hugetlb folios from getting re-allocated after migration succeeded? Conceptually, I think we would want migration code in the case of alloc_contig_range() to allocate a new folio from the buddy, and to free the old one back to the buddy immediately, without ever allowing re-allocation of it. What needs to be handled is detecting that (a) we want to allocate a fresh hugetlb folio as migration target (b) if migration succeeds, we have to free the hugetlb folio back to the buddy (c) if migation fails, we have to free the allocated hugetlb foliio back to the buddy We could provide a custom alloc_migration_target that we pass to migrate_page to allocate a fresh hugetlb folio to handle (a). Using the put_new_folio callback we could handle (c). (b) would need some thought. Maybe we can also just mark the source folio as we isolate it, and enlighten migration+freeing code to handle it automatically? Hoping to get some feedback from hugetlb maintainers. -- Cheers, David / dhildenb