-
Notifications
You must be signed in to change notification settings - Fork 184
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
snapshot: gather full pci tree, handling bridges #224
Conversation
Ready for design review; docstrings are missing, and I need to review unit tests. hence the WIP. Conflicts with #223 |
3d6ae01
to
bf5afbd
Compare
We want to expose the NUMA locality of the PCI devices, much like we already do for GPU devices. This is very important for high-end, high-performance devices (NICs, storage controllers). To enable testing, we update the snapshot with another one captured with more PCI device informations. See: jaypipes#224 Signed-off-by: Francesco Romani <[email protected]>
bf5afbd
to
1a91be6
Compare
aba6ca6
to
7ec16bd
Compare
We want to expose the NUMA locality of the PCI devices, much like we already do for GPU devices. This is very important for high-end, high-performance devices (NICs, storage controllers). To enable testing, we update the snapshot with another one captured with more PCI device informations. See: jaypipes#224 Signed-off-by: Francesco Romani <[email protected]>
7ec16bd
to
1779337
Compare
clarified (again) the commit message |
still not completely happy. Let me evaluate another approach, will update ASAP. |
1779337
to
9b19ce6
Compare
I'm still testing 9b19ce6 and I'm happier with this approach so far. |
fa85ffd
to
f08ab4b
Compare
We want to expose the NUMA locality of the PCI devices, much like we already do for GPU devices. This is very important for high-end, high-performance devices (NICs, storage controllers). To enable testing, we update the snapshot with another one captured with more PCI device informations. See: jaypipes#224 Signed-off-by: Francesco Romani <[email protected]>
f08ab4b
to
7a30a06
Compare
rebased on top of #227 . I think this PR is now good enough. |
7a30a06
to
341af48
Compare
rebased again. No code changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, @fromanirh. Just one little request inline to return an error from findPCIEntryFromPath
, otherwise this is awesome.
In order to maximize the code reuse, we move the code which handles PCI addresses to its own subpackage. This is driven by a upcoming patch, which wants to parse PCI addresses from strings, without consuming the pci package, to avoid circular imports. Only trivial code movement + needed renames e.g.: AddressFromString() -> address.FromString() Signed-off-by: Francesco Romani <[email protected]>
let's add Warn()ings when PCI scan fails, to improve the troubleshooting process. Signed-off-by: Francesco Romani <[email protected]>
Modern (x86_64) systems have multiple PCI buses. For ghw needs, considering the abstraction provided by the linux kernel, there is no practical difference from PCI-express and PCI to date, so we will call them all "PCI". PCI-to-PCI (see initial note about PCI express) are common, and their topology depends on the CPU, mainboard and system manufacturer choice. The linux kernel does not flatten the PCI tree in sysfs. This choice provides the closest representation to reality, and unfortunately is also easy to overlook when exploring simple PCI device trees, such as ones found on laptops, but becomes evident when exploring more complex trees, like the ones we can see on servers, even low end. This means, in case of PCI bridges, we will have entries inside the directory which represent a bus which will be both devices and root of subtrees. In other words, these entries will contain BOTH subdirectories to represent the devices attached to that bridge, and the files which describe the bridge device per se. For ghw, the net effect is we cannot just scan the entries in `/sys/bus/pci/devices` and be done with it; we need to detect the entries which represent PCI bridges, and scan those recursively. Otherwise, we miss to gather the data pertaining to these devices. So we need a smarter function that does this traversal, moving away from the nice static list of paths we previously had. Without this patch (example taken from dev laptop): {host bridge} -[0000:00]-+-00.0 +-02.0 +-14.0 +-14.2 +-16.0 +-16.3 +-1c.0 {PCI bridge} +-1c.2 {PCI bridge} +-1d.0 {PCI bridge} +-1f.0 +-1f.2 +-1f.3 +-1f.4 \-1f.6 With this patch (example taken from dev laptop): {host bridge} -[0000:00]-+-00.0 +-02.0 +-14.0 +-14.2 +-16.0 +-16.3 +-1c.0 | -+-3a {PCI bridge} \-00.0 ** PREVIOUSLY NOT DETECTED! +-1c.2 | -+-3c {PCI bridge} \-00.0 ** PREVIOUSLY NOT DETECTED! +-1d.0 {PCI bridge - no devices here} +-1f.0 +-1f.2 +-1f.3 +-1f.4 \-1f.6 Signed-off-by: Francesco Romani <[email protected]>
341af48
to
1f10653
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @fromanirh! :)
the current implementation of the PCI device snapshot only scans the first level in the PCI tree (actually, PCI forest). Anything attached to bridges is ignored. This was unintended, and this PR aims to fix it acknowledging bridges explictely and handling them correctly. In practices, this means to scan also the devices attached to each bridge, recursively.
Note this affects only the snapshotting code.