[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251114032547.bxw4koznsoqlov5d@master>
Date: Fri, 14 Nov 2025 03:25:47 +0000
From: Wei Yang <richard.weiyang@...il.com>
To: Wei Yang <richard.weiyang@...il.com>
Cc: Balbir Singh <balbirs@...dia.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, dri-devel@...ts.freedesktop.org,
Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>, Zi Yan <ziy@...dia.com>,
Joshua Hahn <joshua.hahnjy@...il.com>, Rakie Kim <rakie.kim@...com>,
Byungchul Park <byungchul@...com>,
Gregory Price <gourry@...rry.net>,
Ying Huang <ying.huang@...ux.alibaba.com>,
Alistair Popple <apopple@...dia.com>,
Oscar Salvador <osalvador@...e.de>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
Lyude Paul <lyude@...hat.com>, Danilo Krummrich <dakr@...nel.org>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Ralph Campbell <rcampbell@...dia.com>,
Mika Penttilä <mpenttil@...hat.com>,
Matthew Brost <matthew.brost@...el.com>,
Francois Dugast <francois.dugast@...el.com>
Subject: Re: [PATCH] mm/huge_memory.c: introduce folio_split_unmapped
On Fri, Nov 14, 2025 at 03:21:05AM +0000, Wei Yang wrote:
>On Fri, Nov 14, 2025 at 12:22:28PM +1100, Balbir Singh wrote:
>[...]
>>@@ -4079,6 +4091,36 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
>> return ret;
>> }
>>
>>+/*
>>+ * This function is a helper for splitting folios that have already been unmapped.
>>+ * The use case is that the device or the CPU can refuse to migrate THP pages in
>>+ * the middle of migration, due to allocation issues on either side
>>+ *
>>+ * The high level code is copied from __folio_split, since the pages are anonymous
>>+ * and are already isolated from the LRU, the code has been simplified to not
>>+ * burden __folio_split with unmapped sprinkled into the code.
>>+ *
>>+ * None of the split folios are unlocked
>>+ */
>>+int folio_split_unmapped(struct folio *folio, unsigned int new_order)
>>+{
>>+ int extra_pins, ret = 0;
>>+
>>+ VM_WARN_ON_FOLIO(folio_mapped(folio), folio);
>>+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
>>+ VM_WARN_ON_ONCE_FOLIO(!folio_test_large(folio), folio);
>>+
>
>Compared with original logic, we did check folio_split_supported() and
>check whether new_order is supported for the file system.
>
>Currently folio_split_unmapped() only pass 0 as new_order, which looks good.
>But for a generic helper, it looks reasonable to do the check, IMHO.
>
BTW, I proposed to do the min_order/new_order check in folio_split_supported()
in [1], which may help to make the code looks cleaner.
[1]: lkml.kernel.org/r/20251107072944.zvqvr4kyibyofhuw@...ter
>>+ if (!can_split_folio(folio, 1, &extra_pins))
>>+ return -EAGAIN;
>>+
>>+ local_irq_disable();
>>+ ret = __folio_freeze_and_split_unmapped(folio, new_order, &folio->page, NULL,
>>+ NULL, false, NULL, SPLIT_TYPE_UNIFORM,
>>+ 0, extra_pins);
>>+ local_irq_enable();
>>+ return ret;
>>+}
>>+
>> /*
>> * This function splits a large folio into smaller folios of order @new_order.
>> * @page can point to any page of the large folio to split. The split operation
>
>
>--
>Wei Yang
>Help you, Help me
--
Wei Yang
Help you, Help me
Powered by blists - more mailing lists