From 556850000a238f5f6fb5d148b105df5032f76648 Mon Sep 17 00:00:00 2001 From: Ajay Kaher Date: Tue, 27 Aug 2024 11:45:28 +0530 Subject: [PATCH] libswap: fix tst_max_swapfiles() for SWP_SWAPIN_ERROR_NUM swapon03 fails because it doesn't includes SWP_SWAPIN_ERROR_NUM to calculate MAX_SWAPFILES. However linux v5.19-v6.1.y includes, as: #define MAX_SWAPFILES \ ((1 << MAX_SWAPFILES_SHIFT) - SWP_DEVICE_NUM - \ SWP_MIGRATION_NUM - SWP_HWPOISON_NUM - \ SWP_PTE_MARKER_NUM - SWP_SWAPIN_ERROR_NUM) Including SWP_SWAPIN_ERROR_NUM to calculate MAX_SWAPFILES, if Linux version is >= v5.19 and < v6.2. Signed-off-by: Ajay Kaher Reviewed-by: Cyril Hrubis --- libs/swap/libswap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/swap/libswap.c b/libs/swap/libswap.c index 5edc848a38f..63a995f4e31 100644 --- a/libs/swap/libswap.c +++ b/libs/swap/libswap.c @@ -244,7 +244,8 @@ bool is_swap_supported(const char *filename) int tst_max_swapfiles(void) { unsigned int swp_migration_num = 0, swp_hwpoison_num = 0, - swp_device_num = 0, swp_pte_marker_num = 0; + swp_device_num = 0, swp_pte_marker_num = 0, + swp_swapin_error_num = 0; struct tst_kconfig_var migration = TST_KCONFIG_INIT("CONFIG_MIGRATION"); struct tst_kconfig_var memory = TST_KCONFIG_INIT("CONFIG_MEMORY_FAILURE"); struct tst_kconfig_var device = TST_KCONFIG_INIT("CONFIG_DEVICE_PRIVATE"); @@ -295,8 +296,11 @@ int tst_max_swapfiles(void) swp_pte_marker_num = 1; } + if ((tst_kvercmp(5, 19, 0) >= 0) && (tst_kvercmp(6, 2, 0) < 0)) + swp_swapin_error_num = 1; + return DEFAULT_MAX_SWAPFILE - swp_migration_num - swp_hwpoison_num - - swp_device_num - swp_pte_marker_num; + - swp_device_num - swp_pte_marker_num - swp_swapin_error_num; } int tst_count_swaps(void)