Commit cb2a351
committed
nvidia: use vzalloc for oversized page table allocations
nvos_create_alloc() allocates at->page_table as a single array of
nvidia_pte_t entries:
pt_size = num_pages * sizeof(nvidia_pte_t)
For very large registered system-memory ranges, pt_size can exceed
INT_MAX. For example, a 512 GiB range with 4 KiB base pages requires
134,217,728 entries. With 16-byte nvidia_pte_t entries, pt_size is
2,147,483,648 bytes.
kvzalloc() rejects sizes larger than INT_MAX before falling back to
vmalloc, so nvos_create_alloc() can fail even though the page table is
CPU-side metadata and does not require physical contiguity.
Use vzalloc() directly when pt_size exceeds INT_MAX, while preserving
the existing kvzalloc() path for smaller allocations.
The existing kvfree() release path remains valid for both kvzalloc()
and vzalloc() allocations.
Signed-off-by: Guzebing <guzebing1612@gmail.com>1 parent 2ccbad2 commit cb2a351
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
| |||
0 commit comments