From patchwork Tue Dec 4 08:46:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1007486 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 438FpY5KMhz9s55 for ; Tue, 4 Dec 2018 19:46:43 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3D2353E78DA for ; Tue, 4 Dec 2018 09:46:40 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 8F09E3E7830 for ; Tue, 4 Dec 2018 09:46:37 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 6441A1401199 for ; Tue, 4 Dec 2018 09:46:34 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0A76307D850; Tue, 4 Dec 2018 08:46:32 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8EBF105706A; Tue, 4 Dec 2018 08:46:31 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Tue, 4 Dec 2018 09:46:25 +0100 Message-Id: <8361c9b264ceb4c212319fcb366d85a854495ffe.1543912963.git.jstancek@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 04 Dec 2018 08:46:32 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-6.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-6.smtp.seeweb.it Cc: liwan@redhat.com Subject: [LTP] [PATCH v4] fzsync: limit sampling 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" Fixes: #429 Sampling can take considerably longer time on single CPU and very slow systems. This patch limits sampling time to 1/2 of fuzzing runtime. If we don't have enough samples by that time, stop sampling and use stats we gathered so far. Signed-off-by: Jan Stancek --- include/tst_fuzzy_sync.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) Changes in v4: - drop comment - tweak info message when timeout is reached diff --git a/include/tst_fuzzy_sync.h b/include/tst_fuzzy_sync.h index 03f69b78bc82..0e534bb041f8 100644 --- a/include/tst_fuzzy_sync.h +++ b/include/tst_fuzzy_sync.h @@ -70,6 +70,9 @@ #ifndef TST_FUZZY_SYNC_H__ #define TST_FUZZY_SYNC_H__ +/* how much of exec time is sampling allowed to take */ +#define SAMPLING_SLICE 0.5f + /** Some statistics for a variable */ struct tst_fzsync_stat { float avg; @@ -582,17 +585,21 @@ static inline void tst_fzsync_wait_b(struct tst_fzsync_pair *pair) static inline int tst_fzsync_run_a(struct tst_fzsync_pair *pair) { int exit = 0; + float rem_p = 1 - tst_timeout_remaining() / pair->exec_time_start; + + if ((pair->exec_time_p * SAMPLING_SLICE < rem_p) + && (pair->sampling > 0)) { + tst_res(TINFO, "Stopped sampling at %d (out of %d) samples, " + "sampling time reached 50% of the total time limit", + pair->exec_loop, pair->min_samples); + pair->sampling = 0; + tst_fzsync_pair_info(pair); + } - if (pair->exec_time_p - < 1 - tst_timeout_remaining() / pair->exec_time_start) { + if (pair->exec_time_p < rem_p) { tst_res(TINFO, "Exceeded execution time, requesting exit"); exit = 1; - - if (pair->sampling > 0) { - tst_res(TWARN, - "Still sampling, consider increasing LTP_TIMEOUT_MUL"); - } } if (++pair->exec_loop > pair->exec_loops) {