Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 591286 - x11-drivers/nvidia-drivers[uvm] should create /dev/nvidia-uvm
Summary: x11-drivers/nvidia-drivers[uvm] should create /dev/nvidia-uvm
Status: RESOLVED DUPLICATE of bug 506696
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-14 23:29 UTC by Sebastian Pipping
Modified: 2018-01-27 12:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Pipping gentoo-dev 2016-08-14 23:29:35 UTC
Hi!

I don't have an NVidia card but the way I understand bug #591214 we need /dev/nvidia-uvm prior to emerge time if we don't want to do something like

  http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/#runfile-verifications

from inside the Gimp ebuild.  Those commands look like a candidate for udev
rules to me.  Are there reasons to not create /dev/nvidia-uvm automatically?

I'm looking forward to your feedback.

Best, Sebastian
Comment 1 Mike Gilbert gentoo-dev 2016-08-14 23:46:17 UTC
Modern udev never creates device nodes; it only applies permissions to existing nodes created by the kernel in devtmpfs.
Comment 2 Sebastian Pipping gentoo-dev 2016-08-15 00:05:31 UTC
Any ideas where to move those calls to mknod?
Comment 3 Mike Gilbert gentoo-dev 2016-08-15 00:48:32 UTC
(In reply to Sebastian Pipping from comment #2)
> Any ideas where to move those calls to mknod?

Ideally, the kernel module should be creating them by calling devtmpfs_create_node (usually indirectly). Are you sure that doesn't already happen?

If not, a possible workaround would be to create them in a shell script fired by a udev rule -- assuming the module generates a udev event.

Another alternative would be an init script and/or systemd unit.
Comment 4 Mike Gilbert gentoo-dev 2016-08-15 01:08:44 UTC
Currently, there is a udev rule that calls nvidia-udev.sh when the nvidia modules is loaded.

nvidia-udev.sh calls /opt/bin/nvidia-smi. According the the documentation you linked, nvidia-smi should take care of creating device nodes.
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2016-08-15 07:34:38 UTC
(In reply to Mike Gilbert from comment #4)
> Currently, there is a udev rule that calls nvidia-udev.sh when the nvidia
> modules is loaded.
> 
> nvidia-udev.sh calls /opt/bin/nvidia-smi. According the the documentation
> you linked, nvidia-smi should take care of creating device nodes.

But we don't (yet) have a udev rule for nvidia-uvm, which is the point here, I think.

That said, I don't normally have nvidia-uvm loaded at all times and I don't expect anyone to, and no program (bug #591214) should expect it to be available OR fail unless its functions are restricted to that device being available.
Comment 6 Daniel Neugebauer 2016-08-15 19:19:19 UTC
Chiming in as I'm the one who reported #591214.

First of all: I don't have any idea about what should actually be done by udev, modules or scripts/tools at this point as I don't understand why uvm is needed for GIMP compilation anyway, as well as what uvm is supposed to be used for in general (accessing VRAM, something for GPGPU access?) and I'm not into GEGL either. So, actually, I'm pretty clueless. :)

Calling nvidia-smi by the (Gentoo-provided?) udev script appears to have been just a workaround to perform some missed initialization or something like that, if I'm reading #454740 correctly? It doesn't appear to create uvm device nodes despite the nvidia-uvm module being loaded on my system and it should not perform any module probing/initialization according to the manpage (it's just for managing & monitoring the card?).

# lsmod | grep nvidia
nvidia_modeset        732580  4
nvidia_uvm            521605  0
nvidia               9994211  78 nvidia_modeset,nvidia_uvm

# ls -al /dev/nvidia*
crw-rw---- 1 root video 195,   0 Aug 15 14:30 /dev/nvidia0
crw-rw---- 1 root video 195, 255 Aug 15 14:30 /dev/nvidiactl
crw-rw-rw- 1 root root  195, 254 Aug 15 11:58 /dev/nvidia-modeset

As the sandbox logs posted in #591214 suggest, the uvm device node can be created by calling nvidia-modprobe which (from reading the manpage) sound like it should have been called earlier. Interestingly, nvidia-modprobe gets called "automatically" (who's the caller?!) by GEGL on compilation (thus the sandbox errors) or when I launch a compiled GIMP 2.9.4.

From looking at strace output it isn't obvious what happens, except that someone creates the node:

$ grep -E '(modprobe|uvm)' gimp-strace.log -B 30 -A 20     
open("/etc/nvidia/nvidia-application-profiles-rc.d/", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/nvidia/nvidia-application-profiles-361.28-rc", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/nvidia/nvidia-application-profiles-rc", O_RDONLY) = -1 ENOENT (No such file or directory)
readlink("/proc/16566/exe", "/usr/bin/gimp-2.9", 4095) = 17
brk(0x172b000)                          = 0x172b000
brk(0x1729000)                          = 0x1729000
geteuid()                               = 1000
open("/tmp/nvidia-mps/control", O_WRONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
lstat("/proc", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
lstat("/proc/self", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/proc/self", "16566", 4095)   = 5
lstat("/proc/16566", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
lstat("/proc/16566/exe", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/proc/16566/exe", "/usr/bin/gimp-2.9", 4095) = 17
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/bin", {st_mode=S_IFDIR|0755, st_size=167936, ...}) = 0
lstat("/usr/bin/gimp-2.9", {st_mode=S_IFREG|0755, st_size=6354144, ...}) = 0
open("/proc/modules", O_RDONLY)         = 12
fstat(12, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7fb2b87000
read(12, "nvidia_modeset 732580 4 - Live 0"..., 1024) = 1024
read(12, "a000\nip6t_rt 2254 3 - Live 0xfff"..., 1024) = 1024
close(12)                               = 0
munmap(0x7f7fb2b87000, 4096)            = 0
open("/proc/devices", O_RDONLY)         = 12
fstat(12, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7fb2b87000
read(12, "Character devices:\n  1 mem\n  2 p"..., 1024) = 671
close(12)                               = 0
munmap(0x7f7fb2b87000, 4096)            = 0
stat("/dev/nvidia-uvm", 0x7ffc42719c80) = -1 ENOENT (No such file or directory)
mknod("/dev/nvidia-uvm", S_IFCHR|0666, makedev(245, 0)) = -1 EACCES (Permission denied)
stat("/usr/bin/nvidia-modprobe", {st_mode=S_IFREG|S_ISUID|0710, st_size=29384, ...}) = 0
geteuid()                               = 1000
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f7fb2b55b90) = 16571
wait4(16571, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 16571
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16571, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
open("/dev/nvidia-uvm", O_RDWR)         = 12
ioctl(12, FIBMAP, 0x7ffc42719d20)       = 0
clock_gettime(CLOCK_MONOTONIC_RAW, {30874, 501563042}) = 0
ioctl(12, 0x27, 0x7ffc42719d20)         = 0
ioctl(12, 0x7ff, 0x7ffc42719d20)        = 0
open("/proc/modules", O_RDONLY)         = 13
fstat(13, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7fb2b87000
read(13, "nvidia_modeset 732580 4 - Live 0"..., 1024) = 1024
read(13, "a000\nip6t_rt 2254 3 - Live 0xfff"..., 1024) = 1024
read(13, "ffa0009000\ncoretemp 5948 0 - Liv"..., 1024) = 1024
close(13)                               = 0
munmap(0x7f7fb2b87000, 4096)            = 0
open("/proc/driver/nvidia/params", O_RDONLY) = 13
fstat(13, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7fb2b87000
read(13, "Mobile: 4294967295\nResmanDebugLe"..., 1024) = 417
close(13)                               = 0
munmap(0x7f7fb2b87000, 4096)            = 0
stat("/dev/nvidiactl", {st_mode=S_IFCHR|0660, st_rdev=makedev(195, 255), ...}) = 0
open("/dev/nvidiactl", O_RDWR)          = 13

It should also be noted that nvidia-modprobe can be called with SetUID root permissions for everyone who's in the video group, so it may as well be that it's intended to be called on demand by applications - which just doesn't work from inside the emerge sandbox:

$ ls -Lal `which nvidia-modprobe`
-rws--x--- 1 root video 29384 Jul 24 16:46 /usr/bin/nvidia-modprobe
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2018-01-27 12:37:12 UTC

*** This bug has been marked as a duplicate of bug 506696 ***