[systemd-devel] udev interface naming for SR-IOV VFs

Nir Soffer nirsof at gmail.com
Fri Apr 17 04:19:09 PDT 2015


On Tue, Apr 14, 2015 at 1:11 PM, Ido Barkan <ibarkan at redhat.com> wrote:
> We are implementing support for SR-IOV network cards. Afer the changing of
> the number of VFs on the card and programmatically querying for all links
> (we use libnl for this) we observe that *during the iteration* over the links
> some of them were renamed by udev and still were not. Meanning, some of them
> are called 'ethN' and some are called 'enp2sNf2' (where N is an arbitrary
> number). Also, there are times that not all of the devices are returned from
> libnl.
> After a _while_ everything stabilizes (# of interfaces and names).
>
> My questions:
> 1. Is this what you would expect from udev? Meaning, this is just
>    async behavior?

Generally yes. You can investigate that by monitoring udev events.

One way is to use udevadm monitor:

1. Start the monitor:

    udevadm monitor --udev --property

2. Configure the SR-IOV card

3. Watch the events - you can use the timestamp to tell how much time it
   took until the new interfaces are ready.

Another way is to turn on debug level, and watch the system log.

1. Set log level to debug:

    udevadm control --log-priority=debug

2. Start to watch the log in another shell

    journalctl -f

3. Setup the SR-IOV card

> 2. Is there a way to _know_ programmticaly that everything was probed
>    and renamed?  Not a heuristic?

Using udevadm settle, you can wait until the current events are handled,
but there are some issues:

- You don't know when events from the kernel are starting - while you
  wait for the SR-IOV modification (e.g, write to sysfs attribute), or
  after a while, and if all of them are triggered one after another, or
  after some delay. So udevadm settle may return before the devices are
  ready.

- It may be possible that one event will synthesize another event, so
  udev settle may return just before another event is triggered.

- You may wait for unrelated events that happen to trigger in the same
  time, waiting after the new interfaces are ready.

I think you need something like:

    while True:
        try:
            udevadm.settle(1)
        except udevadm.Timeout:
            pass
        else:
            if all devices are ready:
                break
            time.sleep(1)

Note that it is not possible to detect a timeout in udevadm settle,
see http://lists.freedesktop.org/archives/systemd-devel/2015-April/030391.html

Nir


More information about the systemd-devel mailing list