Skip to contentSkip to conversation

kho: test: clean up residual memory upon test_kho module unload

PATCH Applied l00580197 3 participants 3 messages Jan 7 – Jan 16

Subsystems (4)
lore
Share & tools
lore

l00580197

author
#0 lore raw

PATCH 1/1 kho: test: clean up residual memory upon test_kho module unload

From: Long Wei <[email protected]>

During the initialization phase, the test_kho module invokes the kho_preserve_folio function, which internally configures bitmaps within kho_mem_track and establishes chunk linked lists in KHO. Upon unloading the test_kho module, it is necessary to clean up these states.

---
 lib/test_kho.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/test_kho.c +5 -1
index 47de56280795..69230da5a056 100644
@@ -339,11 +339,15 @@ module_init(kho_test_init);
 
 static void kho_test_cleanup(void)
 {
+	/* unpreserve and free the data stored in folios */
+	kho_test_unpreserve_data(&kho_test_state);
 	for (int i = 0; i < kho_test_state.nr_folios; i++)
 		folio_put(kho_test_state.folios[i]);
 
 	kvfree(kho_test_state.folios);
-	vfree(kho_test_state.folios_info);
+
+	/* Unpreserve and release the FDT folio */
+	kho_unpreserve_folio(kho_test_state.fdt);
 	folio_put(kho_test_state.fdt);
 }
 
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Wed, Jan 07, 2026 at 10:24:27AM +0800, l00580197 wrote:

From: Long Wei <[email protected]>

During the initialization phase, the test_kho module invokes the kho_preserve_folio function, which internally configures bitmaps within kho_mem_track and establishes chunk linked lists in KHO. Upon unloading the test_kho module, it is necessary to clean up these states.

Quoted 28 lines
---
 lib/test_kho.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/test_kho.c +5 -1
index 47de56280795..69230da5a056 100644
@@ -339,11 +339,15 @@ module_init(kho_test_init);
 
 static void kho_test_cleanup(void)
 {
+	/* unpreserve and free the data stored in folios */
+	kho_test_unpreserve_data(&kho_test_state);
 	for (int i = 0; i < kho_test_state.nr_folios; i++)
 		folio_put(kho_test_state.folios[i]);
 
 	kvfree(kho_test_state.folios);
-	vfree(kho_test_state.folios_info);
+
+	/* Unpreserve and release the FDT folio */
+	kho_unpreserve_folio(kho_test_state.fdt);
 	folio_put(kho_test_state.fdt);
 }
 
Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours,
Mike.
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to l00580197
Quoted 9 lines · On Wed, Jan 07 2026, l00580197 wrote:

From: Long Wei <[email protected]>

During the initialization phase, the test_kho module invokes the kho_preserve_folio function, which internally configures bitmaps within kho_mem_track and establishes chunk linked lists in KHO. Upon unloading the test_kho module, it is necessary to clean up these states.

[...]

Signature · 2 lines
Regards,
Pratyush Yadav