Skip to content
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

Use 1 select() call and let it block #20

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

jandryuk
Copy link
Contributor

vusb-daemon spends a lot of time looping since it has two separate
select calls with short timeouts. Unify the two select calls and let it
block to avoid needless CPU usage.

xcdbus_pre_select is written to add to in-use fd_sets and nfds, so use
that feature. xcdbus_post_select will loop over its registered watches
checking for if the corresponding FD is set, so an extra FD in readfds
is fine. udevfd can then be checked for events as is done currently.

Signed-off-by: Jason Andryuk jandryuk@gmail.com

I haven't actually tested USB pass through with this change. Drivers from the ais build server seem to install in Windows, but I don't see a OpenXT USB Controller in device manager. The other PV drivers are running though.

Looking at strace after the change, the daemon seems to be reacting just fine.

vusb-daemon spends a lot of time looping since it has two separate
select calls with short timeouts.  Unify the two select calls and let it
block to avoid needless CPU usage.

xcdbus_pre_select is written to add to in-use fd_sets and nfds, so use
that feature.  xcdbus_post_select will loop over its registered watches
checking for if the corresponding FD is set, so an extra FD in readfds
is fine.  udevfd can then be checked for events as is done currently.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
@jean-edouard
Copy link
Member

Nice, I didn't realize xcdbus could do that!
However, please test this with at least a couple guests and USB devices.
It is expected to not see any USB controller device in Windows as long as it doesn't have any USB device assigned to it.
IIRC, one controller device gets created for each USB device.

@jandryuk
Copy link
Contributor Author

Oh, thanks for the pointer about the USB controller. The drivers from https://openxt.ainfosec.com/builds/windows/master/412/ didn't seem to work - assigning a USB device promptly reverted to unassigned. Drivers from https://openxt.ainfosec.com/builds/regular/master/1773/repository/packages.main/ didn't show a controller, so I didn't try assigning :(

Assigning a flash drive works. I'll try out a few more.

@jandryuk
Copy link
Contributor Author

Device assignment and reassignment seems to be working.

@jean-edouard
Copy link
Member

@jean-edouard
Copy link
Member

LGTM, merging soon.

@jean-edouard jean-edouard merged commit 099ce18 into OpenXT:master Nov 13, 2018
@jandryuk jandryuk deleted the blocking-select branch November 26, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants