Enables --debug=process to show the actual transitions, instead of
numbers you have to look up in the source:
process 12113 pid=12123: runstate CREATED -> INITIALIZED
instead of
process 12113 pid=12123: runstate 1 -> 2
Signed-off-by: Jens Axboe <axboe@fb.com>
TD_FINISHING,
TD_EXITED,
TD_REAPED,
TD_FINISHING,
TD_EXITED,
TD_REAPED,
};
extern void td_set_runstate(struct thread_data *, int);
};
extern void td_set_runstate(struct thread_data *, int);
+static const char *td_runstates[] = {
+ "NOT_CREATED",
+ "CREATED",
+ "INITIALIZED",
+ "RAMP",
+ "SETTING_UP",
+ "RUNNING",
+ "PRE_READING",
+ "VERIFYING",
+ "FSYNCING",
+ "FINISHING",
+ "EXITED",
+ "REAPED",
+};
+
+static const char *runstate_to_name(int runstate)
+{
+ compiletime_assert(TD_LAST == 12, "td runstate list");
+ if (runstate >= 0 && runstate < TD_LAST)
+ return td_runstates[runstate];
+
+ return "invalid";
+}
+
void td_set_runstate(struct thread_data *td, int runstate)
{
if (td->runstate == runstate)
return;
void td_set_runstate(struct thread_data *td, int runstate)
{
if (td->runstate == runstate)
return;
- dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", (int) td->pid,
- td->runstate, runstate);
+ dprint(FD_PROCESS, "pid=%d: runstate %s -> %s\n", (int) td->pid,
+ runstate_to_name(td->runstate),
+ runstate_to_name(runstate));
td->runstate = runstate;
}
td->runstate = runstate;
}