Bug 219891

Summary: xen SDL framebuffer uses busy polling loop
Product: Red Hat Enterprise Linux 5 Reporter: Stephen Tweedie <sct>
Component: xenAssignee: Chris Lalancette <clalance>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.1CC: xen-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-10 15:56:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to convert the sdlfb busy looping with a thread implementation none

Description Stephen Tweedie 2006-12-15 23:41:14 UTC
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 Program Management 2007-03-21 23:16:13 UTC
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
release.

Comment 3 RHEL Program Management 2007-09-07 19:57:51 UTC
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 20:40:12 UTC
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 15:56:46 UTC
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