Public bug reported:

Hello Ubuntu graphics package maintainers,

Please review this experimental, AI-assisted robustness proposal for the open 
NVIDIA
driver. It is an RFC/wishlist request, not a reproduced hardware defect, a 
proven
performance improvement, a new complete driver, or a request for immediate SRU 
upload.

Prepared for: Jibin Babu
Target package: nvidia-graphics-drivers-595, 595.84-0ubuntu0.24.04.1
Test environment: Ubuntu 24.04.4 LTS, Linux 6.8.0-139-generic, x86-64,
Intel Raptor Lake-P graphics plus NVIDIA RTX 4060 Laptop GPU; open driver 
595.84.

PROPOSAL
Use kvmalloc_array(..., GFP_KERNEL | __GFP_ZERO) for the struct page pointer 
array in
nv_drm_lock_user_pages on Linux, and kvfree on both error and release paths.
The current nv_drm_calloc/kzalloc allocation needs physically contiguous 
storage even
though this array does not require it. The change permits vmalloc fallback while
retaining zero initialization, overflow checks, and existing pin/unpin 
semantics.
The non-Linux branch and generic allocation helpers are unchanged.

TESTS COMPLETED
- All five NVIDIA modules compiled against the installed 6.8.0-139 kernel 
headers.
- 2,219 regression scenarios passed in each of three ASan/UBSan harness modes:
  baseline Linux, patched Linux, and preserved non-Linux branch (6,657 total).
  Exact driver functions are extracted; kernel APIs are MOCKED.
- Thirty real GEM user-memory import/close operations passed on the UNMODIFIED
  loaded driver, over sizes from 4 KiB through 256 MiB; no memory pressure 
injected.
- Patch applicability checked against the current upstream main source snapshot.

LIMITATIONS / REVIEW REQUEST
The patched modules have NOT been loaded. No A/B runtime benchmark, actual 
kernel
allocation fault injection, power measurement, FPS gain, 8K playback 
improvement,
suspend/resume test, or broad hardware/kernel compatibility has been 
established.
No real hardware allocation failure was reproduced. The existing-driver baseline
succeeded throughout. Vmalloc fallback has overhead and is not always faster.
Please advise whether this allocation change is appropriate and whether review
should proceed upstream first. An independent kernel review and isolated runtime
validation are necessary before considering packaging or installation.

The attached review material contains tests, source/patch, environment 
metadata, and
sanitized logs, without private documents or credentials. This is an 
AI-assisted draft;
no contributor agreement or DCO attestation has been signed on the submitter's 
behalf.

PATCH (also supplied as a separate attachment)
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.c
@@ -83,7 +83,13 @@
     struct page **user_pages;
     int pages_pinned;
 
+#if defined(NV_LINUX)
+    /* The page-pointer array need not be physically contiguous. */
+    user_pages = kvmalloc_array(pages_count, sizeof(*user_pages),
+                               GFP_KERNEL | __GFP_ZERO);
+#else
     user_pages = nv_drm_calloc(pages_count, sizeof(*user_pages));
+#endif
 
     if (user_pages == NULL) {
         return -ENOMEM;
@@ -113,7 +119,11 @@
         }
     }
 
+#if defined(NV_LINUX)
+    kvfree(user_pages);
+#else
     nv_drm_free(user_pages);
+#endif
 
     return (pages_pinned < 0) ? pages_pinned : -EINVAL;
 }
@@ -127,7 +137,11 @@
         NV_UNPIN_USER_PAGE(pages[i]);
     }
 
+#if defined(NV_LINUX)
+    kvfree(pages);
+#else
     nv_drm_free(pages);
+#endif
 }
 
 /*

** Affects: nvidia-graphics-drivers-595 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: nvidia-drm patch wishlist

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2166578

Title:
  [RFC] nvidia-drm: allow vmalloc fallback for user-memory page arrays

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-595/+bug/2166578/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to