Folio Free function causes build failure on kernel 5.15.206

Open Beginner friendly
#1,144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
c

Research direction

Start in kernel-open/nvidia-uvm/uvm_pmm_gpu.c at device_p2p_folio_free and review the NV_PAGEMAP_OPS_HAS_FOLIO_FREE configuration result for kernel 5.15.206. Reproduce with make modules, then confirm the build completes on the reported kernel while preserving folio-free support where the configuration enables it.

Written by the indexing model from the issue text.

Description

build-problem
NVIDIA Open GPU Kernel Modules Version

main/595.71.05

Operating System and Version

Slackware 15.0

Kernel Release

5.15.206

Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
  • I am running on a stable kernel release.
Build Command

make modules

Terminal output/Build Log
 CC [M]  /root/nvidia/open-gpu-kernel-modules/kernel-open/nvidia-uvm/uvm_ats.o
/root/nvidia/open-gpu-kernel-modules/kernel-open/nvidia-uvm/uvm_pmm_gpu.c:3282:42: warning: âstruct folioâ declared inside parameter list will not be visible outside of this definition or declaration
 3282 | static void device_p2p_folio_free(struct folio *folio)
      |                                          ^~~~~
/root/nvidia/open-gpu-kernel-modules/kernel-open/nvidia-uvm/uvm_pmm_gpu.c: In function âdevice_p2p_folio_freeâ:
/root/nvidia/open-gpu-kernel-modules/kernel-open/nvidia-uvm/uvm_pmm_gpu.c:3284:32: error: invalid use of undefined type âstruct folioâ
 3284 |     device_p2p_page_free(&folio->page);
      |                                ^~
make[3]: *** [scripts/Makefile.build:289: /root/nvidia/open-gpu-kernel-modules/kernel-open/nvidia-uvm/uvm_pmm_gpu.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:1924: /root/nvidia/open-gpu-kernel-modules/kernel-open] Error 2
make[2]: Leaving directory '/usr/src/linux-5.15.206'
make[1]: *** [Makefile:115: modules] Error 2
make[1]: Leaving directory '/root/nvidia/open-gpu-kernel-modules/kernel-open'
make: *** [Makefile:59: modules] Error 2
More Info

After some digging, I was able to ascertain that the conf test was getting the correct configuration value for the NV_PAGEMAP_OPS_HAS_FOLIO_FREE (#undef) compile time define. Using that knowledge, I was able to make the following change to allow it to build:

diff --git a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c
index 373eca94..e839f648 100644
--- a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c
+++ b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c
@@ -3279,11 +3279,13 @@ static void device_p2p_page_free(struct page *page)
     nv_kref_put(&p2p_mem->refcount, device_p2p_page_free_wake);
 }
 
+#if defined(NV_PAGEMAP_OPS_HAS_FOLIO_FREE)
 static void device_p2p_folio_free(struct folio *folio)
 {
     device_p2p_page_free(&folio->page);
 }
 #endif
+#endif
 
 #if UVM_CDMM_PAGES_SUPPORTED()
 static void device_coherent_page_free(struct page *page)
Dominant language
C
Stars
17.4k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/open-gpu-kernel-modules

All issues in NVIDIA/open-gpu-kernel-modules

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.