Re: [PATCH] hugetlb: Add nohugepages parameter to prevent hugepages creation

From: Guilherme G. Piccoli
Date: Tue Oct 15 2019 - 00:50:35 EST


On 14/10/2019 15:25, Mike Kravetz wrote:
> [...]
> I don't know much about early_param(), so I will assume this works as you
> describe. However, a quick grep shows hugepage options for ia64 also with
> early_param.
>

Thanks a lot for the prompt and quite informative reply Mike.
I've checked this IA64 parameter after your mention, and it just sets
the hugepages size, I don't think it'll affect the purpose of this patch.


>> * The return when sysctl handler is prevented to progress due to
>> nohugepages is -EINVAL, but could be changed; I've just followed
>> present code there, but I'm OK changing that if we have suggestions.
>
> It looks like you only have short circuited/prevented nr_hugepages via
> sysfs/sysctl. Theoretically, one could set nr_overcommit_hugepages and
> still allocate hugetlb pages. So, if you REALLY want to shut things down
> you need to stop this as well.
>
> There is already a macro hugepages_supported() that can be set by arch
> specific code. I wonder how difficult it would be to 'overwrite' the
> macro if nohugepages is specified. Perhaps just a level of naming
> indirection. This would use the existing code to prevent all hugetlb usage.
>

Outstanding! It's a much better idea to use hugepages_supported()
infrastructure, it prevents even the creation of hugepages-related sysfs
entries; I've worked a V2 with this modification, and it worked fine,
thanks for the suggestion.


> It seems like there may be some discussion about 'the right' way to
> do kdump. I can't add to that discussion, but if such an option as
> nohugepages is needed, I can help.
>

I think this parameter may be important/useful not only for kdump - it
is a legitimate way of disabling hugepages, something we don't currently
have on kernel. I'll submit a V2, for Ubuntu kdump specially this is
quite helpful!

Cheers,


Guilherme