[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zqb0+L/21/AKUagd@MiWiFi-R3L-srv>
Date: Mon, 29 Jul 2024 09:48:40 +0800
From: Baoquan He <bhe@...hat.com>
To: Barry Song <21cnbao@...il.com>, Hailong Liu <hailong.liu@...o.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Uladzislau Rezki <urezki@...il.com>,
Christoph Hellwig <hch@...radead.org>,
Lorenzo Stoakes <lstoakes@...il.com>,
Vlastimil Babka <vbabka@...e.cz>, Michal Hocko <mhocko@...e.com>,
Matthew Wilcox <willy@...radead.org>,
Tangquan Zheng <zhengtangquan@...o.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2] mm/vmalloc: fix incorrect
__vmap_pages_range_noflush() if vm_area_alloc_pages() from high order
fallback to order0
Hi Barry,
On 07/26/24 at 03:53pm, Barry Song wrote:
> On Fri, Jul 26, 2024 at 2:31 PM Baoquan He <bhe@...hat.com> wrote:
......
> > mm/mm_init.c <<alloc_large_system_hash>>
> > table = vmalloc_huge(size, gfp_flags);
> > net/ipv4/inet_hashtables.c <<inet_pernet_hashinfo_alloc>>
> > new_hashinfo->ehash = vmalloc_huge(ehash_entries * sizeof(struct inet_ehash_bucket),
> > net/ipv4/udp.c <<udp_pernet_table_alloc>>
> > udptable->hash = vmalloc_huge(hash_entries * 2 * sizeof(struct udp_hslot)
> >
> > Maybe we should add code comment or document to notice people that the
> > contiguous physical pages are not guaranteed for vmalloc_huge() if you
> > use it after boot.
>
> Currently, the issue goes beyond just 'contiguous physical pages are
> not guaranteed.'
> The problem includes the likelihood of failure when trying to allocate
> 2MB of contiguous
> memory. That's why I suggest we allow fallback to order-0 for
> non-nofail allocations with
> your proposed changes.
I missed this part of your comment, I agree with you. I think it's doable
with below draft patch combined with my earlier draft change.
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 260897b21b11..9ae85342d337 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3581,11 +3581,11 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
else
page = alloc_pages_node_noprof(nid, alloc_gfp, order);
if (unlikely(!page)) {
- if (!nofail)
+ if (!nofail && !order)
break;
/* fall back to the zero order allocations */
- alloc_gfp |= __GFP_NOFAIL;
+ alloc_gfp = gfp;
order = 0;
continue;
}
Hi Hailong,
Please feel free to collect them to post formal patch, maybe two
patches, one is to allow non-nofail to fallback to order-0 in
vm_area_alloc_pages(), the other is passing out the fallbacked
page_order to vmap_pages_range() if it's OK.
Thanks
Baoquan
Powered by blists - more mailing lists