From patchwork Wed Apr 11 09:47:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 897117 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 40LfNM0ryWz9s3L for ; Wed, 11 Apr 2018 19:47:47 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 43C3A3E75DF for ; Wed, 11 Apr 2018 11:47:44 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id C91853E75DF for ; Wed, 11 Apr 2018 11:47:41 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id 161C4600EBD for ; Wed, 11 Apr 2018 11:47:40 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9F1D40201A3; Wed, 11 Apr 2018 09:47:38 +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 EBE9D10B2B57; Wed, 11 Apr 2018 09:47:36 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Wed, 11 Apr 2018 17:47:34 +0800 Message-Id: <20180411094734.10962-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 09:47:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 09:47:38 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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-2.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-2.smtp.seeweb.it Subject: [LTP] [PATCH v2] 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 --- testcases/kernel/fs/read_all/read_all.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c index b7ed540..a9f9707 100644 --- a/testcases/kernel/fs/read_all/read_all.c +++ b/testcases/kernel/fs/read_all/read_all.c @@ -57,6 +57,8 @@ #define BUFFER_SIZE 1024 #define MAX_PATH 4096 #define MAX_DISPLAY 40 +#define MICROSECOND 1 +#define SECOND MICROSECOND * 1000000 struct queue { sem_t sem; @@ -265,20 +267,21 @@ 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) { + if (delay < SECOND) { + usleep(delay); + delay *= 2; + } else { tst_brk(TBROK, "Worker %d is stalled", workers[i].pid); - break; } } } @@ -295,7 +298,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 +309,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, + "Attempts %d times but still failed to push %s", + push_attempts, path); } } }