lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 15 Sep 2021 15:38:33 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     zhenguo yao <yaozhenguo1@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     corbet@....net, yaozhenguo@...com,
        Matthew Wilcox <willy@...radead.org>,
        linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
        Linux Memory Management List <linux-mm@...ck.org>
Subject: Re: [PATCH v4] hugetlbfs: Extend the definition of hugepages
 parameter to support node allocation

On 9/15/21 3:03 PM, Mike Kravetz wrote:
> On 9/15/21 6:11 AM, zhenguo yao wrote:
>> Andrew Morton <akpm@...ux-foundation.org> 于2021年9月15日周三 上午11:50写道:
>>>
>>> On Thu,  9 Sep 2021 22:16:55 +0800 yaozhenguo <yaozhenguo1@...il.com> wrote:
>>>
>>>> +static void __init hugetlb_hstate_alloc_pages_onenode(struct hstate *h, int nid)
>>>> +{
>>>> +     unsigned long i;
>>>> +     char buf[32];
>>>> +
>>>> +     for (i = 0; i < h->max_huge_pages_node[nid]; ++i) {
>>>> +             if (hstate_is_gigantic(h)) {
>>>> +                     struct huge_bootmem_page *m;
>>>> +                     void *addr;
>>>> +
>>>> +                     addr = memblock_alloc_try_nid_raw(
>>>> +                                     huge_page_size(h), huge_page_size(h),
>>>> +                                     0, MEMBLOCK_ALLOC_ACCESSIBLE, nid);
>>>> +                     if (!addr)
>>>> +                             break;
>>>> +                     m = addr;
>>>> +                     BUG_ON(!IS_ALIGNED(virt_to_phys(m), huge_page_size(h)));
>>>
>>> We try very hard to avoid adding BUG calls.  Is there any way in which
>>> this code can emit a WARNing then permit the kernel to keep operating?
>>>
>> Maybe we can rewrite it as below:
>>                         if (WARN(!IS_ALIGNED(virt_to_phys(m),
>> huge_page_size(h)),
>>                                 "HugeTLB: page addr:%p is not aligned\n", m))
>>                                 break;
>> @Mike,  Do you think it's OK?
> 
> Sorry, I have not yet reviewed the latest version of this patch.
> Quick thought on this question.
> 
> The required alignment passed to memblock_alloc_try_nid_raw() is
> huge_page_size(h).  Therefore, we know the virtual address m is
> huge_page_size(h) aligned.  The BUG is just checking to make sure
> the physical address associated with the virtual address is aligned
> the same.  I really do not see how this could not be the case.
> In fact, the memblock allocator finds a physical address with the
> required alignment and then returns phys_to_virt(alloc).
> Someone please correct me if I am wrong.  Otherwise, we can drop
> the BUG.
> Adding Mike Rapport on Cc:
> 
> This allocation code and the associated BUG was copied from
> __alloc_bootmem_huge_page().  The BUG was added 12 years ago before
> the memblock allocator existed and we were using the bootmem allocator.
> If there is no need for a BUG in hugetlb_hstate_alloc_pages_onenode,
> there is no need for one in __alloc_bootmem_huge_page.

One additional thought.

Architectures can provide their own version of alloc_bootmem_huge_page.
powerpc is the only architecture doing so today.  If an architecture
does provide their own version of alloc_bootmem_huge_page, I do not
think we should/can use hugetlb_hstate_alloc_pages_onenode to allocate
node specific gigantic huge pages.

I think we need to disable this feature for such architectures,
-OR-
provide some method to do architecture specific node allocations of
gigantic pages.
-- 
Mike Kravetz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ