summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-11-11 22:02:01 -0800
committerAdam Jackson <ajax@redhat.com>2015-12-01 13:54:54 -0500
commite10ba9e4b52269b2ac75c4802dce4ca47d169657 (patch)
tree653de4bab7b3ca2b2b1fd41aaaf35af81e78c69f
parentc7f4aef8f45e500c900d59f68c653477148907ea (diff)
Remove non-smart scheduler. Don't require setitimer.
This allows the server to call GetTimeInMillis() after each request is processed to avoid needing setitimer. -dumbSched now turns off the setitimer. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--configure.ac2
-rw-r--r--dix/dispatch.c17
-rw-r--r--include/dix-config.h.in3
-rw-r--r--include/dixstruct.h6
-rw-r--r--os/WaitFor.c14
-rw-r--r--os/io.c13
-rw-r--r--os/utils.c38
7 files changed, 45 insertions, 48 deletions
diff --git a/configure.ac b/configure.ac
index 14a5bb8dd..2e38efac3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -218,7 +218,7 @@ AC_SUBST(DLOPEN_LIBS)
dnl Checks for library functions.
AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
- mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext])
+ mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext setitimer])
AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup])
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 2c201245a..53032dc64 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -222,11 +222,11 @@ UpdateCurrentTimeIf(void)
#define SMART_SCHEDULE_DEFAULT_INTERVAL 5
#define SMART_SCHEDULE_MAX_SLICE 15
-#if defined(WIN32) && !defined(__CYGWIN__)
-Bool SmartScheduleDisable = TRUE;
-#else
-Bool SmartScheduleDisable = FALSE;
+#ifdef HAVE_SETITIMER
+#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE HAVE_SETITIMER
+Bool SmartScheduleSignalEnable = SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE;
#endif
+
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
@@ -358,7 +358,7 @@ Dispatch(void)
nready = WaitForSomething(clientReady);
- if (nready && !SmartScheduleDisable) {
+ if (nready) {
clientReady[0] = SmartScheduleClient(clientReady, nready);
nready = 1;
}
@@ -386,8 +386,8 @@ Dispatch(void)
ProcessInputEvents();
FlushIfCriticalOutputPending();
- if (!SmartScheduleDisable &&
- (SmartScheduleTime - start_tick) >= SmartScheduleSlice) {
+ if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice)
+ {
/* Penalize clients which consume ticks */
if (client->smart_priority > SMART_MIN_PRIORITY)
client->smart_priority--;
@@ -431,6 +431,9 @@ Dispatch(void)
(*client->requestVector[client->majorOp]) (client);
XaceHookAuditEnd(client, result);
}
+ if (!SmartScheduleSignalEnable)
+ SmartScheduleTime = GetTimeInMillis();
+
#ifdef XSERVER_DTRACE
if (XSERVER_REQUEST_DONE_ENABLED())
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 112ab952f..940d2b7e2 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -518,4 +518,7 @@
/* Define if no local socket credentials interface exists */
#undef NO_LOCAL_CLIENT_CRED
+/* Have setitimer support */
+#undef HAVE_SETITIMER
+
#endif /* _DIX_CONFIG_H_ */
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 757506623..8e70ae1fa 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -130,7 +130,11 @@ extern long SmartScheduleTime;
extern long SmartScheduleInterval;
extern long SmartScheduleSlice;
extern long SmartScheduleMaxSlice;
-extern Bool SmartScheduleDisable;
+#if HAVE_SETITIMER
+extern Bool SmartScheduleSignalEnable;
+#else
+#define SmartScheduleSignalEnable FALSE
+#endif
extern void SmartScheduleStartTimer(void);
extern void SmartScheduleStopTimer(void);
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 993c14e52..732543086 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -175,16 +175,10 @@ WaitForSomething(int *pClientsReady)
if (workQueue)
ProcessWorkQueue();
if (XFD_ANYSET(&ClientsWithInput)) {
- if (!SmartScheduleDisable) {
- someReady = TRUE;
- waittime.tv_sec = 0;
- waittime.tv_usec = 0;
- wt = &waittime;
- }
- else {
- XFD_COPYSET(&ClientsWithInput, &clientsReadable);
- break;
- }
+ someReady = TRUE;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 0;
+ wt = &waittime;
}
if (someReady) {
XFD_COPYSET(&AllSockets, &LastSelectMask);
diff --git a/os/io.c b/os/io.c
index 55644eaf3..971fdc951 100644
--- a/os/io.c
+++ b/os/io.c
@@ -462,23 +462,14 @@ ReadRequestFromClient(ClientPtr client)
)
FD_SET(fd, &ClientsWithInput);
else {
- if (!SmartScheduleDisable)
- FD_CLR(fd, &ClientsWithInput);
- else
- YieldControlNoInput(fd);
+ FD_CLR(fd, &ClientsWithInput);
}
}
else {
if (!gotnow)
AvailableInput = oc;
- if (!SmartScheduleDisable)
- FD_CLR(fd, &ClientsWithInput);
- else
- YieldControlNoInput(fd);
+ FD_CLR(fd, &ClientsWithInput);
}
- if (SmartScheduleDisable)
- if (++timesThisConnection >= MAX_TIMES_PER)
- YieldControl();
if (move_header) {
request = (xReq *) oci->bufptr;
oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
diff --git a/os/utils.c b/os/utils.c
index b45719e26..ef7a2cc21 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -71,7 +71,6 @@ __stdcall unsigned long GetTickCount(void);
#if !defined(WIN32) || !defined(__MINGW32__)
#include <sys/time.h>
#include <sys/resource.h>
-# define SMART_SCHEDULE_POSSIBLE
#endif
#include "misc.h"
#include <X11/X.h>
@@ -1005,10 +1004,11 @@ ProcessCommandLine(int argc, char *argv[])
i = skip - 1;
}
#endif
-#ifdef SMART_SCHEDULE_POSSIBLE
+#if HAVE_SETITIMER
else if (strcmp(argv[i], "-dumbSched") == 0) {
- SmartScheduleDisable = TRUE;
+ SmartScheduleSignalEnable = FALSE;
}
+#endif
else if (strcmp(argv[i], "-schedInterval") == 0) {
if (++i < argc) {
SmartScheduleInterval = atoi(argv[i]);
@@ -1024,7 +1024,6 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
-#endif
else if (strcmp(argv[i], "-render") == 0) {
if (++i < argc) {
int policy = PictureParseCmapPolicy(argv[i]);
@@ -1208,10 +1207,10 @@ XNFstrdup(const char *s)
void
SmartScheduleStopTimer(void)
{
-#ifdef SMART_SCHEDULE_POSSIBLE
+#if HAVE_SETITIMER
struct itimerval timer;
- if (SmartScheduleDisable)
+ if (!SmartScheduleSignalEnable)
return;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 0;
@@ -1224,10 +1223,10 @@ SmartScheduleStopTimer(void)
void
SmartScheduleStartTimer(void)
{
-#ifdef SMART_SCHEDULE_POSSIBLE
+#if HAVE_SETITIMER
struct itimerval timer;
- if (SmartScheduleDisable)
+ if (!SmartScheduleSignalEnable)
return;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
@@ -1237,6 +1236,7 @@ SmartScheduleStartTimer(void)
#endif
}
+#if HAVE_SETITIMER
static void
SmartScheduleTimer(int sig)
{
@@ -1247,10 +1247,9 @@ static int
SmartScheduleEnable(void)
{
int ret = 0;
-#ifdef SMART_SCHEDULE_POSSIBLE
struct sigaction act;
- if (SmartScheduleDisable)
+ if (!SmartScheduleSignalEnable)
return 0;
memset((char *) &act, 0, sizeof(struct sigaction));
@@ -1261,7 +1260,6 @@ SmartScheduleEnable(void)
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGALRM);
ret = sigaction(SIGALRM, &act, 0);
-#endif
return ret;
}
@@ -1269,10 +1267,9 @@ static int
SmartSchedulePause(void)
{
int ret = 0;
-#ifdef SMART_SCHEDULE_POSSIBLE
struct sigaction act;
- if (SmartScheduleDisable)
+ if (!SmartScheduleSignalEnable)
return 0;
memset((char *) &act, 0, sizeof(struct sigaction));
@@ -1280,20 +1277,19 @@ SmartSchedulePause(void)
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
ret = sigaction(SIGALRM, &act, 0);
-#endif
return ret;
}
+#endif
void
SmartScheduleInit(void)
{
- if (SmartScheduleDisable)
- return;
-
+#if HAVE_SETITIMER
if (SmartScheduleEnable() < 0) {
perror("sigaction for smart scheduler");
- SmartScheduleDisable = TRUE;
+ SmartScheduleSignalEnable = FALSE;
}
+#endif
}
#ifdef SIG_BLOCK
@@ -1490,6 +1486,7 @@ Popen(const char *command, const char *type)
}
/* Ignore the smart scheduler while this is going on */
+#if HAVE_SETITIMER
if (SmartSchedulePause() < 0) {
close(pdes[0]);
close(pdes[1]);
@@ -1497,14 +1494,17 @@ Popen(const char *command, const char *type)
perror("signal");
return NULL;
}
+#endif
switch (pid = fork()) {
case -1: /* error */
close(pdes[0]);
close(pdes[1]);
free(cur);
+#if HAVE_SETITIMER
if (SmartScheduleEnable() < 0)
perror("signal");
+#endif
return NULL;
case 0: /* child */
if (setgid(getgid()) == -1)
@@ -1678,10 +1678,12 @@ Pclose(void *iop)
/* allow EINTR again */
OsReleaseSignals();
+#if HAVE_SETITIMER
if (SmartScheduleEnable() < 0) {
perror("signal");
return -1;
}
+#endif
return pid == -1 ? -1 : pstat;
}