libnvme: examples: fix select() usage in telemetry-listen - #3914
Merged
igaw merged 1 commit intoAug 26, 2026
Conversation
select() takes the highest watched fd plus one, not the number of watched fds. With stdio occupying 0-2, the uevent fds of 1-3 controllers sit above the count, so select(nr) never wakes on any of them - the listener's whole purpose silently dead for the common 1-3 controller case. Also select() clears inactive bits in the passed set: restore the watched set on a local copy each round (otherwise the first event permanently disables all other fds), skip the loop entirely when no controller was found (select(0,...) returns immediately, spinning at 100% CPU), and guard calloc(). Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
igaw
force-pushed
the
fix-telemetry-listen-select
branch
from
August 26, 2026 13:48
fe1fdbe to
76e5180
Compare
Collaborator
|
removed the libnvme 1 reference. |
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Port of linux-nvme/libnvme#1126 to libnvme3 (the example has the same misuse vector).
wait_events()passes the count of uevent fds toselect()asnfds; the argument is max-fd+1, and with stdio occupying 0-2 the uevent fds always start at 3, so for the common 1-3 controller case the watcher never wakes on any telemetry AEN. Additionally,select()clears inactive fds in the passed set, and the same set is reused — after the first event the loop only monitors fds that happened to be active. With no controller it spins at 100% CPU, andcalloc()isn't checked.Fix
Track maxfd while
FD_SETing; passmaxfd + 1toselect()on a re-armed local copy of the set; skip the wait loop when no controller was found; checkcalloc().Testing