[LTP] [PATCH] read_all: retry to queue work for any worker
Cyril Hrubis
chrubis@suse.cz
Wed Oct 9 15:56:56 CEST 2019
Hi!
> +static void work_push_retry(int worker, const char *buf)
> +{
> + int i, ret, worker_min, worker_max;
> +
> + if (worker < 0) {
> + /* pick any, try -worker first */
> + worker_min = worker * (-1);
> + worker_max = worker_count;
> + } else {
> + /* keep trying worker */
> + worker_min = worker;
> + worker_max = worker + 1;
> + }
> + i = worker_min;
> +
> + for (;;) {
> + ret = queue_push(workers[i].q, buf);
> + if (ret == 1)
> + break;
> +
> + if (++i >= worker_max) {
> + i = worker_min;
> + usleep(100000);
My only concern is that we sleep for too long here. Maybe we should
start with smaller sleep here and increase it after a while.
Or have you checked that the tests runs as fast as if we had smaller
sleep here?
> + }
> + }
> +}
> +
> static void stop_workers(void)
> {
> const char stop_code[1] = { '\0' };
> @@ -292,7 +319,7 @@ static void stop_workers(void)
>
> for (i = 0; i < worker_count; i++) {
> if (workers[i].q)
> - TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1);
> + work_push_retry(i, stop_code);
> }
>
> for (i = 0; i < worker_count; i++) {
> @@ -310,7 +337,7 @@ static void rep_sched_work(const char *path, int rep)
> for (i = j = 0; i < rep; i++, j++) {
> if (j >= worker_count)
> j = 0;
> - TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
> + work_push_retry(-j, path);
> }
> }
>
> --
> 1.8.3.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list