NORMAL ZONE (low memory) exhaustion when VRAM depleted on 256.* and upstream 32bit drivers

Problem:
ZONE NORMAL (low memory) is exhausted when VRAM is depleted and further frame updates/textures are used/created. Eventually the out-of-memory (OOM) killer will kick-off and start it’s logic to free up ZONE NORMAL memory by killing applications.

Environment:
HP Z600 Workstations with dual FX580 (512M) video cards driving three monitors with three separate X sessions (one for each) running in-house application. Running 32bit OS kernel version 2.6.32-431.11.2.el6.i686 and drivers tested include 331.20, 337.25, 340.24 all exhibit the same problem.

I do not think the application’s own heap allocations have much of an impact on this issue.
Most of those would be in the individual “depictable” classes that actually load the data inside our source/applications DisplayPanel.{c|h] and DisplayMgr.[c|h] and it simply runs “XCreatePixmap”. If need be the source of the in-house applications can be provided and/or the specific XCreatePixmap calls.

Note that we do not experience this issue on older kernel version 2.6.18-194.17.1.el5 which is running 195.36.24 driver version. Installing driver versions downstream of 256.* results in various “undefined symbols” in the libglx and nvidia_drv shared objects, thus downgrading is not optimal/option as well as the “supported” version for the kernel version and cards we have is 331.20 regardless.

Troubleshooting:
Loading up application and monitoring the slab table, low memory, and VRAM via:

slabtop -n 1 -S c
watch -n 0.25 free -lm
watch -n 0.25 nvidia-smi -q ‘2>&1’ ‘|’ grep -A3 “‘Memory Usage’”

You will notice that when the VRAM for a specific GPU driving the rendering is depleted, the nvidia_pte_t (page table entry structures) appear to start being evicted and calling __get_free_pages with GFP kernel calls inside the driver via nv_alloc_system_pages( ). Eventually the low memory is exhausted and the OOM killer is evoked to free up pages, if it cannot free up enough reclaimable slabs then it will start killing applications based on their oom_adj/score.

We’ve already tuned the VM and kernel to the point where we’ve freed up as much low memory as is possible give the limitations of the 32bit architecture (about 780M free of the allotted max 896M). We still will notice that when this occurs, the nvidia_pte_t slab entries/cache will grow significantly, and was the initial piece of information that lead us to investigating the nvidia driver.

Previous versions appear to not attempt to allocate system pages under the same circumstances, 195.36.24 for example … however I cannot fully attest to that as I don’t have a test environment to run through that on just yet.

Request:
Is there any way to mediate this, backport or build in a way to prevent this situation from occurring that doesn’t introduce additional risk to the system. We could change the nv.c source to mediate the situation, but it doesn’t account for what the application may then do if this occurs under these situations. Unfortunately moving to a 64bit kernel is not possible at this time due to programmatic issues, and if there is a way to remedy the missing symbols perhaps (need to still look into that) then we could use the older driver.

Attached is the bug-report, there are three, one when the system is on the verge but not evoked the OOM killer yet, that’s named firstLoad. The CRASH named report was caught just before the OOM killer was evoked, and I believe the regular named log is after the crash.

Additional Info may be uploaded (slabinfo, kernel ring buffer, etc…) to show the situation but the nvidia-smi will show the issue hopefully, and the references in this post hopefully will job someone?

Thanks for your time and attention!!
[This file was removed because it was flagged as potentially malicious] (98.4 KB)
[This file was removed because it was flagged as potentially malicious] (134 KB)
nvidia-bug-report.log.gz (142 KB)

Some additional information in the form of logs/tabels:

Slab info:

slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
nvidia_p2p_page_t      0      0     32  113    1 : tunables  120   60    8 : slabdata      0      0      0
nvidia_pte_t      173460 174744     52   72    1 : tunables  120   60    8 : slabdata   2425   2427    480
nvidia_stack_t       126    126   8192    1    2 : tunables    8    4    0 : slabdata    126    126      0

Low Memory exhaustion, nothing reclaimable:

Jul  1 14:23:45 lx4-btv kernel: Normal free:3704kB <==== min:3724kB <===== low:4652kB high:5584kB active_anon:0kB inactive_anon:0kB active_file:144kB inactive_file:176kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:883912kB mlocked:0kB dirty:0kB writeback:0kB mapped:924kB shmem:0kB slab_reclaimable:11160kB slab_unreclaimable:35876kB kernel_stack:4448kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:486 all_unreclaimable? yes

OOM evocation:

The kernel will kill processes off in attempt to keep the OS running.  In this case the nvidia driver was implicated by the traces in the messages:

  Jul  1 14:23:45 lx4-btv kernel: Out of memory: Kill process 4704 (IGC_Process) score 20 or sacrifice child
  Jul  1 14:23:45 lx4-btv kernel: Killed process 7920, UID 102, (warnGenWish) total-vm:18580kB, anon-rss:2168kB, file-rss:4552kB
  Jul  1 14:23:45 lx4-btv kernel: Xorg invoked oom-killer: gfp_mask=0x82d0, order=0, oom_adj=0, oom_score_adj=0
  Jul  1 14:23:45 lx4-btv kernel: Xorg cpuset=/ mems_allowed=0
  Jul  1 14:23:45 lx4-btv kernel: Pid: 3369, comm: Xorg Tainted: P           ---------------    2.6.32-431.11.2.el6.i686 #1
  Jul  1 14:23:45 lx4-btv kernel: Call Trace:
  Jul  1 14:23:45 lx4-btv kernel: [<c04ec6e4>] ? dump_header+0x84/0x190
  Jul  1 14:23:45 lx4-btv kernel: [<c04eca88>] ? oom_kill_process+0x68/0x280
  Jul  1 14:23:45 lx4-btv kernel: [<c04ec9c2>] ? oom_badness+0x92/0xf0
  Jul  1 14:23:45 lx4-btv kernel: [<c04ed008>] ? out_of_memory+0xc8/0x1e0
  Jul  1 14:23:45 lx4-btv kernel: [<c04f778d>] ? __alloc_pages_nodemask+0x7fd/0x810
  Jul  1 14:23:45 lx4-btv kernel: [<c04f77b4>] ? __get_free_pages+0x14/0x30
  Jul  1 14:23:45 lx4-btv kernel: Xorg invoked oom-killer: gfp_mask=0x82d0, order=0, oom_adj=0, oom_score_adj=0
  Jul  1 14:23:45 lx4-btv kernel: Xorg cpuset=/ mems_allowed=0
  Jul  1 14:23:45 lx4-btv kernel: Pid: 3369, comm: Xorg Tainted: P           ---------------    2.6.32-431.11.2.el6.i686 #1
  Jul  1 14:23:45 lx4-btv kernel: Call Trace:
  Jul  1 14:23:45 lx4-btv kernel: [<c04ec6e4>] ? dump_header+0x84/0x190
  Jul  1 14:23:45 lx4-btv kernel: [<c04eca88>] ? oom_kill_process+0x68/0x280
  Jul  1 14:23:45 lx4-btv kernel: [<c04ec9c2>] ? oom_badness+0x92/0xf0
  Jul  1 14:23:45 lx4-btv kernel: [<c04ed008>] ? out_of_memory+0xc8/0x1e0
  Jul  1 14:23:45 lx4-btv kernel: [<c04f778d>] ? __alloc_pages_nodemask+0x7fd/0x810
  Jul  1 14:23:45 lx4-btv kernel: [<c04f77b4>] ? __get_free_pages+0x14/0x30
  Jul  1 14:23:45 lx4-btv kernel: [<f95980f1>] ? nv_alloc_system_pages+0x101/0x820 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f958fb4d>] ? nvos_create_alloc+0xdd/0x130 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f958fd8b>] ? nv_alloc_pages+0x1eb/0x210 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9599196>] ? os_pci_read_dword+0x36/0x40 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f956cbc3>] ? _nv012258rm+0x10f/0x129 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f94523ee>] ? _nv011208rm+0x163/0x316 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9452813>] ? _nv011202rm+0x272/0x2fd [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9132d0f>] ? _nv000891rm+0x5eb/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9133483>] ? _nv000891rm+0xd5f/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f913283d>] ? _nv000891rm+0x119/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9116915>] ? _nv000693rm+0xbb/0x209 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f956ada0>] ? _nv000778rm+0x2e4/0x8cc [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f957366d>] ? rm_ioctl+0x4e/0xa1 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9591ca8>] ? nv_kern_ioctl+0xf8/0x460 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c0610265>] ? copy_from_user+0x35/0x120
  Jul  1 14:23:45 lx4-btv kernel: [<f9591d08>] ? nv_kern_ioctl+0x158/0x460 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c0481927>] ? enqueue_hrtimer+0x67/0xb0
  Jul  1 14:23:45 lx4-btv kernel: [<f9592048>] ? nv_kern_unlocked_ioctl+0x18/0x20 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9592030>] ? nv_kern_unlocked_ioctl+0x0/0x20 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c054888b>] ? vfs_ioctl+0x1b/0xa0
  Jul  1 14:23:45 lx4-btv kernel: [<c0548a6c>] ? do_vfs_ioctl+0x6c/0x5c0
  Jul  1 14:23:45 lx4-btv kernel: [<c0536d76>] ? rw_verify_area+0x66/0xe0
  Jul  1 14:23:45 lx4-btv kernel: [<c05376ee>] ? vfs_read+0x11e/0x190
  Jul  1 14:23:45 lx4-btv kernel: [<c0549036>] ? sys_ioctl+0x76/0x90
  Jul  1 14:23:45 lx4-btv kernel: [<c04b9dfb>] ? __audit_syscall_exit+0x21b/0x240
  Jul  1 14:23:45 lx4-btv kernel: [<c04099bf>] ? sysenter_do_call+0x12/0x28
  Jul  1 14:23:45 lx4-btv kernel: Mem-Info:
  Jul  1 14:23:45 lx4-btv kernel: [<f95980f1>] ? nv_alloc_system_pages+0x101/0x820 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f958fb4d>] ? nvos_create_alloc+0xdd/0x130 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f958fd8b>] ? nv_alloc_pages+0x1eb/0x210 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9599196>] ? os_pci_read_dword+0x36/0x40 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f956cbc3>] ? _nv012258rm+0x10f/0x129 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f94523ee>] ? _nv011208rm+0x163/0x316 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9452813>] ? _nv011202rm+0x272/0x2fd [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9132d0f>] ? _nv000891rm+0x5eb/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9133483>] ? _nv000891rm+0xd5f/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f913283d>] ? _nv000891rm+0x119/0x2fa5 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9116915>] ? _nv000693rm+0xbb/0x209 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f956ada0>] ? _nv000778rm+0x2e4/0x8cc [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f957366d>] ? rm_ioctl+0x4e/0xa1 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9591ca8>] ? nv_kern_ioctl+0xf8/0x460 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c0610265>] ? copy_from_user+0x35/0x120
  Jul  1 14:23:45 lx4-btv kernel: [<f9591d08>] ? nv_kern_ioctl+0x158/0x460 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c0481927>] ? enqueue_hrtimer+0x67/0xb0
  Jul  1 14:23:45 lx4-btv kernel: [<f9592048>] ? nv_kern_unlocked_ioctl+0x18/0x20 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<f9592030>] ? nv_kern_unlocked_ioctl+0x0/0x20 [nvidia]
  Jul  1 14:23:45 lx4-btv kernel: [<c054888b>] ? vfs_ioctl+0x1b/0xa0
  Jul  1 14:23:45 lx4-btv kernel: [<c0548a6c>] ? do_vfs_ioctl+0x6c/0x5c0
  Jul  1 14:23:45 lx4-btv kernel: [<c0536d76>] ? rw_verify_area+0x66/0xe0
  Jul  1 14:23:45 lx4-btv kernel: [<c05376ee>] ? vfs_read+0x11e/0x190
  Jul  1 14:23:45 lx4-btv kernel: [<c0549036>] ? sys_ioctl+0x76/0x90
  Jul  1 14:23:45 lx4-btv kernel: [<c04b9dfb>] ? __audit_syscall_exit+0x21b/0x240
  Jul  1 14:23:45 lx4-btv kernel: [<c04099bf>] ? sysenter_do_call+0x12/0x28