42.0-1ubuntu6 doesn't recongize the presence of NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS=1

Bug #1969447 reported by Jack Howarth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdm3 (Ubuntu)
New
Undecided
Unassigned

Bug Description

The current /lib/udev/rules.d/61-gdm.rules has a broken rule for detecting the presence of NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS=1.

This issue can be seen by adding a file /etc/modprobe.d/nvidia-power-management.conf containing the line...

options nvidia NVreg_PreserveVideoMemoryAllocations=1

and then rebooting. Manually executing the test used in /lib/udev/rules.d/61-gdm.rules as...

/bin/sh -c "sed -e 's/: /=/g' -e 's/\([^[:upper:]]\)\([[:upper:]]\)/\1_\2/g' -e 's/[[:lower:]]/\U&/g' -e 's/^/NVIDIA_/' /proc/driver/nvidia/params"

produces the desired...

NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS=1

for the actual test in /lib/udev/rules.d/61-gdm.rules of...

IMPORT{program}="/bin/sh -c \"sed -e 's/: /=/g' -e 's/\([^[:upper:]]\)\([[:upper:]]\)/\1_\2/g' -e 's/[[:lower:]]/\U&/g' -e 's/^/NVIDIA_/' /proc/driver/nvidia/params\""
ENV{NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS}!="1", GOTO="gdm_disable_wayland"

However, this test still is treated as failing as seen by the absence of Wayland on Nvidia at that point. Currently, the only workaround is to disable this particular test.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: gdm3 42.0-1ubuntu6
ProcVersionSignature: Ubuntu 5.15.0-27.28-generic 5.15.30
Uname: Linux 5.15.0-27-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.11-0ubuntu82
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Tue Apr 19 05:20:49 2022
InstallationDate: Installed on 2022-03-31 (18 days ago)
InstallationMedia: Ubuntu 22.04 LTS "Jammy Jellyfish" - Alpha amd64 (20220326)
ProcEnviron:
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: gdm3
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile..etc.gdm3.custom.conf: 2022-04-01T05:39:42.178574

Revision history for this message
Jack Howarth (jwhowarth) wrote :
description: updated
Revision history for this message
Jack Howarth (jwhowarth) wrote :

I am wondering if the use of escaped quotes in the failing rule of /lib/udev/rules.d/61-gdm.rules is really being honored. There don't seem to be any other examples of deployed udev rules which actually use such escaped quotes.

Revision history for this message
Jack Howarth (jwhowarth) wrote (last edit ):

I have found that current /lib/udev/rules.d/61-gdm.rules can be fixed by swapping the order of the single and escaped double quotes from...

IMPORT{program}="/bin/sh -c \"sed -e 's/: /=/g' -e 's/\([^[:upper:]]\)\([[:upper:]]\)/\1_\2/g' -e 's/[[:lower:]]/\U&/g' -e 's/^/NVIDIA_/' /proc/driver/nvidia/params\""

which fails to parse correctly to...

IMPORT{program}="/bin/sh -c 'sed -e \"s/: /=/g\" -e \"s/\([^[:upper:]]\)\([[:upper:]]\)/\1_\2/g\" -e \"s/[[:lower:]]/\U&/g\" -e \"s/^/NVIDIA_/\" /proc/driver/nvidia/params'"

which parses properly and allows the test for

ENV{NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS}!="1", GOTO="gdm_disable_wayland"

to succeed when /etc/modprobe.d/nvidia-power-management.conf contains...

options nvidia NVreg_PreserveVideoMemoryAllocations=1

Revision history for this message
Jack Howarth (jwhowarth) wrote :

Note that I stumbled onto the above fix after noticing the example shown for the udev escaped quoting support showed an example with double quotes surrounded by single quotes which in turn surrounded escaped double quotes...

https://git.alternativebit.fr/NinjaTrappeur/Systemd/commit/7e760b79ad143b26a5c937afa7666a7c40508f85

udev-rules: all values can contain escaped double quotes now (#6890)
This is primarly useful to support escaped double quotes in PROGRAM or
IMPORT{program} directives.

The only possibilty before this patch was to use an external shell script but
this seems too cumbersome for trivial logics such as

 PROGRAM=="/bin/sh -c 'FOO=\"%s{model}\"; echo ${FOO:0:4}'"

or any similar shell constructs that needs to deals with patterns including
whitespaces.

As it's the case for single quote and for directives running a program, words
within escaped double quotes will be considered as a single argument.

Fixes: #6835

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

I'm not totally sure we need this bug. The problem with Wayland sessions missing on Nvidia is tracked in bug 1968929. And the use of NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS should be tracked in bug 1876632. So essentially this bug is just pointing out that we haven't fixed bug 1876632 yet.

Revision history for this message
Jack Howarth (jwhowarth) wrote (last edit ):

Daniel, I disagree. This bug is actually about the fact that the test crafted in /lib/udev/rules.d/61-gdm.rules doesn't parse as expected in udev. We also should probably file a bug report against upstream udev in systemd as the changes added there to support escaped quotes in #6890 aren't robust enough. Unless you can see any obvious flaw in the original syntax of the test having double quotes surrounding escaped double quotes surrounding single quotes compared to the version that works with double quotes, surrounding single quotes surrounding escaped double quotes.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks for your efforts. Please propose fixes upstream at https://gitlab.gnome.org/GNOME/gdm/-/merge_requests (if they apply)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.