From patchwork Tue Apr 24 12:49:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 903403 X-Patchwork-Delegate: chrubis@suse.cz 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=none (p=none dis=none) header.from=suse.cz 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 40Vjrs0FBqz9s0v for ; Tue, 24 Apr 2018 22:51:54 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E2B663E66C3 for ; Tue, 24 Apr 2018 14:51:50 +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 875143E6013 for ; Tue, 24 Apr 2018 14:51:49 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 6BFD76013A4 for ; Tue, 24 Apr 2018 14:51:48 +0200 (CEST) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 75ACCADE9 for ; Tue, 24 Apr 2018 12:51:47 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Tue, 24 Apr 2018 14:49:57 +0200 Message-Id: <20180424124957.15634-1-chrubis@suse.cz> X-Mailer: git-send-email 2.13.6 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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] [RFC] syscalls/perf_event_open02: Fix failures 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" The testcase was failing randomly, it could be reproduced easily when the machine is under load. To reproduce the issue just run a few dd if=/dev/zero of=/dev/null to saturate your CPUs. It has been sugessted that the reason for the failure are rounding errors caused by a frequent preemption. I haven't got a definitive answer from kernel devs for this but it's true that changing the process pritority to realtime SCHED_FIFO for the measurement does fix the issue. So we either delete the test or apply this patch. Signed-off-by: Cyril Hrubis --- .../kernel/syscalls/perf_event_open/perf_event_open02.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c index 13a17948a..0590ffb43 100644 --- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c +++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c @@ -64,6 +64,7 @@ The -v flag makes it print out the values of each counter. #include #include #include +#include #if HAVE_PERF_EVENT_ATTR # include @@ -286,6 +287,12 @@ static void verify(void) unsigned long long vtsum = 0, vhsum = 0; int i; double ratio; + struct sched_param sparam = {.sched_priority = 1}; + + if (sched_setscheduler(0, SCHED_FIFO, &sparam)) { + tst_brkm(TBROK | TERRNO, cleanup, + "sched_setscheduler(0, SCHED_FIFO, ...) failed"); + } if (prctl(PR_TASK_PERF_EVENTS_ENABLE) == -1) { tst_brkm(TBROK | TERRNO, cleanup, @@ -299,6 +306,12 @@ static void verify(void) "prctl(PR_TASK_PERF_EVENTS_DISABLE) failed"); } + sparam.sched_priority = 0; + if (sched_setscheduler(0, SCHED_OTHER, &sparam)) { + tst_brkm(TBROK | TERRNO, cleanup, + "sched_setscheduler(0, SCHED_OTHER, ...) failed"); + } + if (read(tsk0, &vt0, sizeof(vt0)) != sizeof(vt0)) { tst_brkm(TBROK | TERRNO, cleanup, "error reading task clock counter");