summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fdd5f15)
Two issues:
- We don't want potentially two stat outputs running at the same time.
This could potentially happen if USR1 or interval stats race with
the thread exit.
- We could potentially crash if the interval or USR1 signaled stat
output trigger when fio is tearing down. Let the main thread wait
for any in-progress output in that case.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
return 1;
set_genesis_time();
return 1;
set_genesis_time();
create_disk_util_thread();
cgroup_list = smalloc(sizeof(*cgroup_list));
create_disk_util_thread();
cgroup_list = smalloc(sizeof(*cgroup_list));
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);
fio_mutex_remove(disk_thread_mutex);
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);
fio_mutex_remove(disk_thread_mutex);
#include "lib/getrusage.h"
#include "idletime.h"
#include "lib/getrusage.h"
#include "idletime.h"
+static struct fio_mutex *stat_mutex;
+
void update_rusage_stat(struct thread_data *td)
{
struct thread_stat *ts = &td->ts;
void update_rusage_stat(struct thread_data *td)
{
struct thread_stat *ts = &td->ts;
-void show_run_stats(void)
+static void __show_run_stats(void)
{
struct group_run_stats *runstats, *rs;
struct thread_data *td;
{
struct group_run_stats *runstats, *rs;
struct thread_data *td;
+void show_run_stats(void)
+{
+ fio_mutex_down(stat_mutex);
+ __show_run_stats();
+ fio_mutex_up(stat_mutex);
+}
+
static void *__show_running_run_stats(void fio_unused *arg)
{
struct thread_data *td;
static void *__show_running_run_stats(void fio_unused *arg)
{
struct thread_data *td;
for_each_td(td, i) {
if (td_read(td) && td->io_bytes[DDIR_READ])
for_each_td(td, i) {
if (td_read(td) && td->io_bytes[DDIR_READ])
+ fio_mutex_up(stat_mutex);
- pthread_create(&thread, NULL, __show_running_run_stats, NULL);
- pthread_detach(thread);
+ fio_mutex_down(stat_mutex);
+
+ if (!pthread_create(&thread, NULL, __show_running_run_stats, NULL)) {
+ pthread_detach(thread);
+ return;
+ }
+
+ fio_mutex_up(stat_mutex);
}
static int status_interval_init;
}
static int status_interval_init;
fio_gettime(&td->iops_sample_time, NULL);
}
fio_gettime(&td->iops_sample_time, NULL);
}
+
+void stat_init(void)
+{
+ stat_mutex = fio_mutex_init(FIO_MUTEX_UNLOCKED);
+}
+
+void stat_exit(void)
+{
+ /*
+ * When we have the mutex, we know out-of-band access to it
+ * have ended.
+ */
+ fio_mutex_down(stat_mutex);
+ fio_mutex_remove(stat_mutex);
+}
+extern void stat_init(void);
+extern void stat_exit(void);
+
extern void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs);
extern void show_group_stats(struct group_run_stats *rs);
extern int calc_thread_status(struct jobs_eta *je, int force);
extern void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs);
extern void show_group_stats(struct group_run_stats *rs);
extern int calc_thread_status(struct jobs_eta *je, int force);