aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/server.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-10-15 17:18:33 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-10-15 17:18:33 -0400
commit76ec41ad78e824c421c29e20cd145d95ec88b258 (patch)
treebeec7a78d0edce041243348b94a1d420a279925c /litmus/server.c
parent67be6e7922465a9cc94a8c6f0353cb7051a6f97d (diff)
Fixed sched_trace records for state transitions.
This commit is dirty and will be cleaned up when blocking states are tested.
Diffstat (limited to 'litmus/server.c')
-rw-r--r--litmus/server.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/litmus/server.c b/litmus/server.c
index 3ff48e8316a6..6e713a24fd33 100644
--- a/litmus/server.c
+++ b/litmus/server.c
@@ -13,9 +13,9 @@
13 13
14#define server_job(s) ((s)->job ? *(s)->job : 0) 14#define server_job(s) ((s)->job ? *(s)->job : 0)
15#define trace_switch(s, type) sched_trace_server_switch_ ##type ( \ 15#define trace_switch(s, type) sched_trace_server_switch_ ##type ( \
16 (s)->cpu, 0, (s)->sid, server_job(s)) 16 (s)->parent, 0, (s)->sid, server_job(s), *(s)->cpu)
17#define trace_transition(s, type) \ 17#define trace_transition(s, type) \
18 sched_trace_server_switch_ ##type(0, 0, (s)->sid, server_job(s)) 18 sched_trace_server_switch_ ##type(0, 0, (s)->sid, server_job(s), *(s)->cpu)
19 19
20#define NCS(x) case x: return #x 20#define NCS(x) case x: return #x
21 21
@@ -29,12 +29,13 @@ static const char* server_state_name(enum server_state state)
29 } 29 }
30} 30}
31 31
32void server_init(struct server *server, int sid, int *job) 32void server_init(struct server *server, int sid, int *job, int *cpu)
33{ 33{
34 server->sid = sid; 34 server->sid = sid;
35 server->job = job; 35 server->job = job;
36 36
37 server->cpu = 0; 37 server->cpu = cpu;
38 server->parent = 0;
38 server->state = SS_REMOVED; 39 server->state = SS_REMOVED;
39 server->linked = 0; 40 server->linked = 0;
40 server->in_transit = 0; 41 server->in_transit = 0;
@@ -43,38 +44,45 @@ void server_init(struct server *server, int sid, int *job)
43void server_state_change(struct server *server, enum server_state state, 44void server_state_change(struct server *server, enum server_state state,
44 unsigned int transit) 45 unsigned int transit)
45{ 46{
47 enum server_state last = server->state;
48
46 if (!server->in_transit && transit && 49 if (!server->in_transit && transit &&
47 server->state == state) 50 server->state == state) {
51 STRACE("Ignoring transit state when target same\n");
48 return; 52 return;
49 if (server->in_transit == transit && state == server->state) 53 }
54 if (server->in_transit == transit && state == server->state) {
55 STRACE("Ignoring identical change\n");
50 return; 56 return;
51
52 if (server->in_transit && transit) {
53 sched_trace_server_completion(server->sid, 0);
54 goto set_state;
55 } 57 }
56 58
57 if (server->in_transit) { 59 if (server->in_transit) {
60 STRACE("Transition end\n");
58 trace_transition(server, away); 61 trace_transition(server, away);
59 } else { 62 last = server->last;
60 switch (server->state) { 63 }
61 case SS_BLOCKED: 64
62 sched_trace_server_resume(server->sid); 65 if (server->state == SS_BLOCKED) {
63 break; 66 STRACE("Server resume\n");
64 case SS_ACTIVE: 67 sched_trace_server_resume(server->sid);
65 trace_switch(server, away);
66 break;
67 }
68 } 68 }
69 69
70 if (transit) { 70 if (transit) {
71 STRACE("Transition begin\n");
71 trace_transition(server, to); 72 trace_transition(server, to);
72 } else { 73 } else {
74 if (last == SS_ACTIVE) {
75 STRACE("Switch from server\n");
76 trace_switch(server, away);
77 }
78
73 switch (state) { 79 switch (state) {
74 case SS_BLOCKED: 80 case SS_BLOCKED:
81 STRACE("Server block\n");
75 sched_trace_server_block(server->sid); 82 sched_trace_server_block(server->sid);
76 break; 83 break;
77 case SS_ACTIVE: 84 case SS_ACTIVE:
85 STRACE("Switch to server\n");
78 trace_switch(server, to); 86 trace_switch(server, to);
79 break; 87 break;
80 } 88 }
@@ -82,11 +90,13 @@ void server_state_change(struct server *server, enum server_state state,
82 90
83 set_state: 91 set_state:
84#ifdef CONFIG_PREEMPT_STATE_TRACE 92#ifdef CONFIG_PREEMPT_STATE_TRACE
85 STRACE("server: %d - (%s:%d)->(%s:%d)\n", 93 STRACE("server: %d (parent: %d, cpu: %d, job: %d) - (%s:%d)->(%s:%d) at %llu\n",
86 server->sid, 94 server->sid, server->parent, *server->cpu, (server->job) ? *server->job : 0,
87 server_state_name(server->state), server->in_transit, 95 server_state_name(server->state), server->in_transit,
88 server_state_name(state), transit); 96 server_state_name(state), transit,
97 litmus_clock());
89#endif 98#endif
99 server->last = server->state;
90 server->state = state; 100 server->state = state;
91 server->in_transit = transit; 101 server->in_transit = transit;
92} 102}