| diff --git a/kernel-module-source/kernel-open/conftest.sh b/kernel-module-source/kernel-open/conftest.sh |
| index 4e3e7593..7f1870c3 100755 |
| --- a/kernel-module-source/kernel-open/conftest.sh |
| +++ b/kernel-module-source/kernel-open/conftest.sh |
| @@ -6356,6 +6509,22 @@ compile_test() { |
| compile_check_conftest "$CODE" "NV_MMU_INTERVAL_NOTIFIER" "" "types" |
| ;; |
| |
| + folio_test_swapcache) |
| + # |
| + # Determine if the folio_test_swapcache() function is present. |
| + # |
| + # folio_test_swapcache() was exported by commit d389a4a811551 ("mm: |
| + # Add folio flag manipulation functions") in v5.16. |
| + # |
| + CODE=" |
| + #include <linux/page-flags.h> |
| + void conftest_folio_test_swapcache(void) { |
| + folio_test_swapcache(); |
| + }" |
| + |
| + compile_check_conftest "$CODE" "NV_FOLIO_TEST_SWAPCACHE_PRESENT" "" "functions" |
| + ;; |
| + |
| # When adding a new conftest entry, please use the correct format for |
| # specifying the relevant upstream Linux kernel commit. |
| # |
| diff --git a/kernel-module-source/kernel-open/nvidia-uvm/uvm_hmm.c b/kernel-module-source/kernel-open/nvidia-uvm/uvm_hmm.c |
| index 0d82314a..5ae31382 100644 |
| --- a/kernel-module-source/kernel-open/nvidia-uvm/uvm_hmm.c |
| +++ b/kernel-module-source/kernel-open/nvidia-uvm/uvm_hmm.c |
| @@ -71,6 +71,24 @@ module_param(uvm_disable_hmm, bool, 0444); |
| #include "uvm_va_policy.h" |
| #include "uvm_tools.h" |
| |
| +// The function nv_PageSwapCache() wraps the check for page swap cache flag in |
| +// order to support a wide variety of kernel versions. |
| +// The function PageSwapCache() is removed after 32f51ead3d77 ("mm: remove |
| +// PageSwapCache") in v6.12-rc1. |
| +// The function folio_test_swapcache() was added in Linux 5.16 (d389a4a811551 |
| +// "mm: Add folio flag manipulation functions") |
| +// Systems with HMM patches backported to 5.14 are possible, but those systems |
| +// do not include folio_test_swapcache() |
| +// TODO: Bug 4050579: Remove this when migration of swap cached pages is updated |
| +static __always_inline bool nv_PageSwapCache(struct page *page) |
| +{ |
| +#if defined(NV_FOLIO_TEST_SWAPCACHE_PRESENT) |
| + return folio_test_swapcache(page_folio(page)); |
| +#else |
| + return PageSwapCache(page); |
| +#endif |
| +} |
| + |
| static NV_STATUS gpu_chunk_add(uvm_va_block_t *va_block, |
| uvm_page_index_t page_index, |
| struct page *page); |
| @@ -2554,7 +2572,7 @@ static NV_STATUS dmamap_src_sysmem_pages(uvm_va_block_t *va_block, |
| continue; |
| } |
| |
| - if (PageSwapCache(src_page)) { |
| + if (nv_PageSwapCache(src_page)) { |
| // TODO: Bug 4050579: Remove this when swap cached pages can be |
| // migrated. |
| if (service_context) { |
| diff --git a/kernel-module-source/kernel-open/nvidia-uvm/nvidia-uvm.Kbuild b/kernel-module-source/kernel-open/nvidia-uvm/nvidia-uvm.Kbuild |
| index 73083929..a847e9eb 100644 |
| --- a/kernel-module-source/kernel-open/nvidia-uvm/nvidia-uvm.Kbuild |
| +++ b/kernel-module-source/kernel-open/nvidia-uvm/nvidia-uvm.Kbuild |
| @@ -81,6 +81,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc |
| NV_CONFTEST_FUNCTION_COMPILE_TESTS += mmgrab |
| NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_sva_bind_device_has_drvdata_arg |
| NV_CONFTEST_FUNCTION_COMPILE_TESTS += vm_fault_to_errno |
| +NV_CONFTEST_FUNCTION_COMPILE_TESTS += folio_test_swapcache |
| |
| NV_CONFTEST_TYPE_COMPILE_TESTS += backing_dev_info |
| NV_CONFTEST_TYPE_COMPILE_TESTS += mm_context_t |