Skip to content

Commit

Permalink
libswap: fix tst_max_swapfiles() for SWP_SWAPIN_ERROR_NUM
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
  • Loading branch information
akaher authored and metan-ucw committed Sep 16, 2024
1 parent 5d6f7a0 commit 5568500
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libs/swap/libswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5568500

Please sign in to comment.