bottlerocket icon indicating copy to clipboard operation
bottlerocket copied to clipboard

kernel-parameters settings order is not preserved

Open otterley opened this issue 1 year ago • 3 comments

Bottlerocket isn't preserving the order of kernel parameters provided to it via settings.boot.kernel-parameters.

For example, if I pass the following list of kernel parameters:

[settings.boot.kernel-parameters]
"hugepagesz" = [
 "1G"
]
"hugepages" = [
 "10"
]

What should result on the kernel command line is:

hugepagesz="1G" hugepages="10"

However, what can happen is

hugepages="10" hugepagesz="1G"

In Linux, the ordering of command line arguments can be important, and this is particularly true for Huge TLB Page configuration. The two sets of arguments above do not have the same effect: the first argument list specifies that 10 huge pages of size 1GB should be allocated; the second argument list specifies that 10 huge pages of the default size should be allocated (and the second argument is ignored). While one could argue that the order shouldn't matter, it unfortunately does matter.

So, Bottlerocket should ensure the arguments are appended to the kernel command line in the order presented in the settings. If this isn't possible with TOML, some sort of ordering hint should be possible, or perhaps these need to be an array instead of a keyed argument list.

otterley avatar Dec 07 '23 19:12 otterley

In relevant part from the documentation (emphasis mine):

hugepages Specify the number of huge pages to preallocate. This typically follows a valid hugepagesz or default_hugepagesz parameter. However, if hugepages is the first or only hugetlb command line parameter it implicitly specifies the number of huge pages of default size to allocate.

otterley avatar Dec 07 '23 19:12 otterley

Hi @otterley,

~Can you try specifying the parameters like so:~

[settings.boot.kernel-parameters]
"hugepagesz" = [
 "1G",
 "10"
]

~That should help preserve the order.~

EDIT: It's not a duplicate key issue.

etungsten avatar Dec 07 '23 19:12 etungsten

Thanks for opening the issue. We'll have to take a closer look into how to go about fixing this.

etungsten avatar Dec 07 '23 20:12 etungsten