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:
parent
c7f4aef8f4
commit
e10ba9e4b5
|
@ -218,7 +218,7 @@ AC_SUBST(DLOPEN_LIBS)
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
|
AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
|
||||||
getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
|
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_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup])
|
||||||
|
|
||||||
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
|
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
|
||||||
|
|
|
@ -222,11 +222,11 @@ UpdateCurrentTimeIf(void)
|
||||||
#define SMART_SCHEDULE_DEFAULT_INTERVAL 5
|
#define SMART_SCHEDULE_DEFAULT_INTERVAL 5
|
||||||
#define SMART_SCHEDULE_MAX_SLICE 15
|
#define SMART_SCHEDULE_MAX_SLICE 15
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
#ifdef HAVE_SETITIMER
|
||||||
Bool SmartScheduleDisable = TRUE;
|
#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE HAVE_SETITIMER
|
||||||
#else
|
Bool SmartScheduleSignalEnable = SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE;
|
||||||
Bool SmartScheduleDisable = FALSE;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
||||||
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
||||||
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
|
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
|
||||||
|
@ -358,7 +358,7 @@ Dispatch(void)
|
||||||
|
|
||||||
nready = WaitForSomething(clientReady);
|
nready = WaitForSomething(clientReady);
|
||||||
|
|
||||||
if (nready && !SmartScheduleDisable) {
|
if (nready) {
|
||||||
clientReady[0] = SmartScheduleClient(clientReady, nready);
|
clientReady[0] = SmartScheduleClient(clientReady, nready);
|
||||||
nready = 1;
|
nready = 1;
|
||||||
}
|
}
|
||||||
|
@ -386,8 +386,8 @@ Dispatch(void)
|
||||||
ProcessInputEvents();
|
ProcessInputEvents();
|
||||||
|
|
||||||
FlushIfCriticalOutputPending();
|
FlushIfCriticalOutputPending();
|
||||||
if (!SmartScheduleDisable &&
|
if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice)
|
||||||
(SmartScheduleTime - start_tick) >= SmartScheduleSlice) {
|
{
|
||||||
/* Penalize clients which consume ticks */
|
/* Penalize clients which consume ticks */
|
||||||
if (client->smart_priority > SMART_MIN_PRIORITY)
|
if (client->smart_priority > SMART_MIN_PRIORITY)
|
||||||
client->smart_priority--;
|
client->smart_priority--;
|
||||||
|
@ -431,6 +431,9 @@ Dispatch(void)
|
||||||
(*client->requestVector[client->majorOp]) (client);
|
(*client->requestVector[client->majorOp]) (client);
|
||||||
XaceHookAuditEnd(client, result);
|
XaceHookAuditEnd(client, result);
|
||||||
}
|
}
|
||||||
|
if (!SmartScheduleSignalEnable)
|
||||||
|
SmartScheduleTime = GetTimeInMillis();
|
||||||
|
|
||||||
#ifdef XSERVER_DTRACE
|
#ifdef XSERVER_DTRACE
|
||||||
if (XSERVER_REQUEST_DONE_ENABLED())
|
if (XSERVER_REQUEST_DONE_ENABLED())
|
||||||
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
|
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
|
||||||
|
|
|
@ -518,4 +518,7 @@
|
||||||
/* Define if no local socket credentials interface exists */
|
/* Define if no local socket credentials interface exists */
|
||||||
#undef NO_LOCAL_CLIENT_CRED
|
#undef NO_LOCAL_CLIENT_CRED
|
||||||
|
|
||||||
|
/* Have setitimer support */
|
||||||
|
#undef HAVE_SETITIMER
|
||||||
|
|
||||||
#endif /* _DIX_CONFIG_H_ */
|
#endif /* _DIX_CONFIG_H_ */
|
||||||
|
|
|
@ -130,7 +130,11 @@ extern long SmartScheduleTime;
|
||||||
extern long SmartScheduleInterval;
|
extern long SmartScheduleInterval;
|
||||||
extern long SmartScheduleSlice;
|
extern long SmartScheduleSlice;
|
||||||
extern long SmartScheduleMaxSlice;
|
extern long SmartScheduleMaxSlice;
|
||||||
extern Bool SmartScheduleDisable;
|
#if HAVE_SETITIMER
|
||||||
|
extern Bool SmartScheduleSignalEnable;
|
||||||
|
#else
|
||||||
|
#define SmartScheduleSignalEnable FALSE
|
||||||
|
#endif
|
||||||
extern void SmartScheduleStartTimer(void);
|
extern void SmartScheduleStartTimer(void);
|
||||||
extern void SmartScheduleStopTimer(void);
|
extern void SmartScheduleStopTimer(void);
|
||||||
|
|
||||||
|
|
|
@ -175,17 +175,11 @@ WaitForSomething(int *pClientsReady)
|
||||||
if (workQueue)
|
if (workQueue)
|
||||||
ProcessWorkQueue();
|
ProcessWorkQueue();
|
||||||
if (XFD_ANYSET(&ClientsWithInput)) {
|
if (XFD_ANYSET(&ClientsWithInput)) {
|
||||||
if (!SmartScheduleDisable) {
|
|
||||||
someReady = TRUE;
|
someReady = TRUE;
|
||||||
waittime.tv_sec = 0;
|
waittime.tv_sec = 0;
|
||||||
waittime.tv_usec = 0;
|
waittime.tv_usec = 0;
|
||||||
wt = &waittime;
|
wt = &waittime;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
XFD_COPYSET(&ClientsWithInput, &clientsReadable);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (someReady) {
|
if (someReady) {
|
||||||
XFD_COPYSET(&AllSockets, &LastSelectMask);
|
XFD_COPYSET(&AllSockets, &LastSelectMask);
|
||||||
XFD_UNSET(&LastSelectMask, &ClientsWithInput);
|
XFD_UNSET(&LastSelectMask, &ClientsWithInput);
|
||||||
|
|
9
os/io.c
9
os/io.c
|
@ -462,23 +462,14 @@ ReadRequestFromClient(ClientPtr client)
|
||||||
)
|
)
|
||||||
FD_SET(fd, &ClientsWithInput);
|
FD_SET(fd, &ClientsWithInput);
|
||||||
else {
|
else {
|
||||||
if (!SmartScheduleDisable)
|
|
||||||
FD_CLR(fd, &ClientsWithInput);
|
FD_CLR(fd, &ClientsWithInput);
|
||||||
else
|
|
||||||
YieldControlNoInput(fd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!gotnow)
|
if (!gotnow)
|
||||||
AvailableInput = oc;
|
AvailableInput = oc;
|
||||||
if (!SmartScheduleDisable)
|
|
||||||
FD_CLR(fd, &ClientsWithInput);
|
FD_CLR(fd, &ClientsWithInput);
|
||||||
else
|
|
||||||
YieldControlNoInput(fd);
|
|
||||||
}
|
}
|
||||||
if (SmartScheduleDisable)
|
|
||||||
if (++timesThisConnection >= MAX_TIMES_PER)
|
|
||||||
YieldControl();
|
|
||||||
if (move_header) {
|
if (move_header) {
|
||||||
request = (xReq *) oci->bufptr;
|
request = (xReq *) oci->bufptr;
|
||||||
oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
|
oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
|
||||||
|
|
38
os/utils.c
38
os/utils.c
|
@ -71,7 +71,6 @@ __stdcall unsigned long GetTickCount(void);
|
||||||
#if !defined(WIN32) || !defined(__MINGW32__)
|
#if !defined(WIN32) || !defined(__MINGW32__)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
# define SMART_SCHEDULE_POSSIBLE
|
|
||||||
#endif
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
|
@ -1005,10 +1004,11 @@ ProcessCommandLine(int argc, char *argv[])
|
||||||
i = skip - 1;
|
i = skip - 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
#if HAVE_SETITIMER
|
||||||
else if (strcmp(argv[i], "-dumbSched") == 0) {
|
else if (strcmp(argv[i], "-dumbSched") == 0) {
|
||||||
SmartScheduleDisable = TRUE;
|
SmartScheduleSignalEnable = FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if (strcmp(argv[i], "-schedInterval") == 0) {
|
else if (strcmp(argv[i], "-schedInterval") == 0) {
|
||||||
if (++i < argc) {
|
if (++i < argc) {
|
||||||
SmartScheduleInterval = atoi(argv[i]);
|
SmartScheduleInterval = atoi(argv[i]);
|
||||||
|
@ -1024,7 +1024,6 @@ ProcessCommandLine(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
UseMsg();
|
UseMsg();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (strcmp(argv[i], "-render") == 0) {
|
else if (strcmp(argv[i], "-render") == 0) {
|
||||||
if (++i < argc) {
|
if (++i < argc) {
|
||||||
int policy = PictureParseCmapPolicy(argv[i]);
|
int policy = PictureParseCmapPolicy(argv[i]);
|
||||||
|
@ -1208,10 +1207,10 @@ XNFstrdup(const char *s)
|
||||||
void
|
void
|
||||||
SmartScheduleStopTimer(void)
|
SmartScheduleStopTimer(void)
|
||||||
{
|
{
|
||||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
#if HAVE_SETITIMER
|
||||||
struct itimerval timer;
|
struct itimerval timer;
|
||||||
|
|
||||||
if (SmartScheduleDisable)
|
if (!SmartScheduleSignalEnable)
|
||||||
return;
|
return;
|
||||||
timer.it_interval.tv_sec = 0;
|
timer.it_interval.tv_sec = 0;
|
||||||
timer.it_interval.tv_usec = 0;
|
timer.it_interval.tv_usec = 0;
|
||||||
|
@ -1224,10 +1223,10 @@ SmartScheduleStopTimer(void)
|
||||||
void
|
void
|
||||||
SmartScheduleStartTimer(void)
|
SmartScheduleStartTimer(void)
|
||||||
{
|
{
|
||||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
#if HAVE_SETITIMER
|
||||||
struct itimerval timer;
|
struct itimerval timer;
|
||||||
|
|
||||||
if (SmartScheduleDisable)
|
if (!SmartScheduleSignalEnable)
|
||||||
return;
|
return;
|
||||||
timer.it_interval.tv_sec = 0;
|
timer.it_interval.tv_sec = 0;
|
||||||
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
|
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
|
||||||
|
@ -1237,6 +1236,7 @@ SmartScheduleStartTimer(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_SETITIMER
|
||||||
static void
|
static void
|
||||||
SmartScheduleTimer(int sig)
|
SmartScheduleTimer(int sig)
|
||||||
{
|
{
|
||||||
|
@ -1247,10 +1247,9 @@ static int
|
||||||
SmartScheduleEnable(void)
|
SmartScheduleEnable(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
if (SmartScheduleDisable)
|
if (!SmartScheduleSignalEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset((char *) &act, 0, sizeof(struct sigaction));
|
memset((char *) &act, 0, sizeof(struct sigaction));
|
||||||
|
@ -1261,7 +1260,6 @@ SmartScheduleEnable(void)
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
sigaddset(&act.sa_mask, SIGALRM);
|
sigaddset(&act.sa_mask, SIGALRM);
|
||||||
ret = sigaction(SIGALRM, &act, 0);
|
ret = sigaction(SIGALRM, &act, 0);
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,10 +1267,9 @@ static int
|
||||||
SmartSchedulePause(void)
|
SmartSchedulePause(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
if (SmartScheduleDisable)
|
if (!SmartScheduleSignalEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset((char *) &act, 0, sizeof(struct sigaction));
|
memset((char *) &act, 0, sizeof(struct sigaction));
|
||||||
|
@ -1280,20 +1277,19 @@ SmartSchedulePause(void)
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
ret = sigaction(SIGALRM, &act, 0);
|
ret = sigaction(SIGALRM, &act, 0);
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
SmartScheduleInit(void)
|
SmartScheduleInit(void)
|
||||||
{
|
{
|
||||||
if (SmartScheduleDisable)
|
#if HAVE_SETITIMER
|
||||||
return;
|
|
||||||
|
|
||||||
if (SmartScheduleEnable() < 0) {
|
if (SmartScheduleEnable() < 0) {
|
||||||
perror("sigaction for smart scheduler");
|
perror("sigaction for smart scheduler");
|
||||||
SmartScheduleDisable = TRUE;
|
SmartScheduleSignalEnable = FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SIG_BLOCK
|
#ifdef SIG_BLOCK
|
||||||
|
@ -1490,6 +1486,7 @@ Popen(const char *command, const char *type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore the smart scheduler while this is going on */
|
/* Ignore the smart scheduler while this is going on */
|
||||||
|
#if HAVE_SETITIMER
|
||||||
if (SmartSchedulePause() < 0) {
|
if (SmartSchedulePause() < 0) {
|
||||||
close(pdes[0]);
|
close(pdes[0]);
|
||||||
close(pdes[1]);
|
close(pdes[1]);
|
||||||
|
@ -1497,14 +1494,17 @@ Popen(const char *command, const char *type)
|
||||||
perror("signal");
|
perror("signal");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
case -1: /* error */
|
case -1: /* error */
|
||||||
close(pdes[0]);
|
close(pdes[0]);
|
||||||
close(pdes[1]);
|
close(pdes[1]);
|
||||||
free(cur);
|
free(cur);
|
||||||
|
#if HAVE_SETITIMER
|
||||||
if (SmartScheduleEnable() < 0)
|
if (SmartScheduleEnable() < 0)
|
||||||
perror("signal");
|
perror("signal");
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
if (setgid(getgid()) == -1)
|
if (setgid(getgid()) == -1)
|
||||||
|
@ -1678,10 +1678,12 @@ Pclose(void *iop)
|
||||||
/* allow EINTR again */
|
/* allow EINTR again */
|
||||||
OsReleaseSignals();
|
OsReleaseSignals();
|
||||||
|
|
||||||
|
#if HAVE_SETITIMER
|
||||||
if (SmartScheduleEnable() < 0) {
|
if (SmartScheduleEnable() < 0) {
|
||||||
perror("signal");
|
perror("signal");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return pid == -1 ? -1 : pstat;
|
return pid == -1 ? -1 : pstat;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue