1GB pages can only be allocated at boot time using hugepages= and not freed afterwards

2018-6-27 9:12:38

https://stackoverflow.com/questions/26385554/error-setting-nr-hugepages-via-sysfs


~ # echo 1 > /sys/devices/system/node/node0/hugepages/hugepages-1048576kB/nr_hugepages
sh: write error: Invalid argument

parameter in https://www.kernel.org/doc/Documentation/kernel-parameters.txt
says that "1GB pages can only be allocated at boot time using hugepages= and not freed afterwards"
I think this is why I can't decrease number of pages.

Also, the code in mm/hugetlb.c doesn't allow this operation:

#if defined(CONFIG_CMA) && defined(CONFIG_X86_64)
...
static inline bool gigantic_page_supported(void) { return true; }
#else
static inline bool gigantic_page_supported(void) { return false; }
...
#endif
...
static int hugetlb_sysctl_handler_common(...)
{
  ...
  if (write && hstate_is_gigantic(h) && !gigantic_page_supported())
          return -EINVAL;
  ...
}

So, unless CONFIG_CMA is defined (and in the default kernel configuration shipped with Fedora 20
this option is disabled), the kernel will always return EINVAL.

原文地址:https://www.cnblogs.com/mull/p/9232532.html