Re: [systemd-devel] Start service after video drivers have been loaded
Il giorno lun 17 giu 2019 alle ore 11:07 Lennart Poettering ha scritto: > > On So, 09.06.19 19:45, Germano Massullo (germano.massu...@gmail.com) wrote: > > > Il giorno mar 21 mag 2019 alle ore 16:59 Mantas Mikulėnas > > ha scritto: > Actually, maybe having udev > > > trigger BOINC startup would be a good option? After all that's how > > > BlueZ already works -- it doesn't go in multi-user.target, it has > > > WantedBy=bluetooth.target and there's an udev rule that makes every > > > Bluetooth device pull in bluetooth.target as a dependency. And > > > that's already an official systemd thing, too. > > > > No because BOINC client can even run on systems without graphic card. > > I will try an approach of restarting BOINC client as soon a new > > dev-dri-card0.device appears > > The clean way to handle this is to make your software handle hardware > dynamically internally: make use of the graphics devices it can make > use of the moment they pop up, and not earlier, and do so with any > device showing up, regardless if there are zero initially, one > eventually, or even more... > > systemd is not really designed to be used as work-around for software > that deals with hardware but doesn't really understand that hw is > dynamic these days. > > Hence my recommendation would be to work with the upstream developers > of your project to natively hook up things with libudev or a similar > library to watch for devices popping up and going away. Good, thank you very much for clarifing this. Have a nice day! > > Lennart > > -- > Lennart Poettering, Berlin ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
On So, 09.06.19 19:45, Germano Massullo (germano.massu...@gmail.com) wrote: > Il giorno mar 21 mag 2019 alle ore 16:59 Mantas Mikulėnas > ha scritto: > Actually, maybe having udev > > trigger BOINC startup would be a good option? After all that's how > > BlueZ already works -- it doesn't go in multi-user.target, it has > > WantedBy=bluetooth.target and there's an udev rule that makes every > > Bluetooth device pull in bluetooth.target as a dependency. And > > that's already an official systemd thing, too. > > No because BOINC client can even run on systems without graphic card. > I will try an approach of restarting BOINC client as soon a new > dev-dri-card0.device appears The clean way to handle this is to make your software handle hardware dynamically internally: make use of the graphics devices it can make use of the moment they pop up, and not earlier, and do so with any device showing up, regardless if there are zero initially, one eventually, or even more... systemd is not really designed to be used as work-around for software that deals with hardware but doesn't really understand that hw is dynamic these days. Hence my recommendation would be to work with the upstream developers of your project to natively hook up things with libudev or a similar library to watch for devices popping up and going away. Lennart -- Lennart Poettering, Berlin ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
14.06.2019 17:13, Germano Massullo пишет: > I have two different options at the moment, and I would like to ask > you for a feedback. > > > A file > > /usr/lib/udev/rules.d/01-boinc-gpu-plugged.rules > > containing > > ACTION=="add", SUBSYSTEM=="drm", RUN+=systemctl --no-block restart > boinc-client.service > > should restart BOINC client when a new DRM device (under /dev/dri) > appears. So we can fix the problem that unables BOINC to detect OpenCL > capabilities if BOINC service is loaded before the videocard drivers. > > Flag > --no-block > is needed to avoid udev time it out agains things runned by RUN. When > udev runs something with RUN it has a timeout and it kills the process > after that so that udev doesn't get blocked on some long running > script triggered from a rule. > By the way since udev has various sandbox rules that restict things > like what sort of sockets you can connect to and what system calls can > be used, this approach could not be recommended. > > Another approach that should avoid this problems is > > ACTION=="add", SUBSYSTEM=="drm", TAG+="systemd", > ENV{SYSTEMD_WANTS}+="boinc-restart.service" > > and then have a simple service (""boinc-restart.service") that does > the restart. By the way this means that the machine will have two > systemd unit files for BOINC client and perhaps even a > boinc-restart.service marked as running among running services. > > What do you think about? Third approach - your service listens to udev events and automatically discovers whatever it is interested in. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
I have two different options at the moment, and I would like to ask you for a feedback. A file /usr/lib/udev/rules.d/01-boinc-gpu-plugged.rules containing ACTION=="add", SUBSYSTEM=="drm", RUN+=systemctl --no-block restart boinc-client.service should restart BOINC client when a new DRM device (under /dev/dri) appears. So we can fix the problem that unables BOINC to detect OpenCL capabilities if BOINC service is loaded before the videocard drivers. Flag --no-block is needed to avoid udev time it out agains things runned by RUN. When udev runs something with RUN it has a timeout and it kills the process after that so that udev doesn't get blocked on some long running script triggered from a rule. By the way since udev has various sandbox rules that restict things like what sort of sockets you can connect to and what system calls can be used, this approach could not be recommended. Another approach that should avoid this problems is ACTION=="add", SUBSYSTEM=="drm", TAG+="systemd", ENV{SYSTEMD_WANTS}+="boinc-restart.service" and then have a simple service (""boinc-restart.service") that does the restart. By the way this means that the machine will have two systemd unit files for BOINC client and perhaps even a boinc-restart.service marked as running among running services. What do you think about? Thank you for your time BOINC client systemd unit file: https://github.com/BOINC/boinc/blob/master/client/scripts/boinc-client.service.in ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
Il giorno mar 21 mag 2019 alle ore 16:59 Mantas Mikulėnas ha scritto: > Actually, maybe having udev trigger BOINC startup would be a good option? > After all that's how BlueZ already works -- it doesn't go in > multi-user.target, it has WantedBy=bluetooth.target and there's an udev rule > that makes every Bluetooth device pull in bluetooth.target as a dependency. > And that's already an official systemd thing, too. No because BOINC client can even run on systems without graphic card. I will try an approach of restarting BOINC client as soon a new dev-dri-card0.device appears ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
On Tue, May 21, 2019 at 5:56 PM Mantas Mikulėnas wrote: > On Tue, May 21, 2019 at 1:39 PM Germano Massullo < > germano.massu...@gmail.com> wrote: > >> Hello, Fedora / EPEL BOINC comaintainer here. >> On BOINC client we have a problem. On some Linux distributions BOINC >> gets loaded before the videocard drivers are loaded, so it does not >> detect OpenCL/CUDA capabilities. >> We cannot use graphical.target as wait condition because there can be >> headless systems without graphic server so this condition cannot be >> used. >> What can be a good solution in your opinion? >> > > You cannot really know when *all* devices have been detected. Although, > since graphics cards are probably always fixed PCI devices, maybe a limited > form of `udevadm settle` (one that doesn't block the rest of boot process) > would work? > > You can know when the *first* device has been detected. This is probably > just as poor a suggestion as above, but worth a try: Add a dependency on > dev-dri-card0.device (and an udev rule to apply TAG+="systemd" to drm > devices). > > (Even crazier would be to allow BOINC to start as normal, but then > *restart* it as soon as the first GPU driver has been loaded.) > > Actually, maybe having udev trigger BOINC startup would be a good option? After all that's how BlueZ already works -- it doesn't go in multi-user.target, it has WantedBy=bluetooth.target and there's an udev rule that makes every Bluetooth device pull in bluetooth.target as a dependency. And that's already an official systemd thing, too. -- Mantas Mikulėnas ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
On Tue, May 21, 2019 at 1:39 PM Germano Massullo wrote: > Hello, Fedora / EPEL BOINC comaintainer here. > On BOINC client we have a problem. On some Linux distributions BOINC > gets loaded before the videocard drivers are loaded, so it does not > detect OpenCL/CUDA capabilities. > We cannot use graphical.target as wait condition because there can be > headless systems without graphic server so this condition cannot be > used. > What can be a good solution in your opinion? > You cannot really know when *all* devices have been detected. Although, since graphics cards are probably always fixed PCI devices, maybe a limited form of `udevadm settle` (one that doesn't block the rest of boot process) would work? You can know when the *first* device has been detected. This is probably just as poor a suggestion as above, but worth a try: Add a dependency on dev-dri-card0.device (and an udev rule to apply TAG+="systemd" to drm devices). (Even crazier would be to allow BOINC to start as normal, but then *restart* it as soon as the first GPU driver has been loaded.) -- Mantas Mikulėnas ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Start service after video drivers have been loaded
On Di, 21.05.19 12:38, Germano Massullo (germano.massu...@gmail.com) wrote: > Hello, Fedora / EPEL BOINC comaintainer here. > On BOINC client we have a problem. On some Linux distributions BOINC > gets loaded before the videocard drivers are loaded, so it does not > detect OpenCL/CUDA capabilities. > We cannot use graphical.target as wait condition because there can be > headless systems without graphic server so this condition cannot be > used. > What can be a good solution in your opinion? I am not sure what "BOINC" is, but if it needs to wait for hardware it should use libudev or so and wait for it to show up. Everything else is messy. There's no point in time where all hw plugged in is guaranteed to have shown up, and in particular in a world where even PCI devices are hotpluggable (thunderbolt), even graphics devices can come and go any time. Hence there's no point in time during boot when you know that all graphics devices have now shown up, or where you know that there won't be any graphics device showing up ever... any program that Lennart -- Lennart Poettering, Berlin ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel