From patchwork Thu Apr 12 03:27:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 897454 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 40M5vs3KhNz9s25 for ; Thu, 12 Apr 2018 13:28:09 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A3DAA3E762B for ; Thu, 12 Apr 2018 05:28:05 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 0784A3E6113 for ; Thu, 12 Apr 2018 05:28:02 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id 16B98200B13 for ; Thu, 12 Apr 2018 05:28:01 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF32B813F6FF; Thu, 12 Apr 2018 03:27:59 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (dhcp-12-102.nay.redhat.com [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADC32215CDC8; Thu, 12 Apr 2018 03:27:57 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Thu, 12 Apr 2018 11:27:55 +0800 Message-Id: <20180412032755.4131-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 12 Apr 2018 03:27:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 12 Apr 2018 03:27:59 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v3] read_all: give more time to wait children finish read action 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" 1. We get the following worker 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 use an exponential backoff way to loop the stop operation in limited seconds. 2. The sched_work() push action in a infinite loop, here also let it trys in limited time. Signed-off-by: Li Wang Cc: Richard Palethorpe Cc: Xiao Yang Cc: Cyril Hrubis --- testcases/kernel/fs/read_all/read_all.c | 35 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c index b7ed540..32ab4e8 100644 --- a/testcases/kernel/fs/read_all/read_all.c +++ b/testcases/kernel/fs/read_all/read_all.c @@ -57,6 +57,7 @@ #define BUFFER_SIZE 1024 #define MAX_PATH 4096 #define MAX_DISPLAY 40 +#define SECOND 1000000 struct queue { sem_t sem; @@ -265,21 +266,22 @@ static void spawn_workers(void) static void stop_workers(void) { const char stop_code[1] = { '\0' }; - int i, stop_attempts; + int i, delay = 1; 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) + continue; + while (!queue_push(workers[i].q, stop_code)) { + if (delay < SECOND) { + usleep(delay); + delay *= 2; + } else { + tst_brk(TBROK, + "Worker %d is stalled", + workers[i].pid); } } } @@ -295,7 +297,7 @@ static void stop_workers(void) static void sched_work(const char *path) { static int cur; - int push_attempts = 0, pushed; + int push_attempts = 0, pushed, delay = 1; while (1) { pushed = queue_push(workers[cur].q, path); @@ -306,9 +308,14 @@ static void sched_work(const char *path) if (pushed) break; - if (++push_attempts > worker_count) { - usleep(100); - push_attempts = 0; + if (delay < SECOND) { + push_attempts++; + usleep(delay); + delay *= 2; + } else { + tst_brk(TBROK, + "Attempted %d times but still failed to push %s", + push_attempts, path); } } }