Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5194357imm; Tue, 16 Oct 2018 06:41:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV63pkuDoJSUUBkZlCMOgRW0XRjT5ufynWzDwlnyMTaiwIIww3EHauvMJuSkGzT90pTB23BKi X-Received: by 2002:a63:2807:: with SMTP id o7-v6mr20018560pgo.155.1539697265070; Tue, 16 Oct 2018 06:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539697265; cv=none; d=google.com; s=arc-20160816; b=gu8TABKytq58EodUyIylMG6no9/LcFp1usd0yP/kBBTr3UqX0qpEh0ZrT/CUd3GjvU uGasR4xizQ0SCjujQ1Br7UFaOaJFXoWgP1Zb+BMY2G69LlUDaY2/k9AUE5aXWbvAwXwL NaqcxN03h/qgGn1jr7MTo1qzJESOmpd9JYMmUDHJEvitDYfQe6LxKtcHy5ATDc0BR4v6 tM2aDYYKDWFPK8kURslSqObXdcK3TE7BojIBDvwpHA7ejxu6EGDGL4MGP+FYQVRR4pee Q2vserSIDEesm3DAoJJ99qsgdZVj6eGU3Qx12eonj+MF/oLVwo8t9vkFgoa8vssHj1qR 3L1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=yhkUKMIiP/kj3oxaCK/PxwhnJ62EIen4Hy1JfQAHGnE=; b=pdHsFn08+MeCVEDnzOUhTA691Kq+j2kfwcE+rJ4eAzAOI0HXjiNT4NZSPr4R1koklW D1UOeXe0T7nfCYqWg8U//D4w/wp7JgAG95iR2W8zFhFlROBkGM80HkiFTmYPo3/JilXS 2v4iluR7v3xRQK8ld8IJ1+fsgYMy7W2kaa+owLFeRPhfqnNYhOm2bhoshdXy/A/T0Rxe mg9jHS4ubheqvF2GFMoPwuTodRdSvLmezLOsD1uPXuhsYBY0lEIzwCN9DYNoiNzTiRic B5vtPb2qspJv6EYsrsYfIjno0+jScxT9wUOEizmIirbLuqdrbF5GQDC44B3sZl2aVTNp 5msw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si12835740pfi.271.2018.10.16.06.40.48; Tue, 16 Oct 2018 06:41:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbeJPVaj (ORCPT + 99 others); Tue, 16 Oct 2018 17:30:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:35404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727002AbeJPVaj (ORCPT ); Tue, 16 Oct 2018 17:30:39 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ECCE320881; Tue, 16 Oct 2018 13:40:06 +0000 (UTC) Date: Tue, 16 Oct 2018 09:40:05 -0400 From: Steven Rostedt To: Joel Fernandes Cc: LKML Subject: [PATCH] tracing: Use trace_clock_local() for looping in preemptirq_delay_test.c Message-ID: <20181016094005.654275a9@gandalf.local.home> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (VMware)" The preemptirq_delay_test module is used for the ftrace selftest code that tests the latency tracers. The problem is that it uses ktime for the delay loop, and then checks the tracer to see if the delay loop is caught, but the tracer uses trace_clock_local() which uses various different other clocks to measure the latency. As ktime uses the clock cycles, and the code then converts that to nanoseconds, it causes rounding errors, and the preemptirq latency tests are failing due to being off by 1 (it expects to see a delay of 500000 us, but the delay is only 499999 us). This is happening due to a rounding error in the ktime (which is totally legit). The purpose of the test is to see if it can catch the delay, not to test the accuracy between trace_clock_local() and ktime_get(). Best to use apples to apples, and have the delay loop use the same clock as the latency tracer does. Cc: Joel Fernandes (Google) Cc: stable@vger.kernel.org Fixes: f96e8577da102 ("lib: Add module for testing preemptoff/irqsoff latency tracers") Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/preemptirq_delay_test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c index f704390db9fc..d8765c952fab 100644 --- a/kernel/trace/preemptirq_delay_test.c +++ b/kernel/trace/preemptirq_delay_test.c @@ -5,12 +5,12 @@ * Copyright (C) 2018 Joel Fernandes (Google) */ +#include #include #include #include #include #include -#include #include #include #include @@ -25,13 +25,13 @@ MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt or irq (default ir static void busy_wait(ulong time) { - ktime_t start, end; - start = ktime_get(); + u64 start, end; + start = trace_clock_local(); do { - end = ktime_get(); + end = trace_clock_local(); if (kthread_should_stop()) break; - } while (ktime_to_ns(ktime_sub(end, start)) < (time * 1000)); + } while ((end - start) < (time * 1000)); } static int preemptirq_delay_run(void *data) -- 2.13.6