[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7691fac7-f569-4fc2-9d0e-f7dad4139261@huawei.com>
Date: Tue, 10 Jun 2025 17:18:10 +0800
From: mawupeng <mawupeng1@...wei.com>
To: <hannes@...xchg.org>
CC: <mawupeng1@...wei.com>, <akpm@...ux-foundation.org>, <vbabka@...e.cz>,
<surenb@...gle.com>, <jackmanb@...gle.com>, <ziy@...dia.com>,
<wangkefeng.wang@...wei.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] mm: Drain PCP during direct reclaim
On 2025/6/6 19:19, Johannes Weiner wrote:
> On Fri, Jun 06, 2025 at 02:59:30PM +0800, Wupeng Ma wrote:
>> Memory retained in Per-CPU Pages (PCP) caches can prevent hugepage
>> allocations from succeeding despite sufficient free system memory. This
>> occurs because:
>> 1. Hugepage allocations don't actively trigger PCP draining
>> 2. Direct reclaim path fails to trigger drain_all_pages() when:
>> a) All zone pages are free/hugetlb (!did_some_progress)
>> b) Compaction skips due to costly order watermarks (COMPACT_SKIPPED)
>
> This doesn't sound quite right. Direct reclaim skips when compaction
> is suitable. Compaction says COMPACT_SKIPPED when it *isn't* suitable.
>
> So if direct reclaim didn't drain, presumably compaction ran but
> returned COMPLETE or PARTIAL_SKIPPED because the freelist checks in
> __compact_finished() never succeed due to the pcp?
Yes, compaction do run, however since all pages in this movable node
are free or in pcp. there is no way for compaction to reclaim a page.
>
>> @@ -4137,28 +4137,22 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
>> {
>> struct page *page = NULL;
>> unsigned long pflags;
>> - bool drained = false;
>>
>> psi_memstall_enter(&pflags);
>> *did_some_progress = __perform_reclaim(gfp_mask, order, ac);
>> - if (unlikely(!(*did_some_progress)))
>> - goto out;
>> -
>> -retry:
>> - page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac);
>> + if (likely(*did_some_progress))
>> + page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac);
>>
>> /*
>> * If an allocation failed after direct reclaim, it could be because
>> * pages are pinned on the per-cpu lists or in high alloc reserves.
>> * Shrink them and try again
>> */
>> - if (!page && !drained) {
>> + if (!page) {
>> unreserve_highatomic_pageblock(ac, false);
>> drain_all_pages(NULL);
>> - drained = true;
>> - goto retry;
>> + page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac);
>
> This seems like the wrong place to fix the issue.
>
> Kcompactd has a drain_all_pages() call. Move that to compact_zone(),
> so that it also applies to the try_to_compact_pages() path?
Since there is no pages isolated during isolate_migratepages(), it is
strange to drain_pcp here?
Powered by blists - more mailing lists