-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wishlist: support for mdev's netlink daemon mode #367
Comments
Since the current setup has been moved from hard-coded in C to an external .conf file the mdev support is considered "working" and "good enough" for users to be able to override locally. Improvements along the lines you mention are welcome in the form of pull requests. I.e., I have not immediate use for this myself so would be put on the back burner. |
On Wed, 20 Sep 2023 22:22:41 -0700, Joachim Wiberg writes:
Improvements along the lines you mention are welc
ome in the form of pull requests.
i'll provide one; may take a week or two.
regards
az
…--
Alexander Zangerl + GPG Key 2FCCF66BB963BD5F + https://snafu.priv.at/
The determined programmer can write a FORTRAN program in any language.
|
I'd appreciate if you can keep the old |
Very little progress on this one, so I took the liberty of testing it out myself. I changed
In my OS I have either BusysBox syslogd or my own sysklogd (the one Debian used before rsyslogd). Both provide the condition This works for me:tm:, but maybe you had something else in mind @az143? Unless you have any objections, I'll go with this tomorrow, because I'd like to get Finit v4.5 out the door asap since I have customer projects hinging on it. |
sorry for the lack of progress - i'm overseas at the moment and slightly busier than normal. back on topic: your suggested setup is near ideal, except:
overall: for most setups and/or basic use, |
Thanks, I suspected As an example, we use a Marvell switch with external PHYs that requires firmware. We use We need a similar barrier here with mdev, that's why I added I have looked at other distros using
|
On Sun, 15 Oct 2023 11:42:54 -0700, Joachim Wiberg writes:
We need a similar barrier here with mdev, that's why I added `mdev -s` to ensur
e all that had completed, and then `mdev -df` would take care of any runtime ch
anges after that point.
please note that, according to the busybox sources, mdev -s is not the
same as an udevadm trigger...add:
util-linux/mdev.c:
/* "mdev -s" scans /sys/class/xxx, looking for directories which have dev
* file (it is of the form "M:m\n"). Example: /sys/class/tty/tty0/dev
* contains "4:0\n". Directory name is taken as device name, path component
* directly after /sys/class/ as subsystem. In this example, "tty0" and "tty".
* Then mdev creates the /dev/device_name node.
the find-and-add coldplug is closer to a full discovery operation,
but doesn't wait for completion. (mdev has no mechanism similar
to udevadm settle.)
I have looked at other distros using `mdev -df` and have not seen
anything like
your `find /sys/devices` construct. Do you have a reference for that I can lo
ok into?
a few: https://documentation.suse.com/sles/12-SP4/html/SLES-all/cha-udev.html#sec-udev-boot
explains how and why add to the udev device is relevant/required,
daemon_init() in util-linux/mdev.c in the busybox sources, has an example of
the find-and-add sequence
the manpage and sources for mdevd-coldplug (https://skarnet.org/software/mdevd/mdevd-coldplug.html and https://github.com/skarnet/mdevd/blob/master/src/mdevd/mdevd-coldplug.c) describe why (and how) the competition does the equivalent,
and this lwn article, https://lwn.net/Articles/646617/
the read without IFS is just to survive devices with spaces in their
uevent name, e.g.
/sys/devices/platform/Fixed MDIO bus.0/mdio_bus/fixed-0/uevent
and to avoid the repeated fork+exec of the find ... -exec variation.
regards
az
…--
Alexander Zangerl + GPG Key 2FCCF66BB963BD5F + https://snafu.priv.at/
The correct way to roll NT out is out the door and into the nearest
dumpster or other large waste receptacle. -- Mike Andrews
|
Thanks, I'll have a look in detail later tonight (CET)! |
OK, I've spent a few hours skimming through the links you sent and reading the mdev source.
This The code has this comment: /*
* Make inital scan after the uevent socket is alive and
* _before_ we fork away. Already open mdev.log because we work
* in daemon mode.
*/ Clearly, they have designed We could run it as ... I honestly don't see a way around this that would be sustainable to maintain in Finit. So my suggestion is to keep things as-is in |
Here's a crazy idea, completely sidestepping BusyBox For a future relase, fork mdevd and integrate in Finit as an optional helper daemon. We could tailor the boot process more tightly around it ... the licenses are compatible and the code is not that big. Should be fairly straightforward and as I'm writing this I'm realizing this is how systemd swallowed up udevd 🤣 Regardless, still is a better idea than what we can do with |
On Mon, 16 Oct 2023 11:37:07 -0700, Joachim Wiberg writes:
2. No `/run/mdev.pid` is created, this would have solved a lot of problems for
...
3. We need some way of `echo add > /sys/devices/**/uevent`
personally i'm telling finit to generate a pidfile for mdev -d, followed by
a run stanza which depends on that mdev pidfile, which then performs the
echo-add-sequence.
the echo-add operation can proceed as soon as mdevd listens, and mdev -d sets up the socket
(with seriously fat receive buffer) before doing the initial scan: even if that scan were to take
a while, the big socket buffer ensures that no add uevents are lost until the initial scan is done
and mdev starts processing the uevents.
(the very few activities between entering mdev_main() and the socket setup
don't have any potential for undue delay.)
therefore i think that the pidfile timing versus readiness for uevent processing is not an issue.
but i do agree that lack of a discovery completion notification may not be sufficiently robust
for some (many?) situations.
So my suggestion is to keep things as-is in `system/10-hotplug.conf` (`mdev -s`) and add a huge comment
around that run stanza explaining the issue(s). We can also provide commented-out `mdev -df` and your
example coldplug >`add`.
i think that's sensible.
here is my suggestion for an commented mdev config stanza (but not disabled, and not conditional either):
---
# on startup, the mdev daemon only performs a cursory scan of
# already known devices and their device files, then sets itself up
# as a manager for future uevents.
#
# mdev doesn't create a pid file; this stanza instructs finit to generate one
service [S12345] pid:/run/mdev.pid mdev -df -- mdev daemon
# to perform device (re)discovery, module loading and setup, a coldplug
# operation is typically required.
#
# however, mdev does not offer any mechanism to detect when
# the discovery operation is complete: on slower systems the triggering
# side (the coldplug script) often completes quite a bit earlier than
# mdev's uevent processing.
# in other words: depending on <run/coldplug/success> is not necessarily
# an indicator of all devices having been (re)discovered and are now fully set up.
run [S] <service/mdev/ready> /sbin/coldplug -- mdev cold plug discovery run
---
and my /sbin/coldplug is just (which may or may not be safely inlineable in a finit conf)
---
#!/bin/busybox ash
find /sys/devices -name uevent -print | while IFS='' read X; do echo add > $X; done
---
…--
Alexander Zangerl + GPG Key 2FCCF66BB963BD5F + https://snafu.priv.at/
The idea is that RAID stands for Redundant Array of Inexpensive Dreck.
-- Anthony de Boer
|
On Mon, 16 Oct 2023 12:37:56 -0700, Joachim Wiberg writes:
For a future relase, fork mdevd and integrate in Finit as an optional
helper daemon. We could tailor the boot process more tightly around
it ... the licenses are compatible and the code is not that big.
i hear you :-)
and we would still need the extra band-aid with `echo add >
/sys/devices/**/uevent`.
not really: mdevd comes with mdevd-coldplug, and yesterday i saw
that they both have a synchronous/waiting mode where mdevd-coldplug
doesn't exit until mdevd is done; which would
make the perfect barrier for ensuring the discovery is complete.
the one downside of mdevd that i see (from an integration/packaging perspective)
is that it also requires skalibs as build- and run-dependency - or one would
have to recreate/reimplement missing bits using libite/libuev. the former
duplicates code, the latter duplicates work.
for me personally finit's main appeal is its streamlined behaviour and
compactness, and thus i'm not fully convinced that finit itself would
benefit greatly from encompassing mdevd; but to support it as an option in
10-hotplug would definitely be a good thing.
regards
az
…--
Alexander Zangerl + GPG Key 2FCCF66BB963BD5F + https://snafu.priv.at/
Syntactic sugar causes cancer of the semicolon. -- Alan Perlis
|
I'm not so sure it's a non-issue. I've tested on really slow embedded devices and I've seen "this shouldn't happen" too many times to let this one slide. Therefore I'll propose keeping
Yeah, without measuring/testing this I'd rather take the conservative route. In particular since I want to get this release out the door asap
Almost the same as my proposal, which I unfortunately have on my other computer 30 km away. Anyway, for this release I suggest we keep the
It runs the device probe twice, but leaves a guarantee that at least that which worked before still work now.
This is great, we can put that script in I'll add it like that, adding only the |
Riight, almost forgot about that! I should know, I helped integrate and test a preview of mdevd into Finit a year ago. It actually spawned the addition of both systemd and s6-style process synchronization!
It works for some use-cases I couldn't get it to work properly with Finit without some additional features:
It works, but it ain't pretty.
I've closely monitored s6, skalibs, and now latest mdevd for several years. For obvious reasons, s6 is a close competitor of Finit, but also because Laurent Bercot is a very nice guy. His code, however is very tight and in many cases hard to read. So I imagine integrating mdevd in Finit would mean stripping it down to its very core and cleaning it to better integrate with the utility functions in Finit and libite, I would not use skalibs for that. Effectively to the point of it no longer resembling the original, so it would not be called |
Ended up skipping |
since busybox release 1.31 (june 2019), mdev has been a much better udev-replacement and now does pretty much all that mdevd does:
starting it up as
mdev -d
makes it daemonise and listen on netlink, whereasmdev -df
does the same without forking. with those versions, no scan run withmdev -s
is required (or useful).mdev -d
doesn't have a pid file, though.i think that your new(ish) system/hotplug.conf could do with some small amendments to support such newer mdev capabilities, unless you think four years is too short a transition time for relying on new enough busyboxes.
The text was updated successfully, but these errors were encountered: