sysfs: add SR-IOV VF PCI address and NUMA node helpers for net interfaces#795
sysfs: add SR-IOV VF PCI address and NUMA node helpers for net interfaces#795aharivel wants to merge 1 commit into
Conversation
|
Why is this not part of |
|
@SuperQ I followed the precedent of You're right that net_class.go is the natural home. Both functions read attributes from the underlying PCI device of a net interface (device/numa_node, device/virtfn), which is exactly the kind of thing net_class.go already handles. I can move them there and drop net_class_sriov.go. That said — would you prefer they stay grouped together (e.g. with a comment marking them as SR-IOV related), or just inline them with the rest of the net class helpers? |
|
Hmm, looking into this a bit more. The |
|
Hmm ok cleaner approach — agreed. A For virtfnX resolution, I'd read those symlinks from the resolved PCI device path. |
Add two new functions to support SR-IOV network VF metrics collection: - NetClassPCIDevice(iface string) (*PciDevice, error) in net_class.go: Resolves /sys/class/net/<iface>/device symlink and returns the backing PciDevice using the existing PCI device parser. This gives callers access to all PCI device properties (NumaNode, link speed, SR-IOV fields, etc.). - PciDeviceVFAddress(device *PciDevice, vfIndex uint32) (string, error) in pci_device.go: Returns the PCI BDF address of a Virtual Function by resolving the virtfn symlink at /sys/bus/pci/devices/<bdf>/virtfn<n>. Test fixtures added under testdata/fixtures/sys/class/net/enp3s0f0/ using the existing 0000:a2:00.0 PCI device fixture. Signed-off-by: Anthony Harivel <aharivel@redhat.com>
|
@SuperQ Ok so I've reworked the patch in a way that takes your feedback into consideration. I've also tested this morning the end goal of this patch (e.g adding SR-IOV network Virtual Function statistics in node_exporter prometheus/node_exporter#3544 ) on my server with E810 nic and the result looks as expected (i.e PCI address are good, numa node are also good): |
|
Hi @SuperQ just a gentle ping on this PR, would you have a moment to take a look when you get a chance? Thanks! |
|
Hi @discordianfish |
|
Hi, is there anything I can do to help review this patch ? |
SuperQ
left a comment
There was a problem hiding this comment.
Looks good, small issue with the Go docs.
| @@ -97,6 +97,18 @@ func (fs FS) NetClassByIface(devicePath string) (*NetClassIface, error) { | |||
| } | |||
|
|
|||
| // NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>. | |||
There was a problem hiding this comment.
It looks like you've misplaced this doc comment. It needs to be attached to func (fs FS) NetClass() below.
Add two helpers to the sysfs package for SR-IOV Physical Function (PF) network interfaces:
NetClassVFPCIAddress(iface string, vfIndex uint32) (string, error)Resolves the PCI BDF address of a Virtual Function by reading the sysfs
virtfn symlink at
/sys/class/net/<iface>/device/virtfn<vfIndex>.Returns the BDF address e.g.
0000:65:01.0.NetClassNumaNode(iface string) (int, error)Returns the NUMA node of the PCI device backing the interface, read from
/sys/class/net/<iface>/device/numa_node.Returns -1 if the device is not NUMA-aware (kernel convention).
These are intended to support SR-IOV VF collectors (e.g. in node_exporter) that need to correlate VF traffic metrics with workloads referencing VFs by PCI address or NUMA topology (e.g. OpenStack Nova, libvirt, DPDK).
Test fixtures added under
testdata/fixtures/sys/class/net/enp3s0f0/.