From 9803cdc16a761bc58847b5484984110565cbbff4 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Wed, 18 Oct 2023 06:31:21 +0300 Subject: [PATCH 1/2] hugepages: add some details on allocation This commit add a little more details on pre-allocation and dynamic allocation of huge pages on the node. It also links to the Linux documentation for further details but gives a quick example on multiple page sizes that is not very obvious from the Linux documentation currently. Signed-off-by: Anthony Nandaa --- .../manage-hugepages/scheduling-hugepages.md | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md b/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md index dd784463810ce..31be02d57fbb1 100644 --- a/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md +++ b/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md @@ -14,15 +14,43 @@ by applications in a Pod. This page describes how users can consume huge pages. ## {{% heading "prerequisites" %}} +Kubernetes nodes must +[pre-allocate huge pages](https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html) +in order for the node to report its huge page capacity. -1. Kubernetes nodes must pre-allocate huge pages in order for the node to report - its huge page capacity. A node can pre-allocate huge pages for multiple - sizes. +A node can pre-allocate huge pages for multiple sizes, for instance, +the following line in `/etc/default/grub` allocates `2*1GiB` of 1 GiB +and `512*2 MiB` of 2 MiB pages: + +``` +GRUB_CMDLINE_LINUX="hugepagesz=1G hugepages=2 hugepagesz=2M hugepages=512" +``` The nodes will automatically discover and report all huge page resources as schedulable resources. +When you describe the node, you should see something similar to the following +in the following in the `Capacity` and `Allocatable` sections: + +``` +Capacity: + cpu: ... + ephemeral-storage: ... + hugepages-1Gi: 2Gi + hugepages-2Mi: 1Gi + memory: ... + pods: ... +Allocatable: + cpu: ... + ephemeral-storage: ... + hugepages-1Gi: 2Gi + hugepages-2Mi: 1Gi + memory: ... + pods: ... +``` +> **NOTE:** For dynamically allocated pages (after boot), the Kubelet +> needs to be restarted for the new allocations to be refrelected. From ca2b3023e7fa60d5c4c2ef4bd69f276e84de5b80 Mon Sep 17 00:00:00 2001 From: Qiming Teng Date: Wed, 18 Oct 2023 13:15:01 +0800 Subject: [PATCH 2/2] Update scheduling-hugepages.md --- .../docs/tasks/manage-hugepages/scheduling-hugepages.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md b/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md index 31be02d57fbb1..2bae4e6c9bff5 100644 --- a/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md +++ b/content/en/docs/tasks/manage-hugepages/scheduling-hugepages.md @@ -29,7 +29,7 @@ GRUB_CMDLINE_LINUX="hugepagesz=1G hugepages=2 hugepagesz=2M hugepages=512" The nodes will automatically discover and report all huge page resources as schedulable resources. -When you describe the node, you should see something similar to the following +When you describe the Node, you should see something similar to the following in the following in the `Capacity` and `Allocatable` sections: ``` @@ -49,8 +49,10 @@ Allocatable: pods: ... ``` -> **NOTE:** For dynamically allocated pages (after boot), the Kubelet -> needs to be restarted for the new allocations to be refrelected. +{{< note >}} +For dynamically allocated pages (after boot), the Kubelet needs to be restarted +for the new allocations to be refrelected. +{{< /note >}}