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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sun, 17 May 2020 21:16:18 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Hushijie <hushijie3@...wei.com>
Cc:     "will@...nel.org" <will@...nel.org>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Nixiaoming <nixiaoming@...wei.com>,
        "wangxu (AE)" <wangxu72@...wei.com>,
        "Wangkefeng (OS Kernel Lab)" <wangkefeng.wang@...wei.com>,
        yangerkun <yangerkun@...wei.com>,
        "Wangle (RTOS FAE)" <wangle6@...wei.com>,
        "Chengang (L)" <cg.chen@...wei.com>,
        "Chenjie (K)" <chenjie6@...wei.com>,
        "Huangjianhui (Alex)" <alex.huangjianhui@...wei.com>
Subject: Re: [PATCH v5] hugetlbfs: Get unmapped area below TASK_UNMAPPED_BASE
 for hugetlbfs

On 5/16/20 12:47 AM, Hushijie wrote:
>> On 5/14/20 7:31 AM, Shijie Hu wrote:
>>> +	if (mm->get_unmapped_area == arch_get_unmapped_area)
>>> +		return hugetlb_get_unmapped_area_bottomup(file, addr, len,
>>> +				pgoff, flags);
>>> +	return hugetlb_get_unmapped_area_topdown(file, addr, len,
>>> +			pgoff, flags);
>>
>> I like this code using the value of mm->get_unmapped_area to determine
>> which routine to call.  It is used by a few architectures.   However, I
>> noticed that on at least one architecture (powerpc) mm->get_unmapped_area
>> may be assigned to routines other than arch_get_unmapped_area or
>> arch_get_unmapped_area_topdown.  In such a case, we would call the 'new'
>> topdown routine.  I would prefer that we call the bottomup routine in this
>> default case.
>>
>> In reality, this does not impact powerpc as that architecture has it's
>> own hugetlb_get_unmapped_area routine.
>>
> 
> Yes, I also noticed this before, powerpc uses radix__arch_get_unmapped_area*() 
> when CONFIG_PPC_RADIX_MMU opened as 'y' and radix_enabled() returns 
> true. However, powerpc implemented its own hugetlb_get_unmapped_area(). This
> patch actually has no effect on powerpc.
> 
>> Because of this, I suggest we add a comment above this code and switch
>> the if/else order.  For example,
>>
>> +       /*
>> +        * Use mm->get_unmapped_area value as a hint to use topdown routine.
>> +        * If architectures have special needs, they should define their own
>> +        * version of hugetlb_get_unmapped_area.
>> +        */
>> +       if (mm->get_unmapped_area == arch_get_unmapped_area_topdown)
>> +               return hugetlb_get_unmapped_area_topdown(file, addr, len,
>> +                               pgoff, flags);
>> +       return hugetlb_get_unmapped_area_bottomup(file, addr, len,
>> +                       pgoff, flags);
>>
>> Thoughts?
>> -- 
>> Mike Kravetz
>>
> I agree with you. It's clever to switch the if/else order. If there is such
> a case, mm->get_unmapped_area() is neihter arch_get_unmapped_area() nor
> arch_get_unmapped_area_topdown(), it is indeed more appropriate to make the
> bottomup routine as the default behavior.
> 
> May I put this code and comment you show above into patch v6 and add 
> "Signed-off-by: Mike Kravetz <mike.kravetz@...cle.com>" to it?

Feel free to add this code and my Signed-off-by.

I assume this still works for your use case.  Correct?
-- 
Mike Kravetz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ