Skip to contentSkip to conversation

nvme/029: reserve hugepages for lager allocations

PATCH Applied Daniel Wagner 3 participants 3 messages Feb 21, 2024 – Feb 22, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme/029: reserve hugepages for lager allocations

The test is issuing larger IO workload. This depends on being able to allocate larger chunks of linear memory. nvme-cli used to use libhugetlb to automatically allocate the HugeTLB pool. Though nvme-cli dropped the dependency on the library, thus the test should try to provision the system accordingly.

---
 tests/nvme/029 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tests/nvme/029 +14 -0
index db6e8b91f707..a4f0cb1402b1 100755
@@ -54,6 +54,7 @@ test() {
 	_setup_nvmet
 
 	local nvmedev
+	local reset_nr_hugepages=false
 
 	_nvmet_target_setup
 
@@ -62,6 +63,15 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
+	# nvme-cli may fail to allocate linear memory for rather large IO buffers.
+	# Increase nr_hugepages to allow nvme-cli to try the linear memory allocation
+	# from HugeTLB pool.
+	if [[  -r /proc/sys/vm/nr_hugepages &&
+		       "$(cat /proc/sys/vm/nr_hugepages)" -eq 0 ]]; then
+		echo 20 > /proc/sys/vm/nr_hugepages
+		reset_nr_hugepages=true
+	fi
+
 	local dev="/dev/${nvmedev}n1"
 	test_user_io "$dev" 1 512 > "$FULL" 2>&1 || echo FAIL
 	test_user_io "$dev" 1 511 > "$FULL" 2>&1 || echo FAIL
@@ -70,6 +80,10 @@ test() {
 	test_user_io "$dev" 511 1023 > "$FULL" 2>&1 || echo FAIL
 	test_user_io "$dev" 511 1025 > "$FULL" 2>&1 || echo FAIL
 
+	if [[ ${reset_nr_hugepages} = true ]]; then
+		echo 0 > /proc/sys/vm/nr_hugepages
+	fi
+
 	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
Signature · 1 line
2.43.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Daniel Wagner

The test is issuing larger IO workload. This depends on being able to allocate larger chunks of linear memory. nvme-cli used to use libhugetlb to automatically allocate the HugeTLB pool. Though nvme-cli dropped the dependency on the library, thus the test should try to provision the system accordingly.

Quoted 6 lines

---

Looks good.

-ck

#2 lore raw
In reply to Daniel Wagner
Quoted 10 lines · Daniel Wagner

The test is issuing larger IO workload. This depends on being able to allocate larger chunks of linear memory. nvme-cli used to use libhugetlb to automatically allocate the HugeTLB pool. Though nvme-cli dropped the dependency on the library, thus the test should try to provision the system accordingly.

Thanks, applied.

I note here that an opportunity is left to improve stability of nvme-cli linear memory allocation in the test case as discussed [1].

[1] https://lore.kernel.org/linux-block/[email protected]/