Bug 202991 - On change of sriov_numvfs, netlink message is sent before the new value is available in /sys
Summary: On change of sriov_numvfs, netlink message is sent before the new value is av...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: PCI (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_pci@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-21 16:35 UTC by pierre.cregut
Modified: 2019-03-26 10:11 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.0.3 (all)
Tree: Mainline
Regression: No


Attachments
Shell script to monitor netlink and read sriov_numvfs (212 bytes, application/x-shellscript)
2019-03-21 16:35 UTC, pierre.cregut
Details
Proposed patch that sets num_VFs earlier. (818 bytes, patch)
2019-03-21 17:09 UTC, pierre.cregut
Details | Diff

Description pierre.cregut 2019-03-21 16:35:12 UTC
Created attachment 281953 [details]
Shell script to monitor netlink and read sriov_numvfs

I would like to monitor the number of VFs for an sr-iov card.
When sriov_numvfs is changed, a netlink message is sent. Unfortunately reading the value on sriov_numvfs just after receiving the message always give the value 0. As a result the netlink message is almost useless for monitoring.

The shell script in attachment can be used to monitor an interface (DEVICE). Changing alternatively sriov_numvfs will make a 0 be written down whatever the value used.

One solution may be to set iov->num_VFs just before each call to pci_iov_set_numvfs in sriov_enable (iov.c), on the normal path to nr_virtfn and to 0 on the error path.
Comment 1 pierre.cregut 2019-03-21 17:09:06 UTC
Created attachment 281955 [details]
Proposed patch that sets num_VFs earlier.
Comment 2 Bjorn Helgaas 2019-03-21 18:30:43 UTC
Thanks for the report and for the patch!  Can you please fix the whitespace issue (add spaces around "="), add a changelog (include the URL of this bug report), and post it to linux-pci@vger.kernel.com.

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst has the basics of the process.  You can also run "git log drivers/pci/iov.c" to see the usual style.

Thanks again!
Comment 3 pierre.cregut 2019-03-26 10:11:03 UTC
patch has been posted to the list.

Note You need to log in before you can comment on or make changes to this bug.