Re: [PATCH v5 00/13] PRIME Synchronization
On 20 May 2016 at 08:36, Alex Goinswrote: > Hi Dave, > > Any update on this? Anything I can do to help? Hey, can you take a look at prime: clean up slave bo properly. (v3) I think with this rebased onto that, we should be pretty much good to merge. Dave. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH RESEND xserver v3] xfree86: Immediately handle failure to set HW cursor
Friendly ping, as it would be very nice to see this merged! On Fri, May 13, 2016 at 7:36 PM, Alexandre Courbotwrote: > On 05/13/2016 01:04 AM, Adam Jackson wrote: >> >> On Thu, 2016-05-12 at 16:04 +0900, Alexandre Courbot wrote: >>> >>> There is currently no reliable way to report failure to set a HW >>> cursor. Still such failures can happen if e.g. the MODE_CURSOR DRM >>> ioctl fails (which currently happens at least with modesetting on Tegra >>> for format incompatibility reasons). >>> >>> As failures are currently handled by setting the HW cursor size to >>> (0,0), the fallback to SW cursor will not happen until the next time the >>> cursor changes and xf86CursorSetCursor() is called again. In the >>> meantime, the cursor will be invisible to the user. >>> >>> This patch addresses that by adding _xf86CrtcFuncs::set_cursor_check and >>> _xf86CursorInfoRec::ShowCursorCheck hook variants that return booleans. >>> This allows to propagate errors up to xf86CursorSetCursor(), which can >>> then fall back to using the SW cursor immediately. >>> >>> Signed-off-by: Alexandre Courbot >>> Cc: Michael Thayer >>> --- >>> Hoping to see this patch go through - all issues in the previous versions >>> have been addressed, and the logic it introduces seems saner than setting >>> the cursor size to (0, 0). >> >> >> How are external drivers to know whether .set_cursor_check is available >> at compile time? ABI_VIDEODRV_VERSION > 21.0 ? (That's a fine answer, >> just want to make sure it's explicit.) > > > Yes, that's probably how it should be done - should I add a comment > somewhere in the code to specify the minimum ABI version? I haven't found > any such comment for other _check variants though. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver] randr: Adjust master's last set time with slaves
In prime configurations master's last set time may not be latest and greatest, adjust it with slaves last set time, pick up greatest one. Otherwise xserver may end with events which has lastSetTime < lastConfigTime even if that's not the case and confuse xrandr client. Signed-off-by: Nikhil Mahale--- randr/randr.c | 9 + 1 file changed, 9 insertions(+) diff --git a/randr/randr.c b/randr/randr.c index 3aabb19..549f26c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -584,6 +584,15 @@ RRTellChanged(ScreenPtr pScreen) mastersp = pScrPriv; } +xorg_list_for_each_entry(iter, >output_slave_list, output_head) { +pSlaveScrPriv = rrGetScrPriv(iter); + +if (CompareTimeStamps(mastersp->lastSetTime, + pSlaveScrPriv->lastSetTime) == EARLIER) { +mastersp->lastSetTime = pSlaveScrPriv->lastSetTime; +} +} + if (mastersp->changed) { UpdateCurrentTimeIf(); if (mastersp->configChanged) { -- 2.8.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] randr: Adjust master's last set time with slaves
On 05/27/2016 01:40 AM, Hans de Goede wrote: Hi, On 26-05-16 18:20, Nikhil Mahale wrote: In prime configurations master's last set time may not be latest and greatest, adjust it with slaves last set time, pick up greatest one. Otherwise xserver may end with events which has lastSetTime < lastConfigTime even if that's not the case and confuse xrandr client. Thanks, looks good to me now: Acked-by: Hans de GoedeSorry, I did forgot to add signoff line. Please let me add signoff line in commit msg. Regards, Hans --- randr/randr.c | 9 + 1 file changed, 9 insertions(+) diff --git a/randr/randr.c b/randr/randr.c index 3aabb19..549f26c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -584,6 +584,15 @@ RRTellChanged(ScreenPtr pScreen) mastersp = pScrPriv; } +xorg_list_for_each_entry(iter, >output_slave_list, output_head) { +pSlaveScrPriv = rrGetScrPriv(iter); + +if (CompareTimeStamps(mastersp->lastSetTime, + pSlaveScrPriv->lastSetTime) == EARLIER) { +mastersp->lastSetTime = pSlaveScrPriv->lastSetTime; +} +} + if (mastersp->changed) { UpdateCurrentTimeIf(); if (mastersp->configChanged) { ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 20/23] os: Use poll(2) for input thread
Replace use of select(2) to avoid fd limits Signed-off-by: Keith Packard--- os/inputthread.c | 85 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/os/inputthread.c b/os/inputthread.c index b6bbf35..3d8e6da 100644 --- a/os/inputthread.c +++ b/os/inputthread.c @@ -35,7 +35,6 @@ #include #include -#include #include "inputstr.h" #include "opaque.h" #include "osdep.h" @@ -62,7 +61,7 @@ typedef struct _InputThreadDevice { typedef struct { pthread_t thread; struct xorg_list devs; -fd_set fds; +struct ospoll *fds; int readPipe; int writePipe; } InputThreadInfo; @@ -126,9 +125,10 @@ InputThreadFillPipe(int writeHead) { int ret; char byte = 0; -fd_set writePipe; +struct pollfd poll_fd; -FD_ZERO(); +poll_fd.fd = writeHead; +poll_fd.events = POLLOUT; while (1) { ret = write(writeHead, , 1); @@ -141,8 +141,7 @@ InputThreadFillPipe(int writeHead) FatalError("input-thread: filling pipe"); DebugF("input-thread: pipe full\n"); -FD_SET(writeHead, ); -Select(writeHead + 1, NULL, , NULL, NULL); +poll(_fd, 1, -1); } } @@ -167,6 +166,18 @@ InputThreadReadPipe(int readHead) return 1; } +static void +InputReady(int fd, short revents, void *data) +{ +InputThreadDevice *dev = data; + +if (revents & POLLIN) { +input_lock(); +dev->readInputProc(fd, X_NOTIFY_READ, dev->readInputArgs); +input_unlock(); +} +} + /** * Register an input device in the threaded input facility * @@ -198,7 +209,11 @@ InputThreadRegisterDev(int fd, xorg_list_add(>node, >devs); -FD_SET(fd, >fds); +ospoll_add(inputThreadInfo->fds, fd, + ospoll_trigger_level, + InputReady, + dev); +ospoll_listen(inputThreadInfo->fds, fd, POLLIN); InputThreadFillPipe(hotplugPipeWrite); DebugF("input-thread: registered device %d\n", fd); @@ -239,7 +254,7 @@ InputThreadUnregisterDev(int fd) xorg_list_del(>node); -FD_CLR(fd, >fds); +ospoll_remove(inputThreadInfo->fds, fd); free(dev); InputThreadFillPipe(hotplugPipeWrite); @@ -248,6 +263,16 @@ InputThreadUnregisterDev(int fd) return 1; } +static void +InputThreadPipeNotify(int fd, short revents, void *data) +{ +/* Empty pending input, shut down if the pipe has been closed */ +if (InputThreadReadPipe(hotplugPipeRead) == 0) { +Bool*running = data; +*running = FALSE; +} +} + /** * The workhorse of threaded input event generation. * @@ -265,51 +290,36 @@ InputThreadUnregisterDev(int fd) static void* InputThreadDoWork(void *arg) { -fd_set readyFds; -InputThreadDevice *dev, *next; +Boolrunning = TRUE; sigset_t set; /* Don't handle any signals on this thread */ sigfillset(); pthread_sigmask(SIG_BLOCK, , NULL); -FD_ZERO(); +ospoll_add(inputThreadInfo->fds, hotplugPipeRead, + ospoll_trigger_level, + InputThreadPipeNotify, + ); -while (1) +while (running) { -XFD_COPYSET(>fds, ); -FD_SET(hotplugPipeRead, ); - DebugF("input-thread: %s waiting for devices\n", __func__); -if (Select(MAXSELECT, , NULL, NULL, NULL) < 0) { +if (ospoll_wait(inputThreadInfo->fds, -1) < 0) { if (errno == EINVAL) FatalError("input-thread: %s (%s)", __func__, strerror(errno)); else if (errno != EINTR) ErrorF("input-thread: %s (%s)\n", __func__, strerror(errno)); } -DebugF("input-thread: %s generating events\n", __func__); - -/* Call the device drivers to generate input events for us */ -xorg_list_for_each_entry_safe(dev, next, >devs, node) { -if (FD_ISSET(dev->fd, ) && dev->readInputProc) { -input_lock(); -dev->readInputProc(dev->fd, X_NOTIFY_READ, dev->readInputArgs); -input_unlock(); -} -} - /* Kick main thread to process the generated input events and drain * events from hotplug pipe */ InputThreadFillPipe(inputThreadInfo->writePipe); - -/* Empty pending input, shut down if the pipe has been closed */ -if (FD_ISSET(hotplugPipeRead, )) { -if (InputThreadReadPipe(hotplugPipeRead) == 0) -break; -} } + +ospoll_remove(inputThreadInfo->fds, hotplugPipeRead); + return NULL; } @@ -343,7 +353,7 @@ InputThreadPreInit(void) inputThreadInfo->thread = 0; xorg_list_init(>devs); -FD_ZERO(>fds); +inputThreadInfo->fds = ospoll_create(); /* By making read head non-blocking, we ensure that while the main thread * is busy servicing client requests, the dedicated input thread can work @@ -351,7 +361,6
[PATCH xserver 17/23] os: Add ospoll interface
This provides a wrapper around poll, epoll or WSAPoll providing a callback-based interface for monitoring activity on a large set of file descriptors. Signed-off-by: Keith Packard--- configure.ac| 2 +- include/dix-config.h.in | 9 + os/Makefile.am | 1 + os/ospoll.c | 439 os/ospoll.h | 144 5 files changed, 594 insertions(+), 1 deletion(-) create mode 100644 os/ospoll.c create mode 100644 os/ospoll.h diff --git a/configure.ac b/configure.ac index 1a9aa81..d078190 100644 --- a/configure.ac +++ b/configure.ac @@ -219,7 +219,7 @@ dnl Checks for library functions. AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \ getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \ mmap posix_fallocate seteuid shmctl64 strncasecmp vasprintf vsnprintf \ - walkcontext setitimer]) + walkcontext setitimer poll epoll_create1 WSAPoll]) AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup]) AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include ]]) diff --git a/include/dix-config.h.in b/include/dix-config.h.in index fc7d1a1..11025e0 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -527,4 +527,13 @@ /* Use input thread */ #undef INPUTTHREAD +/* Have poll() */ +#undef HAVE_POLL + +/* Have epoll_create1() */ +#undef HAVE_EPOLL_CREATE1 + +/* Have WSAPoll() */ +#undef HAVE_WSAPOLL + #endif /* _DIX_CONFIG_H_ */ diff --git a/os/Makefile.am b/os/Makefile.am index fc49a73..6835142 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -20,6 +20,7 @@ libos_la_SOURCES =\ oscolor.c \ osdep.h \ osinit.c\ + ospoll.c\ utils.c \ xdmauth.c \ xsha1.c \ diff --git a/os/ospoll.c b/os/ospoll.c new file mode 100644 index 000..c3e8d5b --- /dev/null +++ b/os/ospoll.c @@ -0,0 +1,439 @@ +/* + * Copyright © 2016 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "misc.h" /* for typedef of pointer */ +#include "ospoll.h" +#include "list.h" + +#if !HAVE_OSPOLL && HAVE_EPOLL_CREATE1 +#define EPOLL 1 +#define HAVE_OSPOLL 1 +#endif + +#if !HAVE_OSPOLL && HAVE_POLL +#define POLL1 +#define HAVE_OSPOLL 1 +#endif + +#if !HAVE_OSPOLL && HAVE_WSAPOLL +#define WSAPOLL 1 +#define HAVE_OSPOLL 1 +#endif + +#if EPOLL +#include + +/* epoll-based implementation */ +struct ospollfd { +int fd; +short events; +enum ospoll_trigger trigger; +void(*callback)(int fd, short revents, void *data); +void*data; +}; + +struct ospoll { +int epoll_fd; +struct ospollfd **fds; +int num; +int size; +}; + +#endif + +#if WSAPOLL +/* WSAPoll is just like poll, but with a different name (for reasons) */ +#include +#define POLL1 +#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout) +#endif + +#if POLL + +/* poll-based implementation */ +struct ospollfd { +short revents; +enum ospoll_trigger trigger; +void(*callback)(int fd, short revents, void *data); +void*data; +}; + +struct ospoll { +struct pollfd *fds; +struct ospollfd *osfds; +int num; +int size; +}; + +#endif + +/* Binary search for the specified file descriptor + * + * Returns position if found + * Returns -position - 1 if not found + */ + +static int +ospoll_find(struct ospoll *ospoll, int fd) +{ +int
[PATCH xserver 22/23] Allow 1024 and 2048 for LimitClients
There's no reason not to offer ridiculous numbers of clients; only a few static data structures are arrays of this length. Signed-off-by: Keith Packard--- include/misc.h | 2 +- os/utils.c | 6 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/misc.h b/include/misc.h index 006f768..01747fd 100644 --- a/include/misc.h +++ b/include/misc.h @@ -87,7 +87,7 @@ OF THIS SOFTWARE. #ifndef MAXGPUSCREENS #define MAXGPUSCREENS 16 #endif -#define MAXCLIENTS 512 +#define MAXCLIENTS 2048 #define LIMITCLIENTS 256 /* Must be a power of 2 and <= MAXCLIENTS */ #define MAXEXTENSIONS 128 #define MAXFORMATS 8 diff --git a/os/utils.c b/os/utils.c index 4507c9e..325e435 100644 --- a/os/utils.c +++ b/os/utils.c @@ -847,8 +847,10 @@ ProcessCommandLine(int argc, char *argv[]) if (LimitClients != 64 && LimitClients != 128 && LimitClients != 256 && - LimitClients != 512) { - FatalError("maxclients must be one of 64, 128, 256 or 512\n"); + LimitClients != 512 && +LimitClients != 1024 && +LimitClients != 2048) { + FatalError("maxclients must be one of 64, 128, 256, 512, 1024 or 2048\n"); } } else UseMsg(); -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 15/23] dix: Intermediate GrabServer state 'GrabKickout' not needed
The intermediate grabState, "GrabKickout", was used to trigger dispatch into going back to WaitForSomething after doing a GrabServer so that the set of ready clients would be recomputed to match what the server should be processing. As we only process one client per WaitForSomething call, we will always hit WaitForSomething after finishing the current client, and so don't need any special case here. Signed-off-by: Keith Packard--- dix/dispatch.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index f005983..3237883 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -151,7 +151,6 @@ static ClientPtr grabClient; #define GrabNone 0 #define GrabActive 1 -#define GrabKickout 2 static int grabState = GrabNone; static long grabWaiters[mskcnt]; CallbackListPtr ServerGrabCallback = NULL; @@ -375,11 +374,6 @@ Dispatch(void) /* KillClient can cause this to happen */ continue; } -/* GrabServer activation can cause this to be true */ -if (grabState == GrabKickout) { -grabState = GrabActive; -break; -} isItTimeToYield = FALSE; start_tick = SmartScheduleTime; @@ -1060,7 +1054,7 @@ ProcGrabServer(ClientPtr client) rc = OnlyListenToOneClient(client); if (rc != Success) return rc; -grabState = GrabKickout; +grabState = GrabActive; grabClient = client; if (ServerGrabCallback) { -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 10/23] dmx: Eliminate use of AddEnabledDevice
Use SetNotifyFd instead, with the hope that someday someone will come fix this to be more efficient -- right now, the wakeup handler is doing the event reading, instead of the notify callback. Signed-off-by: Keith Packard--- hw/dmx/input/dmxcommon.c | 17 + hw/dmx/input/dmxsigio.c | 9 +++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c index 90154ef..c7aed68 100644 --- a/hw/dmx/input/dmxcommon.c +++ b/hw/dmx/input/dmxcommon.c @@ -480,17 +480,26 @@ dmxCommonXSelect(DMXScreenInfo * dmxScreen, void *closure) return NULL; } +static void +dmxCommonFdNotify(int fd, int ready, void *data) +{ +/* This should process input on this fd, but instead all + * of that is delayed until the block and wakeup handlers are called + */ +; +} + static void * dmxCommonAddEnabledDevice(DMXScreenInfo * dmxScreen, void *closure) { -AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay)); +SetNotifyFd(XConnectionNumber(dmxScreen->beDisplay), dmxCommonFdNotify, X_NOTIFY_READ, closure); return NULL; } static void * dmxCommonRemoveEnabledDevice(DMXScreenInfo * dmxScreen, void *closure) { -RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay)); +RemoveNotifyFd(XConnectionNumber(dmxScreen->beDisplay)); return NULL; } @@ -504,7 +513,7 @@ dmxCommonMouOn(DevicePtr pDev) priv->eventMask |= DMX_POINTER_EVENT_MASK; if (!priv->be) { XSelectInput(priv->display, priv->window, priv->eventMask); -AddEnabledDevice(XConnectionNumber(priv->display)); +SetNotifyFd(XConnectionNumber(priv->display), dmxCommonFdNotify,X_NOTIFY_READ, pDev); } else { dmxPropertyIterate(priv->be, dmxCommonXSelect, priv); @@ -523,7 +532,7 @@ dmxCommonMouOff(DevicePtr pDev) priv->eventMask &= ~DMX_POINTER_EVENT_MASK; if (!priv->be) { -RemoveEnabledDevice(XConnectionNumber(priv->display)); +RemoveNotifyFd(XConnectionNumber(priv->display)); XSelectInput(priv->display, priv->window, priv->eventMask); } else { diff --git a/hw/dmx/input/dmxsigio.c b/hw/dmx/input/dmxsigio.c index ebfd3d9..1fec12b 100644 --- a/hw/dmx/input/dmxsigio.c +++ b/hw/dmx/input/dmxsigio.c @@ -114,6 +114,11 @@ dmxSigioUnhook(void) } static void +dmxSigioFdNotify(int fd, int ready, void *data) +{ +} + +static void dmxSigioAdd(DMXInputInfo * dmxInput) { int flags; @@ -138,7 +143,7 @@ dmxSigioAdd(DMXInputInfo * dmxInput) flags |= O_ASYNC | O_NONBLOCK; fcntl(fd, F_SETFL, flags); -AddEnabledDevice(fd); +SetNotifyFd(fd, dmxSigioFdNotify, X_NOTIFY_READ, NULL); dmxInput->sigioAdded[i] = TRUE; if (++dmxFdCount == 1) @@ -168,7 +173,7 @@ dmxSigioRemove(DMXInputInfo * dmxInput) int fd = dmxInput->sigioFd[i]; dmxInput->sigioAdded[i] = FALSE; -RemoveEnabledDevice(fd); +RemoveNotifyFd(fd); flags = fcntl(fd, F_GETFL); flags &= ~(O_ASYNC | O_NONBLOCK); -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 21/23] os: eliminate fd value limits for clients
With no code depending on the range of file descriptors, checking for that can be eliminated. Signed-off-by: Keith Packard--- os/connection.c | 81 - os/osdep.h | 43 +- 2 files changed, 23 insertions(+), 101 deletions(-) diff --git a/os/connection.c b/os/connection.c index 1ae50b1..24ad109 100644 --- a/os/connection.c +++ b/os/connection.c @@ -103,7 +103,6 @@ SOFTWARE. #endif /* WIN32 */ #include "misc.h" /* for typedef of pointer */ #include "osdep.h" -#include #include "opaque.h" #include "dixstruct.h" #include "xace.h" @@ -119,7 +118,6 @@ SOFTWARE. #include "probes.h" -static int lastfdesc; /* maximum file descriptor */ struct ospoll *server_poll; int MaxClients = 0; @@ -133,8 +131,6 @@ static char dynamic_display[7]; /* display name */ Bool PartialNetwork;/* continue even if unable to bind all addrs */ static Pid_t ParentProcess; -static Bool debug_conns = FALSE; - int GrabInProgress = 0; static void @@ -148,19 +144,15 @@ set_poll_clients(void); #if !defined(WIN32) int *ConnectionTranslation = NULL; +int ConnectionTranslationSize = 0; #else /* - * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is + * On NT fds are not small integers, they are unrelated, and there is * not even a known maximum value, so use something quite arbitrary for now. * Do storage is a hash table of size 256. Collisions are handled in a linked * list. */ -#undef MAXSOCKS -#define MAXSOCKS 512 -#undef MAXSELECT -#define MAXSELECT 512 - struct _ct_node { struct _ct_node *next; int key; @@ -265,47 +257,17 @@ lookup_trans_conn(int fd) void InitConnectionLimits(void) { -lastfdesc = -1; - -#ifndef __CYGWIN__ - -#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX) -lastfdesc = sysconf(_SC_OPEN_MAX) - 1; -#endif - -#ifdef HAVE_GETDTABLESIZE -if (lastfdesc < 0) -lastfdesc = getdtablesize() - 1; -#endif - -#ifdef _NFILE -if (lastfdesc < 0) -lastfdesc = _NFILE - 1; -#endif - -#endif /* __CYGWIN__ */ - -/* This is the fallback */ -if (lastfdesc < 0) -lastfdesc = MAXSOCKS; - -if (lastfdesc > MAXSELECT) -lastfdesc = MAXSELECT; - -if (lastfdesc > MAXCLIENTS) { -lastfdesc = MAXCLIENTS; -if (debug_conns) -ErrorF("REACHED MAXIMUM CLIENTS LIMIT %d\n", LimitClients); -} -MaxClients = lastfdesc; +MaxClients = MAXCLIENTS; #ifdef DEBUG ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients); #endif #if !defined(WIN32) -if (!ConnectionTranslation) -ConnectionTranslation = xnfallocarray(lastfdesc + 1, sizeof(int)); +if (!ConnectionTranslation) { +ConnectionTranslation = xnfallocarray(MaxClients, sizeof(int)); +ConnectionTranslationSize = MaxClients; +} #else InitConnectionTranslation(); #endif @@ -388,7 +350,7 @@ CreateWellKnownSockets(void) FatalError("failed to allocate poll structure"); #if !defined(WIN32) -for (i = 0; i < MaxClients; i++) +for (i = 0; i < ConnectionTranslationSize; i++) ConnectionTranslation[i] = 0; #else ClearConnectionTranslation(); @@ -762,14 +724,6 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time) OsCommPtr oc; ClientPtr client; -if ( -#ifndef WIN32 - fd >= lastfdesc -#else - XFD_SETCOUNT() >= MaxClients -#endif -) -return NullClient; oc = malloc(sizeof(OsCommRec)); if (!oc) return NullClient; @@ -786,6 +740,10 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time) } client->local = ComputeLocalClient(client); #if !defined(WIN32) +if (fd >= ConnectionTranslationSize) { +ConnectionTranslationSize *= 2; +ConnectionTranslation = xnfreallocarray(ConnectionTranslation, ConnectionTranslationSize, sizeof (int)); +} ConnectionTranslation[fd] = client->index; #else SetConnectionTranslation(fd, client->index); @@ -825,6 +783,7 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure) OsCommPtr oc; XtransConnInfo trans_conn, new_trans_conn; int status; +int clientid; connect_time = GetTimeInMillis(); /* kill off stragglers */ @@ -846,17 +805,9 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure) newconn = _XSERVTransGetConnectionNumber(new_trans_conn); -if (newconn < lastfdesc) { -int clientid; - -#if !defined(WIN32) -clientid = ConnectionTranslation[newconn]; -#else -clientid = GetConnectionTranslation(newconn); -#endif -if (clientid && (client = clients[clientid])) -CloseDownClient(client); -} +clientid = GetConnectionTranslation(newconn); +if (clientid && (client = clients[clientid]))
[PATCH xserver 19/23] os: Switch server to poll(2)
Eliminates all of the fd_set mangling in the server main thread Signed-off-by: Keith Packard--- dix/dispatch.c | 4 + include/dixstruct.h | 25 os/WaitFor.c| 157 +++-- os/connection.c | 333 os/io.c | 101 +++- os/osdep.h | 29 ++--- os/osinit.c | 1 - os/xdmcp.c | 1 - 8 files changed, 223 insertions(+), 428 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index a61d7a4..51e586f 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -242,12 +242,14 @@ void Dispatch(void); static struct xorg_list ready_clients; static struct xorg_list saved_ready_clients; +struct xorg_list output_pending_clients; static void init_client_ready(void) { xorg_list_init(_clients); xorg_list_init(_ready_clients); +xorg_list_init(_pending_clients); } Bool @@ -3413,6 +3415,7 @@ CloseDownClient(ClientPtr client) UngrabServer(client); } mark_client_not_ready(client); +xorg_list_del(>output_pending); BITCLEAR(grabWaiters, client->index); DeleteClientFromAnySelections(client); ReleaseActiveGrabs(client); @@ -3503,6 +3506,7 @@ InitClient(ClientPtr client, int i, void *ospriv) { client->index = i; xorg_list_init(>ready); +xorg_list_init(>output_pending); client->clientAsMask = ((Mask) i) << CLIENTOFFSET; client->closeDownMode = i ? DestroyAll : RetainPermanent; client->requestVector = InitialVector; diff --git a/include/dixstruct.h b/include/dixstruct.h index 1f38349..38c649a 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -77,6 +77,7 @@ typedef struct _Client { void *requestBuffer; void *osPrivate; /* for OS layer, including scheduler */ struct xorg_list ready; /* List of clients ready to run */ +struct xorg_list output_pending; /* List of clients with output queued */ Mask clientAsMask; short index; unsigned char majorOp, minorOp; @@ -153,6 +154,30 @@ static inline Bool client_is_ready(ClientPtr client) Bool clients_are_ready(void); +extern struct xorg_list output_pending_clients; + +static inline void +output_pending_mark(ClientPtr client) +{ +if (xorg_list_is_empty(>output_pending)) +xorg_list_append(>output_pending, _pending_clients); +} + +static inline void +output_pending_clear(ClientPtr client) +{ +xorg_list_del(>output_pending); +} + +static inline Bool any_output_pending(void) { +return !xorg_list_is_empty(_pending_clients); +} + +static inline Bool client_output_pending(ClientPtr client) +{ +return !xorg_list_is_empty(>output_pending); +} + #define SMART_MAX_PRIORITY (20) #define SMART_MIN_PRIORITY (-20) diff --git a/os/WaitFor.c b/os/WaitFor.c index ef4ebb5..9fdc996 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -66,7 +66,6 @@ SOFTWARE. #include "misc.h" #include "osdep.h" -#include #include "dixstruct.h" #include "opaque.h" #ifdef DPMSExtension @@ -146,22 +145,20 @@ Bool WaitForSomething(Bool are_ready) { int i; -struct timeval waittime, *wt; int timeout; -fd_set clientsReadable; -fd_set clientsWritable; -int curclient; -int selecterr; -static int nready; +int pollerr; +static Bool were_ready; +Bool timer_is_running; CARD32 now = 0; -Bool someNotifyWriteReady = FALSE; -FD_ZERO(); -FD_ZERO(); +timer_is_running = were_ready; -if (nready) +if (were_ready && !are_ready) { +timer_is_running = FALSE; SmartScheduleStopTimer(); -nready = 0; +} + +were_ready = FALSE; #ifdef BUSFAULT busfault_check(); @@ -176,8 +173,6 @@ WaitForSomething(Bool are_ready) if (are_ready) { timeout = 0; -XFD_COPYSET(, ); -XFD_UNSET(, ); } else { timeout = -1; @@ -195,57 +190,39 @@ WaitForSomething(Bool are_ready) timeout = 0; } } -XFD_COPYSET(, ); } BlockHandler(); -if (timeout < 0) -wt = NULL; -else { -waittime.tv_sec = timeout / MILLI_PER_SECOND; -waittime.tv_usec = (timeout % MILLI_PER_SECOND) * -(100 / MILLI_PER_SECOND); -wt = -} if (NewOutputPending) FlushAllOutput(); /* keep this check close to select() call to minimize race */ if (dispatchException) i = -1; -else if (AnyWritesPending) { -XFD_COPYSET(, ); -XFD_ORSET(, , ); -i = Select(MaxClients, , , NULL, wt); -} -else { -i = Select(MaxClients, , NULL, NULL, wt); -} -selecterr = GetErrno(); +else +i = ospoll_wait(server_poll, timeout); +pollerr =
[PATCH xserver 03/23] xfree86: Switch from select(2) to poll(2)
xf86WaitForInput and the xf86 SIGIO handling code. Signed-off-by: Keith Packard--- hw/xfree86/common/xf86Events.c | 1 - hw/xfree86/os-support/shared/posix_tty.c | 33 ++--- hw/xfree86/os-support/shared/sigio.c | 63 +--- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 7191980..5b4fa23 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -54,7 +54,6 @@ #endif #include -#include #include #include #include "misc.h" diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c index 6e2af00..d5a70ba 100644 --- a/hw/xfree86/os-support/shared/posix_tty.c +++ b/hw/xfree86/os-support/shared/posix_tty.c @@ -57,6 +57,7 @@ #endif #include +#include #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" @@ -387,26 +388,19 @@ xf86CloseSerial(int fd) int xf86WaitForInput(int fd, int timeout) { -fd_set readfds; -struct timeval to; int r; +struct pollfd poll_fd; -FD_ZERO(); +poll_fd.fd = fd; +poll_fd.events = POLLIN; if (fd >= 0) { -FD_SET(fd, ); -} - -to.tv_sec = timeout / 100; -to.tv_usec = timeout % 100; - -if (fd >= 0) { -SYSCALL(r = select(FD_SETSIZE, , NULL, NULL, )); +SYSCALL(r = poll(_fd, 1, timeout)); } else { -SYSCALL(r = select(FD_SETSIZE, NULL, NULL, NULL, )); +SYSCALL(r = poll(_fd, 0, timeout)); } -xf86ErrorFVerb(9, "select returned %d\n", r); +xf86ErrorFVerb(9, "poll returned %d\n", r); return r; } @@ -423,8 +417,7 @@ xf86SerialSendBreak(int fd, int duration) int xf86FlushInput(int fd) { -fd_set fds; -struct timeval timeout; +struct pollfd poll_fd; /* this needs to be big enough to flush an evdev event. */ char c[256]; @@ -432,15 +425,11 @@ xf86FlushInput(int fd) if (tcflush(fd, TCIFLUSH) == 0) return 0; -timeout.tv_sec = 0; -timeout.tv_usec = 0; -FD_ZERO(); -FD_SET(fd, ); -while (select(FD_SETSIZE, , NULL, NULL, ) > 0) { +poll_fd.fd = fd; +poll_fd.events = POLLIN; +while (poll(_fd, 1, 0) > 0) { if (read(fd, , sizeof(c)) < 1) return 0; -FD_ZERO(); -FD_SET(fd, ); } return 0; } diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c index 37d35f7..92054b3 100644 --- a/hw/xfree86/os-support/shared/sigio.c +++ b/hw/xfree86/os-support/shared/sigio.c @@ -57,6 +57,7 @@ #endif #include +#include #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" @@ -83,8 +84,35 @@ typedef struct _xf86SigIOFunc { static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS]; static int xf86SigIOMax; -static int xf86SigIOMaxFd; -static fd_set xf86SigIOMask; +static struct pollfd *xf86SigIOFds; +static int xf86SigIONum; + +static Bool +xf86SigIOAdd(int fd) +{ +struct pollfd *n; + +n = realloc(xf86SigIOFds, (xf86SigIONum + 1) * sizeof (struct pollfd)); +if (!n) +return FALSE; + +n[xf86SigIONum].fd = fd; +n[xf86SigIONum].events = POLLIN; +xf86SigIOFds = n; +return TRUE; +} + +static void +xf86SigIORemove(int fd) +{ +int i; +for (i = 0; i < xf86SigIONum; i++) +if (xf86SigIOFds[i].fd == fd) { +memmove([i], [i+1], (xf86SigIONum - i - 1) * sizeof (struct pollfd)); +xf86SigIONum--; +break; +} +} /* * SIGIO gives no way of discovering which fd signalled, select @@ -93,24 +121,22 @@ static fd_set xf86SigIOMask; static void xf86SIGIO(int sig) { -int i; -fd_set ready; -struct timeval to; +int i, f; int save_errno = errno; /* do not clobber the global errno */ int r; inSignalContext = TRUE; -ready = xf86SigIOMask; -to.tv_sec = 0; -to.tv_usec = 0; -SYSCALL(r = select(xf86SigIOMaxFd, , 0, 0, )); -for (i = 0; r > 0 && i < xf86SigIOMax; i++) -if (xf86SigIOFuncs[i].f && FD_ISSET(xf86SigIOFuncs[i].fd, )) { -(*xf86SigIOFuncs[i].f) (xf86SigIOFuncs[i].fd, -xf86SigIOFuncs[i].closure); +SYSCALL(r = poll(xf86SigIOFds, xf86SigIONum, 0)); +for (f = 0; r > 0 && f < xf86SigIONum; f++) { +if (xf86SigIOFds[f].revents & POLLIN) { +for (i = 0; i < xf86SigIOMax; i++) +if (xf86SigIOFuncs[i].f && xf86SigIOFuncs[i].fd == xf86SigIOFds[f].fd) +(*xf86SigIOFuncs[i].f) (xf86SigIOFuncs[i].fd, +xf86SigIOFuncs[i].closure); r--; } +} if (r > 0) { xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); } @@ -206,9 +232,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure) xf86SigIOFuncs[i].f = f; if (i >=
[PATCH xserver 06/23] hw/xfree86: Use NotifyFd for other input fd wakeups
Remove code in xf86Wakeup for dealing with other input and switch to using the new NotifyFd interface. Signed-off-by: Keith Packard--- hw/xfree86/common/xf86Events.c | 76 -- 1 file changed, 22 insertions(+), 54 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 5b4fa23..7d3c35f 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -100,8 +100,6 @@ Bool VTSwitchEnabled = TRUE;/* Allows run-time disabling for switches when using the DRI automatic full screen mode.*/ -extern fd_set EnabledDevices; - #ifdef XF86PM extern void (*xf86OSPMClose) (void); #endif @@ -246,45 +244,6 @@ xf86ProcessActionEvent(ActionEvent action, void *arg) void xf86Wakeup(void *blockData, int err, void *pReadmask) { -fd_set *LastSelectMask = (fd_set *) pReadmask; -fd_set devicesWithInput; -InputInfoPtr pInfo; - -if (err >= 0) { - -XFD_ANDSET(, LastSelectMask, ); -if (XFD_ANYSET()) { -pInfo = xf86InputDevs; -while (pInfo) { -if (pInfo->read_input && pInfo->fd >= 0 && -(FD_ISSET(pInfo->fd, ) != 0)) { -input_lock(); - -/* - * Remove the descriptior from the set because more than one - * device may share the same file descriptor. - */ -FD_CLR(pInfo->fd, ); - -pInfo->read_input(pInfo); -input_unlock(); -} -pInfo = pInfo->next; -} -} -} - -if (err >= 0) { /* we don't want the handlers called if select() */ -IHPtr ih, ih_tmp; /* returned with an error condition, do we? */ - -nt_list_for_each_entry_safe(ih, ih_tmp, InputHandlers, next) { -if (ih->enabled && ih->fd >= 0 && ih->ihproc && -(FD_ISSET(ih->fd, ((fd_set *) pReadmask)) != 0)) { -ih->ihproc(ih->fd, ih->data); -} -} -} - if (xf86VTSwitchPending()) xf86VTSwitch(); } @@ -629,6 +588,16 @@ xf86VTSwitch(void) /* Input handler registration */ +static void +xf86InputHandlerNotify(int fd, int ready, void *data) +{ +IHPtr ih = data; + +if (ih->enabled && ih->fd >= 0 && ih->ihproc) { +ih->ihproc(ih->fd, ih->data); +} +} + static void * addInputHandler(int fd, InputHandlerProc proc, void *data) { @@ -646,6 +615,11 @@ addInputHandler(int fd, InputHandlerProc proc, void *data) ih->data = data; ih->enabled = TRUE; +if (!SetNotifyFd(fd, xf86InputHandlerNotify, X_NOTIFY_READ, ih)) { +free(ih); +return NULL; +} + ih->next = InputHandlers; InputHandlers = ih; @@ -657,10 +631,8 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, void *data) { IHPtr ih = addInputHandler(fd, proc, data); -if (ih) { -AddEnabledDevice(fd); +if (ih) ih->is_input = TRUE; -} return ih; } @@ -669,8 +641,6 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, void *data) { IHPtr ih = addInputHandler(fd, proc, data); -if (ih) -AddGeneralSocket(fd); return ih; } @@ -700,6 +670,8 @@ removeInputHandler(IHPtr ih) { IHPtr p; +if (ih->fd >= 0) +RemoveNotifyFd(ih->fd); if (ih == InputHandlers) InputHandlers = ih->next; else { @@ -724,8 +696,6 @@ xf86RemoveInputHandler(void *handler) ih = handler; fd = ih->fd; -if (ih->fd >= 0) -RemoveEnabledDevice(ih->fd); removeInputHandler(ih); return fd; @@ -743,8 +713,6 @@ xf86RemoveGeneralHandler(void *handler) ih = handler; fd = ih->fd; -if (ih->fd >= 0) -RemoveGeneralSocket(ih->fd); removeInputHandler(ih); return fd; @@ -761,7 +729,7 @@ xf86DisableInputHandler(void *handler) ih = handler; ih->enabled = FALSE; if (ih->fd >= 0) -RemoveEnabledDevice(ih->fd); +RemoveNotifyFd(ih->fd); } void @@ -775,7 +743,7 @@ xf86DisableGeneralHandler(void *handler) ih = handler; ih->enabled = FALSE; if (ih->fd >= 0) -RemoveGeneralSocket(ih->fd); +RemoveNotifyFd(ih->fd); } void @@ -789,7 +757,7 @@ xf86EnableInputHandler(void *handler) ih = handler; ih->enabled = TRUE; if (ih->fd >= 0) -AddEnabledDevice(ih->fd); +SetNotifyFd(ih->fd, xf86InputHandlerNotify, X_NOTIFY_READ, ih); } void @@ -803,7 +771,7 @@ xf86EnableGeneralHandler(void *handler) ih = handler; ih->enabled = TRUE; if (ih->fd >= 0) -AddGeneralSocket(ih->fd); +SetNotifyFd(ih->fd, xf86InputHandlerNotify, X_NOTIFY_READ, ih); } /* -- 2.8.0.rc3 ___
[PATCH xserver 16/23] os: Compute timeout in milliseconds instead of struct timeval
The timeout resolution offered in the AdjustWaitForDelay call is only milliseconds, so passing around the timeout as a pointer to a struct timeval is not helpful. Doing everything in milliseconds up to the point of the select call simplifies the code without affecting functionality at all. Signed-off-by: Keith Packard--- include/os.h | 3 +-- os/WaitFor.c | 32 ++-- os/utils.c | 21 - 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/include/os.h b/include/os.h index 51400a9..25e02bf 100644 --- a/include/os.h +++ b/include/os.h @@ -175,8 +175,7 @@ extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ ); extern _X_EXPORT CARD32 GetTimeInMillis(void); extern _X_EXPORT CARD64 GetTimeInMicros(void); -extern _X_EXPORT void AdjustWaitForDelay(void *waitTime, - unsigned long newdelay); +extern _X_EXPORT void AdjustWaitForDelay(void *waitTime, int newdelay); typedef struct _OsTimerRec *OsTimerPtr; diff --git a/os/WaitFor.c b/os/WaitFor.c index 26673e4..0ba1d6b 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -147,7 +147,7 @@ WaitForSomething(int *pClientsReady) { int i; struct timeval waittime, *wt; -INT32 timeout = 0; +int timeout; fd_set clientsReadable; fd_set clientsWritable; int curclient; @@ -175,17 +175,15 @@ WaitForSomething(int *pClientsReady) if (workQueue) ProcessWorkQueue(); if (XFD_ANYSET()) { +timeout = 0; someReady = TRUE; -waittime.tv_sec = 0; -waittime.tv_usec = 0; -wt = } if (someReady) { XFD_COPYSET(, ); XFD_UNSET(, ); } else { -wt = NULL; +timeout = -1; if (timers) { now = GetTimeInMillis(); timeout = timers->expires - now; @@ -198,16 +196,20 @@ WaitForSomething(int *pClientsReady) timeout = timers->expires - now; if (timeout < 0) timeout = 0; -waittime.tv_sec = timeout / MILLI_PER_SECOND; -waittime.tv_usec = (timeout % MILLI_PER_SECOND) * -(100 / MILLI_PER_SECOND); -wt = } } XFD_COPYSET(, ); } -BlockHandler(); +BlockHandler(); +if (timeout < 0) +wt = NULL; +else { +waittime.tv_sec = timeout / MILLI_PER_SECOND; +waittime.tv_usec = (timeout % MILLI_PER_SECOND) * +(100 / MILLI_PER_SECOND); +wt = +} if (NewOutputPending) FlushAllOutput(); /* keep this check close to select() call to minimize race */ @@ -359,6 +361,16 @@ WaitForSomething(int *pClientsReady) return nready; } +void +AdjustWaitForDelay(void *waitTime, int newdelay) +{ +int *timeoutp = waitTime; +int timeout = *timeoutp; + +if (timeout < 0 || newdelay < timeout) +*timeoutp = newdelay; +} + /* If time has rewound, re-run every affected timer. * Timers might drop out of the list, so we have to restart every time. */ static void diff --git a/os/utils.c b/os/utils.c index 87417e2..4507c9e 100644 --- a/os/utils.c +++ b/os/utils.c @@ -493,27 +493,6 @@ GetTimeInMicros(void) #endif void -AdjustWaitForDelay(void *waitTime, unsigned long newdelay) -{ -static struct timeval delay_val; -struct timeval **wt = (struct timeval **) waitTime; -unsigned long olddelay; - -if (*wt == NULL) { -delay_val.tv_sec = newdelay / 1000; -delay_val.tv_usec = 1000 * (newdelay % 1000); -*wt = _val; -} -else { -olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000; -if (newdelay < olddelay) { -(*wt)->tv_sec = newdelay / 1000; -(*wt)->tv_usec = 1000 * (newdelay % 1000); -} -} -} - -void UseMsg(void) { ErrorF("use: X [:] [option]\n"); -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 18/23] dix: Use list for ready clients
This converts the dispatch loop into using a list of ready clients instead of an array. This changes the WaitForSomething API so that it notifies DIX when a client becomes ready to read, instead of returning the set of ready clients. Signed-off-by: Keith Packard--- dix/dispatch.c | 114 +--- include/dixstruct.h | 15 +++ include/os.h| 3 +- os/WaitFor.c| 36 - os/connection.c | 5 ++- 5 files changed, 118 insertions(+), 55 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 3237883..a61d7a4 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -240,21 +240,76 @@ long SmartLastPrint; void Dispatch(void); -static int -SmartScheduleClient(int *clientReady, int nready) +static struct xorg_list ready_clients; +static struct xorg_list saved_ready_clients; + +static void +init_client_ready(void) +{ +xorg_list_init(_clients); +xorg_list_init(_ready_clients); +} + +Bool +clients_are_ready(void) +{ +return !xorg_list_is_empty(_clients); +} + +/* Client has requests queued or data on the network */ +void +mark_client_ready(ClientPtr client) +{ +if (xorg_list_is_empty(>ready)) +xorg_list_append(>ready, _clients); +} + +/* Client has no requests queued and no data on network */ +void +mark_client_not_ready(ClientPtr client) +{ +xorg_list_del(>ready); +} + +static void +mark_client_grab(ClientPtr grab) +{ +ClientPtr client, tmp; + +xorg_list_for_each_entry_safe(client, tmp, _clients, ready) { +if (client != grab) { +xorg_list_del(>ready); +xorg_list_append(>ready, _ready_clients); +} +} +} + +static void +mark_client_ungrab(void) +{ +ClientPtr client, tmp; + +xorg_list_for_each_entry_safe(client, tmp, _ready_clients, ready) { +xorg_list_del(>ready); +xorg_list_append(>ready, _clients); +} +} + +static ClientPtr +SmartScheduleClient(void) { -int i; -int client; ClientPtr pClient, best = NULL; int bestRobin, robin; long now = SmartScheduleTime; long idle; +int nready = 0; bestRobin = 0; idle = 2 * SmartScheduleSlice; -for (i = 0; i < nready; i++) { -client = clientReady[i]; -pClient = clients[client]; + +xorg_list_for_each_entry(pClient, _clients, ready) { +nready++; + /* Praise clients which haven't run in a while */ if ((now - pClient->smart_stop_tick) >= idle) { if (pClient->smart_priority < 0) @@ -279,12 +334,12 @@ SmartScheduleClient(int *clientReady, int nready) } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) -fprintf(stderr, " %2d: %3d", client, pClient->smart_priority); +fprintf(stderr, " %2d: %3d", pClient->index, pClient->smart_priority); #endif } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) { -fprintf(stderr, " use %2d\n", best); +fprintf(stderr, " use %2d\n", best->index); SmartLastPrint = now; } #endif @@ -292,9 +347,9 @@ SmartScheduleClient(int *clientReady, int nready) /* * Set current client pointer */ -if (SmartLastClient != pClient) { -pClient->smart_start_tick = now; -SmartLastClient = pClient; +if (SmartLastClient != best) { +best->smart_start_tick = now; +SmartLastClient = best; } /* * Adjust slice @@ -313,7 +368,7 @@ SmartScheduleClient(int *clientReady, int nready) else { SmartScheduleSlice = SmartScheduleInterval; } -return best->index; +return best; } void @@ -336,44 +391,34 @@ DisableLimitedSchedulingLatency(void) void Dispatch(void) { -int *clientReady; /* array of request ready clients */ int result; ClientPtr client; -int nready; HWEventQueuePtr *icheck = checkForInput; long start_tick; nextFreeClientID = 1; nClients = 0; -clientReady = xallocarray(MaxClients, sizeof(int)); -if (!clientReady) -return; - SmartScheduleSlice = SmartScheduleInterval; +init_client_ready(); + while (!dispatchException) { if (*icheck[0] != *icheck[1]) { ProcessInputEvents(); FlushIfCriticalOutputPending(); } -nready = WaitForSomething(clientReady); +if (!WaitForSomething(clients_are_ready())) +continue; -if (nready) { -clientReady[0] = SmartScheduleClient(clientReady, nready); -nready = 1; -} /* * Handle events in round robin fashion, doing input between * each round */ -while (!dispatchException && (--nready >= 0)) { -client = clients[clientReady[nready]]; -if (!client) { -/* KillClient can cause this to happen */ -continue; -
[PATCH xserver 08/23] hw/kdrive: Use passed-in fd for kdrive/linux APM monitoring [v2]
This is a cleanup, proposed by Adam Jackson, but wasn't merged with the original NotifyFD changes. Signed-off-by: Keith Packard--- hw/kdrive/linux/linux.c | 64 - 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c index a52bdef..bc48d8d 100644 --- a/hw/kdrive/linux/linux.c +++ b/hw/kdrive/linux/linux.c @@ -174,41 +174,39 @@ static Bool LinuxApmRunning; static void LinuxApmNotify(int fd, int mask, void *blockData) { -if (LinuxApmFd >= 0) { -apm_event_t event; -Bool running = LinuxApmRunning; -int cmd = APM_IOC_SUSPEND; - -while (read(LinuxApmFd, , sizeof(event)) == sizeof(event)) { -switch (event) { -case APM_SYS_STANDBY: -case APM_USER_STANDBY: -running = FALSE; -cmd = APM_IOC_STANDBY; -break; -case APM_SYS_SUSPEND: -case APM_USER_SUSPEND: -case APM_CRITICAL_SUSPEND: -running = FALSE; -cmd = APM_IOC_SUSPEND; -break; -case APM_NORMAL_RESUME: -case APM_CRITICAL_RESUME: -case APM_STANDBY_RESUME: -running = TRUE; -break; -} -} -if (running && !LinuxApmRunning) { -KdResume(); -LinuxApmRunning = TRUE; -} -else if (!running && LinuxApmRunning) { -KdSuspend(); -LinuxApmRunning = FALSE; -ioctl(LinuxApmFd, cmd, 0); +apm_event_t event; +Bool running = LinuxApmRunning; +int cmd = APM_IOC_SUSPEND; + +while (read(fd, , sizeof(event)) == sizeof(event)) { +switch (event) { +case APM_SYS_STANDBY: +case APM_USER_STANDBY: +running = FALSE; +cmd = APM_IOC_STANDBY; +break; +case APM_SYS_SUSPEND: +case APM_USER_SUSPEND: +case APM_CRITICAL_SUSPEND: +running = FALSE; +cmd = APM_IOC_SUSPEND; +break; +case APM_NORMAL_RESUME: +case APM_CRITICAL_RESUME: +case APM_STANDBY_RESUME: +running = TRUE; +break; } } +if (running && !LinuxApmRunning) { +KdResume(); +LinuxApmRunning = TRUE; +} +else if (!running && LinuxApmRunning) { +KdSuspend(); +LinuxApmRunning = FALSE; +ioctl(fd, cmd, 0); +} } #ifdef FNONBLOCK -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 14/23] dix/os: Merge priority computation into SmartScheduleClient
Instead of having scheduling done in two places (one in WaitForSomething, and the other in SmartScheduleClient), just stick all of the scheduling in SmartScheduleClient. Signed-off-by: Keith Packard--- dix/dispatch.c | 22 -- os/WaitFor.c | 33 ++--- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 89c0a4e..f005983 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -244,15 +244,13 @@ void Dispatch(void); static int SmartScheduleClient(int *clientReady, int nready) { -ClientPtr pClient; int i; int client; -int bestPrio, best = 0; +ClientPtr pClient, best = NULL; int bestRobin, robin; long now = SmartScheduleTime; long idle; -bestPrio = -0x7fff; bestRobin = 0; idle = 2 * SmartScheduleSlice; for (i = 0; i < nready; i++) { @@ -269,11 +267,16 @@ SmartScheduleClient(int *clientReady, int nready) (pClient->index - SmartLastIndex[pClient->smart_priority - SMART_MIN_PRIORITY]) & 0xff; -if (pClient->smart_priority > bestPrio || -(pClient->smart_priority == bestPrio && robin > bestRobin)) { -bestPrio = pClient->smart_priority; + +/* pick the best client */ +if (!best || +pClient->priority > best->priority || +(pClient->priority == best->priority && + (pClient->smart_priority > best->smart_priority || + (pClient->smart_priority == best->smart_priority && robin > bestRobin +{ +best = pClient; bestRobin = robin; -best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) @@ -286,8 +289,7 @@ SmartScheduleClient(int *clientReady, int nready) SmartLastPrint = now; } #endif -pClient = clients[best]; -SmartLastIndex[bestPrio - SMART_MIN_PRIORITY] = pClient->index; +SmartLastIndex[best->smart_priority - SMART_MIN_PRIORITY] = best->index; /* * Set current client pointer */ @@ -312,7 +314,7 @@ SmartScheduleClient(int *clientReady, int nready) else { SmartScheduleSlice = SmartScheduleInterval; } -return best; +return best->index; } void diff --git a/os/WaitFor.c b/os/WaitFor.c index 994edf0..26673e4 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -326,17 +326,14 @@ WaitForSomething(int *pClientsReady) if (XFD_ANYSET()) { #ifndef WIN32 for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) { -int highest_priority = 0; - while (clientsReadable.fds_bits[i]) { -int client_priority, client_index; +int client_index; curclient = mffs(clientsReadable.fds_bits[i]) - 1; client_index = /* raphael: modified */ ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))]; #else -int highest_priority = 0; fd_set savedClientsReadable; XFD_COPYSET(, ); @@ -346,33 +343,7 @@ WaitForSomething(int *pClientsReady) curclient = XFD_FD(, i); client_index = GetConnectionTranslation(curclient); #endif -/* We implement "strict" priorities. - * Only the highest priority client is returned to - * dix. If multiple clients at the same priority are - * ready, they are all returned. This means that an - * aggressive client could take over the server. - * This was not considered a big problem because - * aggressive clients can hose the server in so many - * other ways :) - */ -client_priority = clients[client_index]->priority; -if (nready == 0 || client_priority > highest_priority) { -/* Either we found the first client, or we found - * a client whose priority is greater than all others - * that have been found so far. Either way, we want - * to initialize the list of clients to contain just - * this client. - */ -pClientsReady[0] = client_index; -highest_priority = client_priority; -nready = 1; -} -/* the following if makes sure that multiple same-priority - * clients get batched together - */ -else if (client_priority == highest_priority) { -pClientsReady[nready++] = client_index; -} +pClientsReady[nready++] = client_index; #ifndef WIN32 clientsReadable.fds_bits[i] &= ~(((fd_mask) 1L) << curclient); } -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives:
[PATCH xserver 11/23] Remove readmask from screen block/wakeup handler
With no users of the interface needing the readmask anymore, we can remove it from the argument passed to these functions. Signed-off-by: Keith Packard--- composite/compalloc.c | 4 +-- dix/dixutils.c | 18 -- doc/Xinput.xml | 8 + doc/Xserver-spec.xml| 59 +++-- exa/exa.c | 10 +++--- glamor/glamor.c | 4 +-- hw/kdrive/ephyr/ephyr.c | 4 +-- hw/kdrive/src/kdrive.h | 6 ++-- hw/kdrive/src/kinput.c | 4 +-- hw/xfree86/common/xf86VGAarbiter.c | 10 +++--- hw/xfree86/common/xf86VGAarbiterPriv.h | 6 ++-- hw/xfree86/dri/dri.c| 12 +++ hw/xfree86/dri/dri.h| 7 ++-- hw/xfree86/drivers/modesetting/driver.c | 8 ++--- hw/xfree86/modes/xf86Rotate.c | 5 ++- hw/xquartz/quartzCocoa.m| 8 ++--- hw/xquartz/quartzCommon.h | 5 +-- hw/xwin/win.h | 4 +-- hw/xwin/winwakeup.c | 3 +- include/scrnintstr.h| 11 +++--- mi/misprite.c | 8 ++--- miext/shadow/shadow.c | 4 +-- 22 files changed, 77 insertions(+), 131 deletions(-) diff --git a/composite/compalloc.c b/composite/compalloc.c index 8daded0..e6a203f 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -55,13 +55,13 @@ compScreenUpdate(ScreenPtr pScreen) } static void -compBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask) +compBlockHandler(ScreenPtr pScreen, void *pTimeout) { CompScreenPtr cs = GetCompScreen(pScreen); pScreen->BlockHandler = cs->BlockHandler; compScreenUpdate(pScreen); -(*pScreen->BlockHandler) (pScreen, pTimeout, pReadmask); +(*pScreen->BlockHandler) (pScreen, pTimeout); /* Next damage will restore the block handler */ cs->BlockHandler = NULL; diff --git a/dix/dixutils.c b/dix/dixutils.c index 3d2e7a3..d728929 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -385,16 +385,13 @@ BlockHandler(void *pTimeout, void *pReadmask) ++inHandler; for (i = 0; i < numHandlers; i++) if (!handlers[i].deleted) -(*handlers[i].BlockHandler) (handlers[i].blockData, - pTimeout, pReadmask); +(*handlers[i].BlockHandler) (handlers[i].blockData, pTimeout, pReadmask); for (i = 0; i < screenInfo.numGPUScreens; i++) -(*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i], - pTimeout, pReadmask); +(*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i], pTimeout); for (i = 0; i < screenInfo.numScreens; i++) -(*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], -pTimeout, pReadmask); +(*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], pTimeout); if (handlerDeleted) { for (i = 0; i < numHandlers;) @@ -422,15 +419,12 @@ WakeupHandler(int result, void *pReadmask) ++inHandler; for (i = 0; i < screenInfo.numScreens; i++) -(*screenInfo.screens[i]->WakeupHandler) (screenInfo.screens[i], - result, pReadmask); +(*screenInfo.screens[i]->WakeupHandler) (screenInfo.screens[i], result); for (i = 0; i < screenInfo.numGPUScreens; i++) -(*screenInfo.gpuscreens[i]->WakeupHandler) (screenInfo.gpuscreens[i], -result, pReadmask); +(*screenInfo.gpuscreens[i]->WakeupHandler) (screenInfo.gpuscreens[i], result); for (i = numHandlers - 1; i >= 0; i--) if (!handlers[i].deleted) -(*handlers[i].WakeupHandler) (handlers[i].blockData, - result, pReadmask); +(*handlers[i].WakeupHandler) (handlers[i].blockData, result, pReadmask); if (handlerDeleted) { for (i = 0; i < numHandlers;) if (handlers[i].deleted) { diff --git a/doc/Xinput.xml b/doc/Xinput.xml index 083b109..0e7fbda 100644 --- a/doc/Xinput.xml +++ b/doc/Xinput.xml @@ -210,7 +210,7 @@ A sample InitInput implementation is shown below. InitInput(argc,argv) { -int i, numdevs, ReadInput(); +int i, numdevs; DeviceIntPtr dev; LocalDevice localdevs[LOCAL_MAX_DEVS]; DeviceProc kbdproc, ptrproc, extproc; @@ -224,12 +224,6 @@ InitInput(argc,argv) open_input_devices (numdevs, localdevs); /** - * Register a WakeupHandler to handle input when it is generated. - ***/ - -RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput,
[PATCH xserver 01/23] dix: Switch to the libXfont2 API (v2)
This new libXfont API eliminates exposing internal X server symbols to the font library, replacing those with a struct full of the entire API needed to use that library. v2: Use libXfont2 instead of libXfont_2 Signed-off-by: Keith Packard--- Xext/xf86bigfont.c | 4 +- configure.ac | 2 +- dix/dispatch.c | 4 +- dix/dixfonts.c | 323 + dix/main.c | 4 +- glamor/glamor_font.c | 6 +- hw/dmx/dmxfont.c | 9 +- hw/dmx/dmxscrinit.c| 4 +- hw/xfree86/sdksyms.sh | 1 - hw/xnest/Font.c| 7 +- hw/xnest/Init.c| 3 +- include/dixfont.h | 18 +-- include/dixfontstr.h | 1 + include/dixfontstubs.h | 43 --- mi/miglblt.c | 6 +- miext/damage/damage.c | 4 +- os/utils.c | 4 +- 17 files changed, 231 insertions(+), 212 deletions(-) delete mode 100644 include/dixfontstubs.h diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 95b5371..682d84f 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -439,7 +439,7 @@ ProcXF86BigfontQueryFont(ClientPtr client) #ifdef HAS_SHM if (pDesc && !badSysCall) { *(CARD32 *) (pCI + nCharInfos) = signature; -if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { +if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) { shmdealloc(pDesc); return BadAlloc; } @@ -723,7 +723,7 @@ XFree86BigfontExtensionInit(void) + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ -FontShmdescIndex = AllocateFontPrivateIndex(); +FontShmdescIndex = xfont2_allocate_font_private_index(); #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; diff --git a/configure.ac b/configure.ac index 6c96de2..1a9aa81 100644 --- a/configure.ac +++ b/configure.ac @@ -813,7 +813,7 @@ LIBEGL="egl" LIBGBM="gbm >= 10.2.0" LIBGL="gl >= 7.1.0" LIBXEXT="xext >= 1.0.99.4" -LIBXFONT="xfont >= 1.4.2" +LIBXFONT="xfont2 >= 2.0.0" LIBXI="xi >= 1.2.99.1" LIBXTST="xtst >= 1.0.99.2" LIBPCIACCESS="pciaccess >= 0.12.901" diff --git a/dix/dispatch.c b/dix/dispatch.c index 26122c1..89c0a4e 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -108,7 +108,7 @@ int ProcInitialConnection(); #include "windowstr.h" #include -#include +#include #include "dixfontstr.h" #include "gcstruct.h" #include "selection.h" @@ -1286,7 +1286,7 @@ ProcQueryTextExtents(ClientPtr client) return BadLength; length--; } -if (!QueryTextExtents(pFont, length, (unsigned char *) [1], )) +if (!xfont2_query_text_extents(pFont, length, (unsigned char *) [1], )) return BadAlloc; reply = (xQueryTextExtentsReply) { .type = X_Reply, diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 19db141..d217d12 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -65,6 +65,7 @@ Equipment Corporation. #include "closestr.h" #include "dixfont.h" #include "xace.h" +#include #ifdef XF86BIGFONT #include "xf86bigfontsrv.h" @@ -75,7 +76,7 @@ extern FontPtr defaultFont; static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; -static FPEFunctions *fpe_functions = (FPEFunctions *) 0; +static xfont2_fpe_funcs_rec const **fpe_functions; static int num_fpe_types = 0; static unsigned char *font_path_string; @@ -83,7 +84,7 @@ static unsigned char *font_path_string; static int num_slept_fpes = 0; static int size_slept_fpes = 0; static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; -static FontPatternCachePtr patternCache; +static xfont2_pattern_cache_ptr patternCache; static int FontToXError(int err) @@ -108,18 +109,18 @@ static int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { -if (fpe_functions[pfont->fpe->type].load_glyphs) -return (*fpe_functions[pfont->fpe->type].load_glyphs) +if (fpe_functions[pfont->fpe->type]->load_glyphs) +return (*fpe_functions[pfont->fpe->type]->load_glyphs) (client, pfont, 0, nchars, item_size, data); else return Successful; } void -dixGetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, - FontEncoding fontEncoding, - unsigned long *glyphcount,/* RETURN */ - CharInfoPtr *glyphs) /* RETURN */ +GetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount,/* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ { (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); } @@ -206,7 +207,7 @@ FontWakeup(void *data, int count, void *LastSelectMask) /* wake up any fpe's
[PATCH xserver 00/23] Switch server to poll/epoll
Ok, I've reworked this patch series to try and have it make some semblance of sense. There's two scary patches, 18/23 and 19/23; everything else is pretty self contained. The first patch flips to the new font API: [PATCH xserver 01/23] dix: Switch to the libXfont2 API (v2) Then changes to move from select(2) to poll(2) in various isolated bits of the server: [PATCH xserver 02/23] kdrive: switch from select(2) to poll(2) [PATCH xserver 03/23] xfree86: Switch from select(2) to poll(2) [PATCH xserver 04/23] dmx: Switch from select(2) to poll(2) for input [PATCH xserver 05/23] os: Switch from select(2) to poll(2) in Then a bunch of fixes related to the use of NotifyFd APIs: [PATCH xserver 06/23] hw/xfree86: Use NotifyFd for other input fd [PATCH xserver 07/23] xnest: Use SetNotifyFd to receive events [PATCH xserver 08/23] hw/kdrive: Use passed-in fd for kdrive/linux [PATCH xserver 09/23] modesetting: Use passed-in fd for drm event [PATCH xserver 10/23] dmx: Eliminate use of AddEnabledDevice And, with everyone using NotifyFd outside of OS, all of the fd_set's visible in the API can be removed: [PATCH xserver 11/23] Remove readmask from screen block/wakeup [PATCH xserver 12/23] Remove fd_set from Block/Wakeup handler API [PATCH xserver 13/23] Remove AddEnabledDevice and AddGeneralSocket Next come a few small cleanups in the server to prepare for major surgery ahead: [PATCH xserver 14/23] dix/os: Merge priority computation into [PATCH xserver 15/23] dix: Intermediate GrabServer state [PATCH xserver 16/23] os: Compute timeout in milliseconds instead of Here's the new interface which I've already sent out. Adam Jackson has suggested that perhaps the edge trigger mode could be a hint instead of a requirement. I haven't done that yet, but it seems like it might be reasonable. Nothing is hooked to this in this patch. [PATCH xserver 17/23] os: Add ospoll interface Two patches which change the server to use the new ospoll bits in WaitForSomething. All of the old select mask frobbing is gone. [PATCH xserver 18/23] dix: Use list for ready clients [PATCH xserver 19/23] os: Switch server to poll(2) Next, the input thread is changed over [PATCH xserver 20/23] os: Use poll(2) for input thread Finally, with the server now independent of fd values, a few cleanups [PATCH xserver 21/23] os: eliminate fd value limits for clients [PATCH xserver 22/23] Allow 1024 and 2048 for LimitClients [PATCH xserver 23/23] os: Leave stdin and stdout open -keith ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 12/23] Remove fd_set from Block/Wakeup handler API
This removes the last uses of fd_set from the server interfaces outside of the OS layer itself. Signed-off-by: Keith Packard--- Xext/sleepuntil.c | 17 +++-- Xext/sync.c | 12 ++-- dix/dixfonts.c | 7 +++ dix/dixutils.c | 20 ++-- hw/dmx/dmxsync.c| 4 ++-- hw/dmx/input/dmxinputinit.c | 4 ++-- hw/vfb/InitOutput.c | 4 ++-- hw/xfree86/common/xf86Events.c | 2 +- hw/xfree86/common/xf86Init.c| 2 +- hw/xfree86/common/xf86Priv.h| 2 +- hw/xfree86/dri/dri.c| 4 ++-- hw/xfree86/dri/dri.h| 6 ++ hw/xnest/Handlers.c | 4 ++-- hw/xnest/Handlers.h | 5 ++--- hw/xwayland/xwayland.c | 4 ++-- include/dix.h | 26 +- miext/rootless/rootlessScreen.c | 4 ++-- os/WaitFor.c| 4 ++-- 18 files changed, 62 insertions(+), 69 deletions(-) diff --git a/Xext/sleepuntil.c b/Xext/sleepuntil.c index 993c028..68a7a9b 100644 --- a/Xext/sleepuntil.c +++ b/Xext/sleepuntil.c @@ -63,14 +63,11 @@ static void ClientAwaken(ClientPtr /* client */ , static int SertafiedDelete(void * /* value */ , XID /* id */ ); -static void SertafiedBlockHandler(void */* data */ , - OSTimePtr /* wt */ , - void */* LastSelectMask */ -); -static void SertafiedWakeupHandler(void * /* data */ , - int /* i */ , - void * /* LastSelectMask */ -); +static void SertafiedBlockHandler(void *data, + void *timeout); + +static void SertafiedWakeupHandler(void *data, + int i); int ClientSleepUntil(ClientPtr client, @@ -154,7 +151,7 @@ SertafiedDelete(void *value, XID id) } static void -SertafiedBlockHandler(void *data, OSTimePtr wt, void *LastSelectMask) +SertafiedBlockHandler(void *data, void *wt) { SertafiedPtr pReq, pNext; unsigned long delay; @@ -186,7 +183,7 @@ SertafiedBlockHandler(void *data, OSTimePtr wt, void *LastSelectMask) } static void -SertafiedWakeupHandler(void *data, int i, void *LastSelectMask) +SertafiedWakeupHandler(void *data, int i) { SertafiedPtr pReq, pNext; TimeStamp now; diff --git a/Xext/sync.c b/Xext/sync.c index 4c59fea..323b9db 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -2556,8 +2556,8 @@ static XSyncValue *pnext_time; *** Server Block Handler *** code inspired by multibuffer extension (now deprecated) */ - /*ARGSUSED*/ static void -ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) +/*ARGSUSED*/ static void +ServertimeBlockHandler(void *env, void *wt) { XSyncValue delay; unsigned long timeout; @@ -2582,8 +2582,8 @@ ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) /* *** Wakeup Handler */ - /*ARGSUSED*/ static void -ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask) +/*ARGSUSED*/ static void +ServertimeWakeupHandler(void *env, int rc) { if (pnext_time) { GetTime(); @@ -2658,7 +2658,7 @@ IdleTimeQueryValue(void *pCounter, CARD64 * pValue_return) } static void -IdleTimeBlockHandler(void *pCounter, struct timeval **wt, void *LastSelectMask) +IdleTimeBlockHandler(void *pCounter, void *wt) { SyncCounter *counter = pCounter; IdleCounterPriv *priv = SysCounterGetPrivate(counter); @@ -2751,7 +2751,7 @@ IdleTimeCheckBrackets(SyncCounter *counter, XSyncValue idle, XSyncValue *less, X } static void -IdleTimeWakeupHandler(void *pCounter, int rc, void *LastSelectMask) +IdleTimeWakeupHandler(void *pCounter, int rc) { SyncCounter *counter = pCounter; IdleCounterPriv *priv = SysCounterGetPrivate(counter); diff --git a/dix/dixfonts.c b/dix/dixfonts.c index d217d12..cca92ed 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -197,7 +197,7 @@ RemoveFontWakeup(FontPathElementPtr fpe) } static void -FontWakeup(void *data, int count, void *LastSelectMask) +FontWakeup(void *data, int count) { int i; FontPathElementPtr fpe; @@ -1918,8 +1918,7 @@ _client_auth_generation(ClientPtr client) static int fs_handlers_installed = 0; static unsigned int last_server_gen; -static void -fs_block_handler(void *blockData, OSTimePtr timeout, void *readmask) +static void fs_block_handler(void *blockData, void *timeout) { FontBlockHandlerProcPtr block_handler = blockData; @@ -2004,7 +2003,7 @@ _init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) static void _remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, - Bool all) +Bool all) { if (all) { /* remove the handlers if no one else is using them */ diff --git
[PATCH xserver 13/23] Remove AddEnabledDevice and AddGeneralSocket APIs
All uses of these interfaces should instead be using the NotifyFd API instead. Signed-off-by: Keith Packard--- include/os.h| 8 os/WaitFor.c| 4 +--- os/connection.c | 43 --- 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/include/os.h b/include/os.h index 20224f1..51400a9 100644 --- a/include/os.h +++ b/include/os.h @@ -143,14 +143,6 @@ extern _X_EXPORT void CheckConnections(void); extern _X_EXPORT void CloseDownConnection(ClientPtr /*client */ ); -extern _X_EXPORT void AddGeneralSocket(int /*fd */ ); - -extern _X_EXPORT void RemoveGeneralSocket(int /*fd */ ); - -extern _X_EXPORT void AddEnabledDevice(int /*fd */ ); - -extern _X_EXPORT void RemoveEnabledDevice(int /*fd */ ); - typedef void (*NotifyFdProcPtr)(int fd, int ready, void *data); #define X_NOTIFY_NONE 0 diff --git a/os/WaitFor.c b/os/WaitFor.c index 5793427..994edf0 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -153,7 +153,6 @@ WaitForSomething(int *pClientsReady) int curclient; int selecterr; static int nready; -fd_set devicesReadable; CARD32 now = 0; Bool someReady = FALSE; Bool someNotifyWriteReady = FALSE; @@ -309,14 +308,13 @@ WaitForSomething(int *pClientsReady) } } -XFD_ANDSET(, , ); XFD_ANDSET(, , ); XFD_ANDSET(_set, , ); if (XFD_ANYSET(_set) || someNotifyWriteReady) HandleNotifyFds(); -if (XFD_ANYSET() || XFD_ANYSET()) +if (XFD_ANYSET()) break; /* check here for DDXes that queue events during Block/Wakeup */ if (*checkForInput[0] != *checkForInput[1]) diff --git a/os/connection.c b/os/connection.c index 488672c..cfe641a 100644 --- a/os/connection.c +++ b/os/connection.c @@ -47,8 +47,8 @@ SOFTWARE. * Stuff to create connections --- OS dependent * * EstablishNewConnections, CreateWellKnownSockets, ResetWellKnownSockets, - * CloseDownConnection, CheckConnections, AddEnabledDevice, - * RemoveEnabledDevice, OnlyListToOneClient, + * CloseDownConnection, CheckConnections + * OnlyListToOneClient, * ListenToAllClients, * * (WaitForSomething is in its own file) @@ -121,7 +121,6 @@ SOFTWARE. static int lastfdesc; /* maximum file descriptor */ -fd_set EnabledDevices; /* mask for input devices that are on */ fd_set NotifyReadFds; /* mask for other file descriptors */ fd_set NotifyWriteFds; /* mask for other write file descriptors */ fd_set AllSockets; /* select on this */ @@ -1043,36 +1042,6 @@ CloseDownConnection(ClientPtr client) AuditF("client %d disconnected\n", client->index); } -void -AddGeneralSocket(int fd) -{ -FD_SET(fd, ); -if (GrabInProgress) -FD_SET(fd, ); -} - -void -AddEnabledDevice(int fd) -{ -FD_SET(fd, ); -AddGeneralSocket(fd); -} - -void -RemoveGeneralSocket(int fd) -{ -FD_CLR(fd, ); -if (GrabInProgress) -FD_CLR(fd, ); -} - -void -RemoveEnabledDevice(int fd) -{ -FD_CLR(fd, ); -RemoveGeneralSocket(fd); -} - struct notify_fd { struct xorg_list list; int fd; @@ -1130,9 +1099,13 @@ SetNotifyFd(int fd, NotifyFdProcPtr notify, int mask, void *data) if (changes & X_NOTIFY_READ) { if (mask & X_NOTIFY_READ) { FD_SET(fd, ); -AddGeneralSocket(fd); +FD_SET(fd, ); +if (GrabInProgress) +FD_SET(fd, ); } else { -RemoveGeneralSocket(fd); +FD_CLR(fd, ); +if (GrabInProgress) +FD_CLR(fd, ); FD_CLR(fd, ); } } -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 04/23] dmx: Switch from select(2) to poll(2) for input
Signed-off-by: Keith Packard--- hw/dmx/input/lnx-ms.c | 19 ++- hw/dmx/input/lnx-ps2.c | 12 +--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/dmx/input/lnx-ms.c b/hw/dmx/input/lnx-ms.c index 621f0fe..3d028be 100644 --- a/hw/dmx/input/lnx-ms.c +++ b/hw/dmx/input/lnx-ms.c @@ -76,6 +76,7 @@ #include #include #include +#include /*/ /* Define some macros to make it easier to move this file to another @@ -120,10 +121,11 @@ static int msLinuxReadBytes(int fd, unsigned char *buf, int len, int min) { int n, tot; -fd_set set; -struct timeval tv; +struct pollfd poll_fd; tot = 0; +poll_fd.fd = fd; +poll_fd.events = POLLIN; while (len) { n = read(fd, buf, len); if (n > 0) { @@ -133,11 +135,7 @@ msLinuxReadBytes(int fd, unsigned char *buf, int len, int min) } if (tot % min == 0) break; -FD_ZERO(); -FD_SET(fd, ); -tv.tv_sec = 0; -tv.tv_usec = 100 * 1000; -n = select(fd + 1, , 0, 0, ); +n = poll(_fd, 1, 100); if (n <= 0) break; } @@ -246,7 +244,8 @@ msLinuxInit(DevicePtr pDev) if (tcgetattr(priv->fd, >tty) < 0) FATAL1("msLinuxInit: tcgetattr failed (%s)\n", strerror(errno)); -write(priv->fd, "*n", 2); /* 1200 baud */ +i = write(priv->fd, "*n", 2); /* 1200 baud */ +(void) i; usleep(10); } @@ -256,6 +255,7 @@ msLinuxOn(DevicePtr pDev) { GETPRIV; struct termios nTty; +int i; if (priv->fd < 0) msLinuxInit(pDev); @@ -273,7 +273,8 @@ msLinuxOn(DevicePtr pDev) cfsetospeed(, B1200); if (tcsetattr(priv->fd, TCSANOW, ) < 0) FATAL1("msLinuxInit: tcsetattr failed (%s)\n", strerror(errno)); -write(priv->fd, "*V", 2); /* 2 button 3 byte protocol */ +i = write(priv->fd, "*V", 2); /* 2 button 3 byte protocol */ +(void) i; return priv->fd; } diff --git a/hw/dmx/input/lnx-ps2.c b/hw/dmx/input/lnx-ps2.c index dd70cb8..834beb0 100644 --- a/hw/dmx/input/lnx-ps2.c +++ b/hw/dmx/input/lnx-ps2.c @@ -73,6 +73,7 @@ #include #include #include +#include /*/ /* Define some macros to make it easier to move this file to another @@ -116,9 +117,10 @@ static int ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min) { int n, tot; -fd_set set; -struct timeval tv; +struct pollfd poll_fd; +poll_fd.fd = fd; +poll_fd.events = POLLIN; tot = 0; while (len) { n = read(fd, buf, len); @@ -129,11 +131,7 @@ ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min) } if (tot % min == 0) break; -FD_ZERO(); -FD_SET(fd, ); -tv.tv_sec = 0; -tv.tv_usec = 100 * 1000; -n = select(fd + 1, , 0, 0, ); +n = poll(_fd, 1, 100); if (n <= 0) break; } -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 23/23] os: Leave stdin and stdout open
There's no reason to close these now that we don't care what file descriptors we use. Signed-off-by: Keith Packard--- os/osinit.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/os/osinit.c b/os/osinit.c index 6ec2f11..e269957 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -221,17 +221,6 @@ OsInit(void) #endif #if !defined(XQUARTZ)/* STDIN is already /dev/null and STDOUT/STDERR is managed by console_redirect.c */ -# if defined(__APPLE__) -int devnullfd = open(devnull, O_RDWR, 0); -assert(devnullfd > 2); - -dup2(devnullfd, STDIN_FILENO); -dup2(devnullfd, STDOUT_FILENO); -close(devnullfd); -# elif !defined(__CYGWIN__) -fclose(stdin); -fclose(stdout); -# endif /* * If a write of zero bytes to stderr returns non-zero, i.e. -1, * then writing to stderr failed, and we'll write somewhere else -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 05/23] os: Switch from select(2) to poll(2) in ErrorConnMax
This avoids problems if the file descriptor is too large for select(2) Signed-off-by: Keith Packard--- os/connection.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/os/connection.c b/os/connection.c index 4c1ba4b..488672c 100644 --- a/os/connection.c +++ b/os/connection.c @@ -892,16 +892,12 @@ ErrorConnMax(XtransConnInfo trans_conn) struct iovec iov[3]; char order = 0; int whichbyte = 1; -struct timeval waittime; -fd_set mask; +struct pollfd poll_fd; /* if these seems like a lot of trouble to go to, it probably is */ -waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND; -waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) * -(100 / MILLI_PER_SECOND); -FD_ZERO(); -FD_SET(fd, ); -(void) Select(fd + 1, , NULL, NULL, ); +poll_fd.fd = fd; +poll_fd.events = POLLIN; +(void) poll(_fd, 1, BOTIMEOUT); /* try to read the byte-order of the connection */ (void) _XSERVTransRead(trans_conn, , 1); if (order == 'l' || order == 'B' || order == 'r' || order == 'R') { -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 09/23] modesetting: Use passed-in fd for drm event monitoring NotifyFd callback
This is a cleanup, proposed by Adam Jackson, but wasn't merged with the original NotifyFD changes. Signed-off-by: Keith Packard--- hw/xfree86/drivers/modesetting/vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c index 869472a..0727887 100644 --- a/hw/xfree86/drivers/modesetting/vblank.c +++ b/hw/xfree86/drivers/modesetting/vblank.c @@ -253,7 +253,7 @@ ms_drm_socket_handler(int fd, int ready, void *data) if (data == NULL) return; -drmHandleEvent(ms->fd, >event_context); +drmHandleEvent(fd, >event_context); } /* -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 02/23] kdrive: switch from select(2) to poll(2)
This avoids fd limits Signed-off-by: Keith Packard--- hw/kdrive/fake/mouse.c | 1 - hw/kdrive/linux/evdev.c | 14 +- hw/kdrive/linux/mouse.c | 34 +- hw/kdrive/linux/ms.c| 13 + hw/kdrive/linux/ps2.c | 13 + hw/kdrive/linux/tslib.c | 1 - 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/hw/kdrive/fake/mouse.c b/hw/kdrive/fake/mouse.c index bb4c25e..564dae4 100644 --- a/hw/kdrive/fake/mouse.c +++ b/hw/kdrive/fake/mouse.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "inputstr.h" #include "scrnintstr.h" #include "kdrive.h" diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index 8415772..9590413 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "inputstr.h" #include "scrnintstr.h" #include "kdrive.h" @@ -444,6 +443,7 @@ EvdevKbdLeds(KdKeyboardInfo * ki, int leds) { struct input_event event; Kevdev *ke; +inti; if (!ki) return; @@ -458,22 +458,26 @@ EvdevKbdLeds(KdKeyboardInfo * ki, int leds) event.type = EV_LED; event.code = LED_CAPSL; event.value = leds & (1 << 0) ? 1 : 0; -write(ke->fd, (char *) , sizeof(event)); +i = write(ke->fd, (char *) , sizeof(event)); +(void) i; event.type = EV_LED; event.code = LED_NUML; event.value = leds & (1 << 1) ? 1 : 0; -write(ke->fd, (char *) , sizeof(event)); +i = write(ke->fd, (char *) , sizeof(event)); +(void) i; event.type = EV_LED; event.code = LED_SCROLLL; event.value = leds & (1 << 2) ? 1 : 0; -write(ke->fd, (char *) , sizeof(event)); +i = write(ke->fd, (char *) , sizeof(event)); +(void) i; event.type = EV_LED; event.code = LED_COMPOSE; event.value = leds & (1 << 3) ? 1 : 0; -write(ke->fd, (char *) , sizeof(event)); +i = write(ke->fd, (char *) , sizeof(event)); +(void) i; } static void diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c index 2bfe7f2..3508b17 100644 --- a/hw/kdrive/linux/mouse.c +++ b/hw/kdrive/linux/mouse.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "inputstr.h" #include "scrnintstr.h" #include "kdrive.h" @@ -47,23 +47,15 @@ typedef struct _kbufio { static Bool MouseWaitForReadable(int fd, int timeout) { -fd_set set; -struct timeval tv, *tp; +struct pollfd poll_fd; int n; CARD32 done; done = GetTimeInMillis() + timeout; +poll_fd.fd = fd; +poll_fd.events = POLLIN; for (;;) { -FD_ZERO(); -FD_SET(fd, ); -if (timeout == -1) -tp = 0; -else { -tv.tv_sec = timeout / 1000; -tv.tv_usec = (timeout % 1000) * 1000; -tp = -} -n = select(fd + 1, , 0, 0, tp); +n = poll(_fd, 1, timeout); if (n > 0) return TRUE; if (n < 0 && (errno == EAGAIN || errno == EINTR)) { @@ -139,20 +131,12 @@ MousePeekByte(Kbufio * b, int timeout) static Bool MouseWaitForWritable(int fd, int timeout) { -fd_set set; -struct timeval tv, *tp; +struct pollfd poll_fd; int n; -FD_ZERO(); -FD_SET(fd, ); -if (timeout == -1) -tp = 0; -else { -tv.tv_sec = timeout / 1000; -tv.tv_usec = (timeout % 1000) * 1000; -tp = -} -n = select(fd + 1, 0, , 0, tp); +poll_fd.fd = fd; +poll_fd.events = POLLOUT; +n = poll(_fd, 1, timeout); if (n > 0) return TRUE; return FALSE; diff --git a/hw/kdrive/linux/ms.c b/hw/kdrive/linux/ms.c index e82350a..79e6373 100644 --- a/hw/kdrive/linux/ms.c +++ b/hw/kdrive/linux/ms.c @@ -26,9 +26,9 @@ THE SOFTWARE. #endif #include #include +#include #include #include -#include #include "inputstr.h" #include "scrnintstr.h" #include "kdrive.h" @@ -37,9 +37,10 @@ static int MsReadBytes(int fd, char *buf, int len, int min) { int n, tot; -fd_set set; -struct timeval tv; +struct pollfd poll_fd; +poll_fd.fd = fd; +poll_fd.events = POLLIN; tot = 0; while (len) { n = read(fd, buf, len); @@ -50,11 +51,7 @@ MsReadBytes(int fd, char *buf, int len, int min) } if (tot % min == 0) break; -FD_ZERO(); -FD_SET(fd, ); -tv.tv_sec = 0; -tv.tv_usec = 100 * 1000; -n = select(fd + 1, , 0, 0, ); +n = poll(_fd, 1, 100); if (n <= 0) break; } diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c index e5417a5..5d4a8eb 100644 --- a/hw/kdrive/linux/ps2.c +++ b/hw/kdrive/linux/ps2.c @@ -25,7 +25,7 @@ #endif #include #include -#include +#include #include "inputstr.h" #include "scrnintstr.h" #include "kdrive.h" @@ -34,10 +34,11 @@ static int Ps2ReadBytes(int fd, char *buf, int len, int
[PATCH xserver] os: Increase default client buffer to 16kB
This matches a change made in xcb and improves performance for a small increase in memory usage. Signed-off-by: Keith Packard--- os/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/io.c b/os/io.c index 19a449a..d04ebd8 100644 --- a/os/io.c +++ b/os/io.c @@ -132,8 +132,8 @@ static OsCommPtr AvailableInput = (OsCommPtr) NULL; ((xBigReq *)(req))->length) #define MAX_TIMES_PER 10 -#define BUFSIZE 4096 -#define BUFWATERMARK 8192 +#define BUFSIZE 16384 +#define BUFWATERMARK 32768 /* * A lot of the code in this file manipulates a ConnectionInputPtr: -- 2.8.0.rc3 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver] dix: Call screen block/wakeup handlers closest to blocking [v3]
The screen block and wakeup handlers are the only ones which provide a well known ordering between the wrapping layers; placing these as close as possible to the server blocking provides a way for the driver to control the flow of execution correctly. Switch the shadow code to run in the screen block handler so that it now occurrs just before the server goes to sleep. Switch glamor to call down to the driver after it has executed its own block handler piece, in case the driver needs to perform additional flushing work after glamor has called glFlush. These changes ensure that the following modules update the screen in the correct order: animated cursors(uses RegisterBlockAndWakeupHandlers dynamically) composite (dynamic wrapping) misprite(dynamic wrapping) shadow (static wrapping) glamor (static wrapping) driver (static wrapping) It looks like there's still a bit of confusion between composite and misprite; if composite updates after misprite, then it's possible you'd exit the block handler chain with the cursor left hidden. To fix that, misprite should be wrapping during ScreenInit time and not unwrapping. And composite might as well join in that fun, just to make things consistent. [v2] Unwrap BlockHandler in shadowCloseScreen (ajax) [v3] ephyr: Use screen block handler for flushing changes ephyr needs to make sure it calls glXSwapBuffers after glamor finishes its rendering. As the screen block handler is now called last, we have to use that instead of a registered block/wakeup handler to make sure the GL rendering is done before we copy it to the front buffer. Signed-off-by: Keith Packard--- dix/dixutils.c | 23 +-- glamor/glamor.c | 6 +++--- hw/kdrive/ephyr/ephyr.c | 43 +++ hw/kdrive/ephyr/ephyr.h | 2 ++ miext/shadow/shadow.c | 20 +++- miext/shadow/shadow.h | 1 + 6 files changed, 53 insertions(+), 42 deletions(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index b6b0023..3d2e7a3 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -383,16 +383,19 @@ BlockHandler(void *pTimeout, void *pReadmask) int i, j; ++inHandler; -for (i = 0; i < screenInfo.numScreens; i++) -(*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], -pTimeout, pReadmask); -for (i = 0; i < screenInfo.numGPUScreens; i++) -(*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i], - pTimeout, pReadmask); for (i = 0; i < numHandlers; i++) if (!handlers[i].deleted) (*handlers[i].BlockHandler) (handlers[i].blockData, pTimeout, pReadmask); + +for (i = 0; i < screenInfo.numGPUScreens; i++) +(*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i], + pTimeout, pReadmask); + +for (i = 0; i < screenInfo.numScreens; i++) +(*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], +pTimeout, pReadmask); + if (handlerDeleted) { for (i = 0; i < numHandlers;) if (handlers[i].deleted) { @@ -418,16 +421,16 @@ WakeupHandler(int result, void *pReadmask) int i, j; ++inHandler; -for (i = numHandlers - 1; i >= 0; i--) -if (!handlers[i].deleted) -(*handlers[i].WakeupHandler) (handlers[i].blockData, - result, pReadmask); for (i = 0; i < screenInfo.numScreens; i++) (*screenInfo.screens[i]->WakeupHandler) (screenInfo.screens[i], result, pReadmask); for (i = 0; i < screenInfo.numGPUScreens; i++) (*screenInfo.gpuscreens[i]->WakeupHandler) (screenInfo.gpuscreens[i], result, pReadmask); +for (i = numHandlers - 1; i >= 0; i--) +if (!handlers[i].deleted) +(*handlers[i].WakeupHandler) (handlers[i].blockData, + result, pReadmask); if (handlerDeleted) { for (i = 0; i < numHandlers;) if (handlers[i].deleted) { diff --git a/glamor/glamor.c b/glamor/glamor.c index 62b5c3a..7d82ce8 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -264,13 +264,13 @@ _glamor_block_handler(ScreenPtr screen, void *timeout, void *readmask) { glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); +glamor_make_current(glamor_priv); +glFlush(); + screen->BlockHandler = glamor_priv->saved_procs.block_handler; screen->BlockHandler(screen, timeout, readmask); glamor_priv->saved_procs.block_handler = screen->BlockHandler; screen->BlockHandler =
Re: [PATCH xserver] randr: Adjust master's last set time with slaves
Hi, On 26-05-16 18:20, Nikhil Mahale wrote: In prime configurations master's last set time may not be latest and greatest, adjust it with slaves last set time, pick up greatest one. Otherwise xserver may end with events which has lastSetTime < lastConfigTime even if that's not the case and confuse xrandr client. Thanks, looks good to me now: Acked-by: Hans de GoedeRegards, Hans --- randr/randr.c | 9 + 1 file changed, 9 insertions(+) diff --git a/randr/randr.c b/randr/randr.c index 3aabb19..549f26c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -584,6 +584,15 @@ RRTellChanged(ScreenPtr pScreen) mastersp = pScrPriv; } +xorg_list_for_each_entry(iter, >output_slave_list, output_head) { +pSlaveScrPriv = rrGetScrPriv(iter); + +if (CompareTimeStamps(mastersp->lastSetTime, + pSlaveScrPriv->lastSetTime) == EARLIER) { +mastersp->lastSetTime = pSlaveScrPriv->lastSetTime; +} +} + if (mastersp->changed) { UpdateCurrentTimeIf(); if (mastersp->configChanged) { ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: API for using poll/epoll instead of select
Adam Jacksonwrites: > Exposing edge/level in ospoll_add is a bit funky, you're silently > degrading edge to level if the OS backend can't do edge. kqueue could do > it if the code were written, and I suspect win32's WaitForMultipleObjects > could be made to do it if we got really wild, but Solaris doesn't have an > edge-triggered API for this at all (does have port_create which is > basically level-triggered epoll, but). Good comment here. poll(2) doesn't have edge-triggered options either, so the ospoll code emulates that by remembering the previous value and not reporting when it hasn't changed. This requires a call to ospoll_reset_events in io.c to clear the previous value when input runs dry. > If the intent is that asking for edge is an indication that the caller > _can_ use edge-triggers but will work with either then I guess that's > fine. A comment to that effect would be good. Could do it this way as well, and would eliminate the ospoll_reset_events interface. The only cost would be extra calls to the callback for clients which have input and are not getting serviced, which is not a big deal as that doesn't actually happen all that often in normal X usage. dix handles this just fine; checking to see if the client is on the ready list before inserting it. Sounds like a good change to me as it will simplify the poll(2) interface. -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: API for using poll/epoll instead of select
On Wed, 2016-05-25 at 22:44 -0700, Keith Packard wrote: > It's similar to the NotifyFd interfaces added to the OS layer, but has > the ability to support both level-triggered and edge-triggered > notifications. Using edge-triggered notifications along with epoll > reduces the notifications received from the kernel when the server is > busy as only newly ready clients appear. Exposing edge/level in ospoll_add is a bit funky, you're silently degrading edge to level if the OS backend can't do edge. kqueue could do it if the code were written, and I suspect win32's WaitForMultipleObjects could be made to do it if we got really wild, but Solaris doesn't have an edge-triggered API for this at all (does have port_create which is basically level-triggered epoll, but). If the intent is that asking for edge is an indication that the caller _can_ use edge-triggers but will work with either then I guess that's fine. A comment to that effect would be good. - ajax ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver] randr: Adjust master's last set time with slaves
In prime configurations master's last set time may not be latest and greatest, adjust it with slaves last set time, pick up greatest one. Otherwise xserver may end with events which has lastSetTime < lastConfigTime even if that's not the case and confuse xrandr client. --- randr/randr.c | 9 + 1 file changed, 9 insertions(+) diff --git a/randr/randr.c b/randr/randr.c index 3aabb19..549f26c 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -584,6 +584,15 @@ RRTellChanged(ScreenPtr pScreen) mastersp = pScrPriv; } +xorg_list_for_each_entry(iter, >output_slave_list, output_head) { +pSlaveScrPriv = rrGetScrPriv(iter); + +if (CompareTimeStamps(mastersp->lastSetTime, + pSlaveScrPriv->lastSetTime) == EARLIER) { +mastersp->lastSetTime = pSlaveScrPriv->lastSetTime; +} +} + if (mastersp->changed) { UpdateCurrentTimeIf(); if (mastersp->configChanged) { -- 2.8.2 --- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. --- ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/3] glamor: Disable logic ops when doing compositing [v3]
Michel Dänzerwrites: > The glamor_set_composite_texture related change in this patch needs to > be moved to patch 3, or this patch fails to build. With that fixed, > patches 1 & 2 are That was also mentioned by Emil Velikov and was fixed in [v4] 1/3 and [v2] 3/3 > Reviewed-by: Michel Dänzer > > and patch 3 is > > Tested-by: Michel Dänzer Thanks! Pushed to master. -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/9] xfree86: Set xf86CrtcConfigRec cursor pointer to NULL in HideCursor
Peter Huttererwrites: >> Signed-off-by: Keith Packard > > Acked-by: Peter Hutterer Merged. b64108f..f5670b4 master -> master -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [xserver-xorg][PATCH V2 1/1] xwayland-shm: block signals during fallocate
On 25 May 2016 at 08:41, Ian Raywrote: > posix_fallocate() does an explicit rollback if it gets EINTR, and > this is a problem on slow systems because when the allocation size > is sufficiently large posix_fallocate() will always be interrupted > by the smart scheduler's SIGALRM. > > Changes since v1 - big comment in the code to explain what is going on > > Signed-off-by: Ian Ray Acked-by: Daniel Stone ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] glamor: Cannot use copies when accessing outside of composite source
Hi, On 26-05-16 12:04, Michel Dänzer wrote: From: Michel DänzerCommit b64108fa ("glamor: Check for composite operations which are equivalent to copies") failed to copy conditions from exaComposite which ensure that the composite operation doesn't access outside of the source picture. This fixes rendercheck regressions from the commit above. Signed-off-by: Michel Dänzer I was hoping that this fixed the thunderbird regressions I was seeing after commit b64108fa, but unfortunately it does not. Apologies for jumping the gun on the previous patch by submitting it without appropriate testing with rendercheck. There is one regression left with this patch (blend test on a8), that one is fixed by https://patchwork.freedesktop.org/patch/87222/ . I've added that one to my local master clone too, still not fixed. The problem is that thunderbird and any thunderbird dialogs simply show up as completely gray windows without anything in them. Reproducing is as simple as starting thunderbird. I'm seeing this on a skylake system using the igpu with modesetting + glamor. For now I'm running xserver-master with b64108fa reverted, let me know if you need to me test any potential fixes for this. Regards, Hans glamor/glamor_render.c | 27 +++ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 9c5cca6..f1bfe03 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -1424,18 +1424,21 @@ glamor_composite_clipped_region(CARD8 op, if (!mask && !source->alphaMap && !dest->alphaMap && source->pDrawable && !source->transform && ((op == PictOpSrc - && ((source->format == dest->format - || (PICT_FORMAT_COLOR(dest->format) - && PICT_FORMAT_COLOR(source->format) - && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), - PICT_FORMAT_TYPE(source->format), - 0, - PICT_FORMAT_R(source->format), - PICT_FORMAT_G(source->format), - PICT_FORMAT_B(source->format - || (op == PictOpOver - && source->format == dest->format - && !PICT_FORMAT_A(source->format)) { + && (source->format == dest->format + || (PICT_FORMAT_COLOR(dest->format) + && PICT_FORMAT_COLOR(source->format) + && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), + PICT_FORMAT_TYPE(source->format), +0, + PICT_FORMAT_R(source->format), + PICT_FORMAT_G(source->format), + PICT_FORMAT_B(source->format) +|| (op == PictOpOver +&& source->format == dest->format +&& !PICT_FORMAT_A(source->format))) +&& x_source >= 0 && y_source >= 0 +&& (x_source + width) <= source->pDrawable->width +&& (y_source + height) <= source->pDrawable->height) { glamor_copy(source->pDrawable, dest->pDrawable, NULL, box, nbox, x_source - x_dest, y_source - y_dest, FALSE, FALSE, 0, NULL); ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] randr: Adjust master's last set time with slaves
Hi, On 20-05-16 07:01, Nikhil Mahale wrote: In prime configurations master's last set time may not be latest and greatest, adjust it with slaves last set time, pick up greatest one. Otherwise xserver may end with events which has lastSetTime < lastConfigTime even if that's not the case and confuse xrandr client. Signed-off-by: Nikhil Mahale--- randr/randr.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/randr/randr.c b/randr/randr.c index 3aabb19..c07def1 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -568,6 +568,7 @@ RRSetChanged(ScreenPtr pScreen) void RRTellChanged(ScreenPtr pScreen) { +ScreenPtr slave; We already declare a "ScreenPtr iter" which is used in other parts of this function to iterate over the output_slave_list, please use that instead. Regards, Hans ScreenPtr master; rrScrPriv(pScreen); rrScrPrivPtr mastersp; @@ -584,6 +585,15 @@ RRTellChanged(ScreenPtr pScreen) mastersp = pScrPriv; } +xorg_list_for_each_entry(slave, >output_slave_list, output_head) { +pSlaveScrPriv = rrGetScrPriv(slave); + +if (CompareTimeStamps(mastersp->lastSetTime, + pSlaveScrPriv->lastSetTime) == EARLIER) { +mastersp->lastSetTime = pSlaveScrPriv->lastSetTime; +} +} + if (mastersp->changed) { UpdateCurrentTimeIf(); if (mastersp->configChanged) { ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/3] glamor: Disable logic ops when doing compositing [v3]
On 17.05.2016 06:05, Keith Packard wrote: > Michel Dänzerwrites: > >> https://bugs.freedesktop.org/show_bug.cgi?id=63397#c24 > > Some day I'll think to look at bugzilla when I fix a bug :-) > > I've added a comment and copy of the patch to that bug. The glamor_set_composite_texture related change in this patch needs to be moved to patch 3, or this patch fails to build. With that fixed, patches 1 & 2 are Reviewed-by: Michel Dänzer and patch 3 is Tested-by: Michel Dänzer -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer signature.asc Description: OpenPGP digital signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver] glamor: Cannot use copies when accessing outside of composite source
From: Michel DänzerCommit b64108fa ("glamor: Check for composite operations which are equivalent to copies") failed to copy conditions from exaComposite which ensure that the composite operation doesn't access outside of the source picture. This fixes rendercheck regressions from the commit above. Signed-off-by: Michel Dänzer --- Apologies for jumping the gun on the previous patch by submitting it without appropriate testing with rendercheck. There is one regression left with this patch (blend test on a8), that one is fixed by https://patchwork.freedesktop.org/patch/87222/ . glamor/glamor_render.c | 27 +++ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 9c5cca6..f1bfe03 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -1424,18 +1424,21 @@ glamor_composite_clipped_region(CARD8 op, if (!mask && !source->alphaMap && !dest->alphaMap && source->pDrawable && !source->transform && ((op == PictOpSrc - && ((source->format == dest->format - || (PICT_FORMAT_COLOR(dest->format) - && PICT_FORMAT_COLOR(source->format) - && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), - PICT_FORMAT_TYPE(source->format), - 0, - PICT_FORMAT_R(source->format), - PICT_FORMAT_G(source->format), - PICT_FORMAT_B(source->format - || (op == PictOpOver - && source->format == dest->format - && !PICT_FORMAT_A(source->format)) { + && (source->format == dest->format + || (PICT_FORMAT_COLOR(dest->format) + && PICT_FORMAT_COLOR(source->format) + && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), + PICT_FORMAT_TYPE(source->format), +0, + PICT_FORMAT_R(source->format), + PICT_FORMAT_G(source->format), + PICT_FORMAT_B(source->format) +|| (op == PictOpOver +&& source->format == dest->format +&& !PICT_FORMAT_A(source->format))) +&& x_source >= 0 && y_source >= 0 +&& (x_source + width) <= source->pDrawable->width +&& (y_source + height) <= source->pDrawable->height) { glamor_copy(source->pDrawable, dest->pDrawable, NULL, box, nbox, x_source - x_dest, y_source - y_dest, FALSE, FALSE, 0, NULL); -- 2.8.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] randr: Do not check the screen size bound for gpu screens
On 26.05.2016 11:21, Nikhil Mahale wrote: > On 05/26/2016 01:31 PM, Timo Aaltonen wrote: >> On 20.05.2016 08:00, Nikhil Mahale wrote: >>> For gpu screen, CrtcSet set/adjust the master screen size along >>> mode in following callstack - >>> >>> ProcRRSetCrtcConfig() >>> | >>> -> RRCrtcSet() >>> | >>> -> rrCheckPixmapBounding() >>> | >>> -> pScrPriv->rrScreenSetSize() >>> >>> Checking screen size bound for gpus screen cause some configurations >>> to fails, e.g >>> >>> $ xrandr --output eDP --mode 1920x1080 --pos 0x0 --output HDMI \ >>> --mode 2560x1440 --pos 0x0 >>> >>> Here xrandr utility first sets screen size to 2560x1440 which >>> gets resized to 1920x1080 on RRSetCrtcConfig request for eDP, >>> and then RRSetCrtcConfig request for HDMI fails because >>> of failure of screen bound check. >>> >>> Signed-off-by: Nikhil Mahale>> >> I've tried to come up with a test that would hang/crash the xserver >> reliably, but failed. It usually takes a number of cycles through >> mirrored/extended/external-only modes, or switching between >> external-only and mirrored. Anyway, the impact is that on intel+nvidia >> hybrid the server can crash or hang or just fail to set the mode without >> these two patches. >> > > Sorry Timo, I don't think I understand what you want to say. This patch > was not intended to fix hang/crash, it simple fixes modeset failure for > the use cases like I mentioned in description of patch. > > The second "[PATCH xserver] randr: Adjust master's last set time with > slaves" fixes XRandr's client confusion about lastConfigTimes and > lastSetTime, I seen client was repeatedly sending modeset request > because each time it gets lastSetTime < lastConfigTime. > > Both the patches only impacting prime configurations. It was for whoever reviews these. The server certainly can crash without the patches with prime setup, according to my tests.. -- t ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] randr: Do not check the screen size bound for gpu screens
On 05/26/2016 01:31 PM, Timo Aaltonen wrote: On 20.05.2016 08:00, Nikhil Mahale wrote: For gpu screen, CrtcSet set/adjust the master screen size along mode in following callstack - ProcRRSetCrtcConfig() | -> RRCrtcSet() | -> rrCheckPixmapBounding() | -> pScrPriv->rrScreenSetSize() Checking screen size bound for gpus screen cause some configurations to fails, e.g $ xrandr --output eDP --mode 1920x1080 --pos 0x0 --output HDMI \ --mode 2560x1440 --pos 0x0 Here xrandr utility first sets screen size to 2560x1440 which gets resized to 1920x1080 on RRSetCrtcConfig request for eDP, and then RRSetCrtcConfig request for HDMI fails because of failure of screen bound check. Signed-off-by: Nikhil MahaleI've tried to come up with a test that would hang/crash the xserver reliably, but failed. It usually takes a number of cycles through mirrored/extended/external-only modes, or switching between external-only and mirrored. Anyway, the impact is that on intel+nvidia hybrid the server can crash or hang or just fail to set the mode without these two patches. Sorry Timo, I don't think I understand what you want to say. This patch was not intended to fix hang/crash, it simple fixes modeset failure for the use cases like I mentioned in description of patch. The second "[PATCH xserver] randr: Adjust master's last set time with slaves" fixes XRandr's client confusion about lastConfigTimes and lastSetTime, I seen client was repeatedly sending modeset request because each time it gets lastSetTime < lastConfigTime. Both the patches only impacting prime configurations. Thanks, Nikhil Mahale --- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. --- ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver] randr: Do not check the screen size bound for gpu screens
On 20.05.2016 08:00, Nikhil Mahale wrote: > For gpu screen, CrtcSet set/adjust the master screen size along > mode in following callstack - > > ProcRRSetCrtcConfig() > | > -> RRCrtcSet() > | > -> rrCheckPixmapBounding() > | > -> pScrPriv->rrScreenSetSize() > > Checking screen size bound for gpus screen cause some configurations > to fails, e.g > > $ xrandr --output eDP --mode 1920x1080 --pos 0x0 --output HDMI \ > --mode 2560x1440 --pos 0x0 > > Here xrandr utility first sets screen size to 2560x1440 which > gets resized to 1920x1080 on RRSetCrtcConfig request for eDP, > and then RRSetCrtcConfig request for HDMI fails because > of failure of screen bound check. > > Signed-off-by: Nikhil MahaleI've tried to come up with a test that would hang/crash the xserver reliably, but failed. It usually takes a number of cycles through mirrored/extended/external-only modes, or switching between external-only and mirrored. Anyway, the impact is that on intel+nvidia hybrid the server can crash or hang or just fail to set the mode without these two patches. -- t ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Performance benefit of epoll over poll
epoll is designed to reduce the cost of having many file descriptors in a process which are mostly idle. The kernel only reports data about active descriptors. I changed MAXCLIENTS from 512 to 2048 so I could get some 'worst case' measurements. I figured x11perf -noop would be a nice test, and then when I saw what the 'Sync time adjustment' was in these situations, I wondered what x11perf -noop -sync would do and was surprised to see that the effect was even larger. Clearly, calling poll with thousands of file descriptors is expensive... -noop -noop -sync clients clients 1 505 2047 1 505 2047 epoll 53e653e653e6140e3 140e3 140e3 poll53e650e634e6140e312e3 2e3 select 43e643e6140e312e3 So, epoll clearly wins when we have a bunch of clients, but both poll and epoll are winning over select because we aren't sending 512 file descriptors into the kernel for it to mull over every time we call select. I want to clean up the patches on my epoll branch before trying to get them merged; there are a couple of false starts left in the branch before I figured out the interface I wanted. -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 3/4] dix: Convert ResourceClientBits to a variable
Mark Ketteniswrites: > Hmm. This is marked as _X_EXPORT, so presumably part of the driver > ABI. Exporting variables like this is generally a bad idea, at least > for ELF DSOs. Copy relocations and all that. even libc exposes a pile of data, including stdin, stderr and stdout, and that seems to work just fine. Switching this from a #define to a exported variable makes the change minimally invasive while solving the problem nicely. Anything more complicated will be harder to understand and end up slower than this solution. I don't see any benefit there. Reviewed-by: Keith Packard -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel