aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/xorg-xserver/xserver-kdrive-1.3.0.0/scheduler.patch
blob: 395bc7d5117d28f1f4a58b1b49cf59be4e6a9d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
>From 48e4d08e99de41047c6b6fde5ba9d12787881c23 Mon Sep 17 00:00:00 2001
From: root <root@benny.jf.intel.com>
Date: Sun, 28 Oct 2007 09:37:52 +0100
Subject: [PATCH] The smart scheduler itimer currently always fires after each request
 (which in turn causes the CPU to wake out of idle, burning precious power).
 Rather than doing this, just stop the timer before going into the select()
 portion of the WaitFor loop. It's a cheap system call, and it will only get
 called if there's no more commands batched up from the active fd.

This change also allows some of the functions to be simplified; setitimer()
will only fail if it's passed invalid data, and we don't do that... so make
it void and remove all the conditional code that deals with failure.

The change also allows us to remove a few variables that were used for
housekeeping between the signal handler and the main loop.
---
 include/dixstruct.h |    6 ++----
 os/WaitFor.c        |   11 +++--------
 os/utils.c          |   28 +++-------------------------
 3 files changed, 8 insertions(+), 37 deletions(-)

diff --git a/include/dixstruct.h b/include/dixstruct.h
index dd6347f..bed31dc 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -150,11 +150,9 @@ extern long SmartScheduleTime;
 extern long SmartScheduleInterval;
 extern long SmartScheduleSlice;
 extern long SmartScheduleMaxSlice;
-extern unsigned long SmartScheduleIdleCount;
 extern Bool SmartScheduleDisable;
-extern Bool SmartScheduleIdle;
-extern Bool SmartScheduleTimerStopped;
-extern Bool SmartScheduleStartTimer(void);
+extern void SmartScheduleStartTimer(void);
+extern void SmartScheduleStopTimer(void);
 #define SMART_MAX_PRIORITY  (20)
 #define SMART_MIN_PRIORITY  (-20)
 
diff --git a/os/WaitFor.c b/os/WaitFor.c
index ec1592c..7683477 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -217,7 +217,8 @@ WaitForSomething(int *pClientsReady)
 	XFD_COPYSET(&AllSockets, &LastSelectMask);
 #ifdef SMART_SCHEDULE
 	}
-	SmartScheduleIdle = TRUE;
+	SmartScheduleStopTimer ();
+
 #endif
 	BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
 	if (NewOutputPending)
@@ -237,13 +238,7 @@ WaitForSomething(int *pClientsReady)
 	selecterr = GetErrno();
 	WakeupHandler(i, (pointer)&LastSelectMask);
 #ifdef SMART_SCHEDULE
-	if (i >= 0)
-	{
-	    SmartScheduleIdle = FALSE;
-	    SmartScheduleIdleCount = 0;
-	    if (SmartScheduleTimerStopped)
-		(void) SmartScheduleStartTimer ();
-	}
+	SmartScheduleStartTimer ();
 #endif
 	if (i <= 0) /* An error or timeout occurred */
 	{
diff --git a/os/utils.c b/os/utils.c
index 31cb0af..6fc1f7d 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1513,10 +1513,6 @@ XNFstrdup(const char *s)
 
 #ifdef SMART_SCHEDULE
 
-unsigned long	SmartScheduleIdleCount;
-Bool		SmartScheduleIdle;
-Bool		SmartScheduleTimerStopped;
-
 #ifdef SIGVTALRM
 #define SMART_SCHEDULE_POSSIBLE
 #endif
@@ -1526,7 +1522,7 @@ Bool		SmartScheduleTimerStopped;
 #define SMART_SCHEDULE_TIMER		ITIMER_REAL
 #endif
 
-static void
+void
 SmartScheduleStopTimer (void)
 {
 #ifdef SMART_SCHEDULE_POSSIBLE
@@ -1537,38 +1533,28 @@ SmartScheduleStopTimer (void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
     (void) setitimer (ITIMER_REAL, &timer, 0);
-    SmartScheduleTimerStopped = TRUE;
 #endif
 }
 
-Bool
+void
 SmartScheduleStartTimer (void)
 {
 #ifdef SMART_SCHEDULE_POSSIBLE
     struct itimerval	timer;
     
-    SmartScheduleTimerStopped = FALSE;
     timer.it_interval.tv_sec = 0;
     timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = SmartScheduleInterval * 1000;
-    return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+    setitimer (ITIMER_REAL, &timer, 0);
 #endif
-    return FALSE;
 }
 
 #ifdef SMART_SCHEDULE_POSSIBLE
 static void
 SmartScheduleTimer (int sig)
 {
-    int olderrno = errno;
-
     SmartScheduleTime += SmartScheduleInterval;
-    if (SmartScheduleIdle)
-    {
-	SmartScheduleStopTimer ();
-    }
-    errno = olderrno;
 }
 #endif
 
@@ -1592,14 +1578,6 @@ SmartScheduleInit (void)
 	perror ("sigaction for smart scheduler");
 	return FALSE;
     }
-    /* Set up the virtual timer */
-    if (!SmartScheduleStartTimer ())
-    {
-	perror ("scheduling timer");
-	return FALSE;
-    }
-    /* stop the timer and wait for WaitForSomething to start it */
-    SmartScheduleStopTimer ();
     return TRUE;
 #else
     return FALSE;
-- 
1.5.3.4