X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=helper_thread.c;h=f0c717f5026db994509d88f6d86d21cebc447c3a;hb=refs%2Fheads%2Fmaster;hp=d8e7ebfe573ef5531fb2c60d00e87e4cb2127308;hpb=674428a527931d86bfb164abcc847508b3be2742;p=fio.git diff --git a/helper_thread.c b/helper_thread.c index d8e7ebfe..fed21d1d 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -1,4 +1,7 @@ +#include #include +#include +#include #include #ifdef CONFIG_HAVE_TIMERFD_CREATE #include @@ -9,6 +12,10 @@ #define DRD_IGNORE_VAR(x) do { } while (0) #endif +#ifdef WIN32 +#include "os/os-windows.h" +#endif + #include "fio.h" #include "smalloc.h" #include "helper_thread.h" @@ -99,13 +106,14 @@ static int read_from_pipe(int fd, void *buf, size_t len) static void block_signals(void) { -#ifdef HAVE_PTHREAD_SIGMASK +#ifdef CONFIG_PTHREAD_SIGMASK sigset_t sigmask; + int ret; + ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask); assert(ret == 0); ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL); - assert(ret == 0); #endif } @@ -118,7 +126,10 @@ static void submit_action(enum action a) return; ret = write_to_pipe(helper_data->pipe[1], &data, sizeof(data)); - assert(ret == 1); + if (ret != 1) { + log_err("failed to write action into pipe, err %i:%s", errno, strerror(errno)); + assert(0); + } } void helper_reset(void) @@ -150,7 +161,6 @@ void helper_thread_exit(void) return; helper_data->exit = 1; - submit_action(A_EXIT); pthread_join(helper_data->thread, NULL); } @@ -277,25 +287,18 @@ static void *helper_thread_main(void *data) }, { .name = "steadystate", - .interval_ms = steadystate_enabled ? STEADYSTATE_MSEC : + .interval_ms = steadystate_enabled ? ss_check_interval : 0, .func = steadystate_check, } }; struct timespec ts; - int clk_tck, ret = 0; + long clk_tck; + int ret = 0; -#ifdef _SC_CLK_TCK - clk_tck = sysconf(_SC_CLK_TCK); -#else - /* - * The timer frequence is variable on Windows. Instead of trying to - * query it, use 64 Hz, the clock frequency lower bound. See also - * https://carpediemsystems.co.uk/2019/07/18/windows-system-timer-granularity/. - */ - clk_tck = 64; -#endif - dprint(FD_HELPERTHREAD, "clk_tck = %d\n", clk_tck); + os_clk_tck(&clk_tck); + + dprint(FD_HELPERTHREAD, "clk_tck = %ld\n", clk_tck); assert(clk_tck > 0); sleep_accuracy_ms = (1000 + clk_tck - 1) / clk_tck; @@ -415,6 +418,8 @@ int helper_thread_create(struct fio_sem *startup_sem, struct sk_out *sk_out) int ret; hd = scalloc(1, sizeof(*hd)); + if (!hd) + return 1; setup_disk_util(); steadystate_setup();