From patchwork Sat Apr 21 02:16:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 902272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Sbzz5wBBz9s1v for ; Sat, 21 Apr 2018 12:20:45 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 13E5A3E7489 for ; Sat, 21 Apr 2018 04:20:43 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 19EA53E6B11 for ; Sat, 21 Apr 2018 04:20:37 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id EE6141A0044B for ; Sat, 21 Apr 2018 04:20:35 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3EEAFB645; Sat, 21 Apr 2018 02:20:34 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (unknown [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18088D7DE0; Sat, 21 Apr 2018 02:20:32 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Sat, 21 Apr 2018 10:16:00 +0800 Message-Id: <20180421021600.17549-2-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 21 Apr 2018 02:20:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 21 Apr 2018 02:20:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'liwang@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v3 2/2] read_all: wait children I/O reading in limited time X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" read_all reports some stalled messges in test: # ./read_all -d /sys -q -r 10 tst_test.c:987: INFO: Timeout per run is 0h 05m 00s read_all.c:280: BROK: Worker 26075 is stalled read_all.c:280: WARN: Worker 26075 is stalled read_all.c:280: WARN: Worker 26079 is stalled read_all.c:280: WARN: Worker 26087 is stalled The reason is that some children are still working on the read I/O but parent trys to stopping them after visit_dir immediately. Although the stop_attemps is 65535, it still sometimes fails. Instead, we take use of TST_RETRY_FUNC maroc to loop the stop operation in limited seconds to wait children I/O. And, the sched_work push action in an infinite loop, here merge it into rep_sched_work with using TST_RETRY_FUNC macro. Signed-off-by: Li Wang Cc: Richard Palethorpe Cc: Xiao Yang Cc: Cyril Hrubis --- Notes: Hi Cyril and Richard, The purpose of this patch is to replace the old one[1] to solve the children I/O issue. Please could you consider to merge or comment on the change of using new marco. [1] http://lists.linux.it/pipermail/ltp/2018-April/007704.html testcases/kernel/fs/read_all/read_all.c | 45 +++++++-------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c index b7ed540..b420e37 100644 --- a/testcases/kernel/fs/read_all/read_all.c +++ b/testcases/kernel/fs/read_all/read_all.c @@ -265,23 +265,14 @@ static void spawn_workers(void) static void stop_workers(void) { const char stop_code[1] = { '\0' }; - int i, stop_attempts; + int i; if (!workers) return; for (i = 0; i < worker_count; i++) { - stop_attempts = 0xffff; - if (workers[i].q) { - while (!queue_push(workers[i].q, stop_code)) { - if (--stop_attempts < 0) { - tst_brk(TBROK, - "Worker %d is stalled", - workers[i].pid); - break; - } - } - } + if (workers[i].q) + TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1); } for (i = 0; i < worker_count; i++) { @@ -292,33 +283,15 @@ static void stop_workers(void) } } -static void sched_work(const char *path) -{ - static int cur; - int push_attempts = 0, pushed; - - while (1) { - pushed = queue_push(workers[cur].q, path); - - if (++cur >= worker_count) - cur = 0; - - if (pushed) - break; - - if (++push_attempts > worker_count) { - usleep(100); - push_attempts = 0; - } - } -} - static void rep_sched_work(const char *path, int rep) { - int i; + int i, j; - for (i = 0; i < rep; i++) - sched_work(path); + for (i = j = 0; i < rep; i++, j++) { + if (j >= worker_count) + j = 0; + TST_RETRY_FUNC(queue_push(workers[j].q, path), 1); + } } static void setup(void)