Bug 219891 - xen SDL framebuffer uses busy polling loop
xen SDL framebuffer uses busy polling loop
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: xen (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Chris Lalancette
Depends On:
  Show dependency treegraph
Reported: 2006-12-15 18:41 EST by Stephen Tweedie
Modified: 2007-11-16 20:14 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-10-10 11:56:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to convert the sdlfb busy looping with a thread implementation (3.88 KB, patch)
2007-10-05 16:40 EDT, Chris Lalancette
no flags Details | Diff

  None (edit)
Description Stephen Tweedie 2006-12-15 18:41:14 EST
Description of problem:
From xen tools/xenfb/sdlfb.c:

+	/*
+	 * We need to wait for fds becoming ready or SDL events to
+	 * arrive.  We time out the select after 10ms to poll for SDL
+	 * events.  Clunky, but works.  Could avoid the clunkiness
+	 * with a separate thread.
+	 */
+	for (;;) {
+		FD_ZERO(&readfds);
+		nfds = xenfb_select_fds(xenfb, &readfds);
+		tv = (struct timeval){0, 10000};
+		if (select(nfds, &readfds, NULL, NULL, &tv) < 0) {
+			if (errno == EINTR)
+				continue;
+			fprintf(stderr,
+				"Can't select() on event channel (%s)\n",
+				strerror(errno));
+			break;
+		}
 		while (SDL_PollEvent(&event)) {

This leaves us polling things every 10ms, forever, even on idle guests.  It's
not too hard to create a helper thread to wait on non-selectable event sources,
and to pass events back via a pipe; longer term, we should make sure we fix
sdlfb in such a way.
Comment 2 RHEL Product and Program Management 2007-03-21 19:16:13 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
Comment 3 RHEL Product and Program Management 2007-09-07 15:57:51 EDT
This request was previously evaluated by Red Hat Product Management
for inclusion in the current Red Hat Enterprise Linux release, but
Red Hat was unable to resolve it in time.  This request will be
reviewed for a future Red Hat Enterprise Linux release.
Comment 4 Chris Lalancette 2007-10-05 16:40:12 EDT
Created attachment 217981 [details]
Patch to convert the sdlfb busy looping with a thread implementation

This is a patch to replace the busy loop in sdlfb with a thread and a pipe.  I
might have been a little pedantic on the locking in here; I wasn't quite sure
if xenfb could be changed by both threads at the same time, so I went very
cautiously and locked every time I accessed it.  I'll have to look into it a
little more, and possibly take some of the locking away (or remove it
altogether if I can convince myself the two threads don't change the same part
of the xenfb structure).

Chris Lalancette
Comment 5 Chris Lalancette 2007-10-10 11:56:46 EDT
The consensus on virtualist seems to be that this is not worth pursuing; few
customers are using SDL, even fewer would even notice the busy wait, and
upstream is going to be getting rid of sdlfb in favor of a merged Qemu solution.
 I'm going to close this as WONTFIX.

Chris Lalancette

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