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>
This commit is contained in:
Keith Packard 2015-11-11 22:02:01 -08:00 committed by Adam Jackson
parent c7f4aef8f4
commit e10ba9e4b5
7 changed files with 45 additions and 48 deletions

View File

@ -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>]])

View File

@ -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),

View File

@ -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_ */

View File

@ -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);

View File

@ -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);

13
os/io.c
View File

@ -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));

View File

@ -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;
}