From patchwork Mon Jun 25 16:21:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10486941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB357601D5 for ; Mon, 25 Jun 2018 16:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B75EC28848 for ; Mon, 25 Jun 2018 16:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B0728847; Mon, 25 Jun 2018 16:23:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ED782890A for ; Mon, 25 Jun 2018 16:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755274AbeFYQVF (ORCPT ); Mon, 25 Jun 2018 12:21:05 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:43334 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbeFYQVE (ORCPT ); Mon, 25 Jun 2018 12:21:04 -0400 Received: by mail-pf0-f193.google.com with SMTP id y8-v6so6677553pfm.10 for ; Mon, 25 Jun 2018 09:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XXa2cTHmp8UavvBtodYFdgvv5MPzmEpNtkylk+SQCgY=; b=wCRMRHksPk8HktqdSaZUrDhcOzCWopIybcWZ31J7LGayOlxZLILMZk0D30eO24sUyR dTkv9IzQmGD2Brz6EpgYX90B26Czx1OAMGB0yh6HggRllsUz2dhORe0CAso5ycZLel1R WIowD2rze2uA/Q7Co9U3NNLhNhWX54eC6tAe4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XXa2cTHmp8UavvBtodYFdgvv5MPzmEpNtkylk+SQCgY=; b=aK2JDqWluB/FbbymURyA8V17fkVby05nYYgvqLPTQVlgGAvItxi3AIJIPgV3/Tivan B8lgXfU724GcrQa2JKwEMjCGPcLUc5+Rrd6CgJaea+5aKgP+kI5Mi/gcjwNqUu+3zJM9 ndalCpoQy/Y8l7m+YAkjieKBg4F3YMhaigUIuoUYQTa0lcoXyqhdAm5URtFSvNnDCT0y A9bsUNLJtbT6ima/G03+ZAnRkOOE7JMJPSMqQ22N9PCZEV8mFoFJvbNZQj5sM3rkVbst RzIN+YSodt2x8zQMMJ80zjAtHFLs+y2oFsG2uaZcyFaOS+WDQ8vbJfnZRwKRY+LJ1raR 2voQ== X-Gm-Message-State: APt69E244J/fSW0o2jBdE7s/sjOwiWa45JHuMX9oRdBJ96QftgR22Y++ ishraOV7m2eLcbNofKcn0LT0qCuR3UY= X-Google-Smtp-Source: ADUXVKLNPxu3d+OWbzoFd+uBItnshpWN6EF6zcr599z/B9zMGGhXqs6GkDXsZ7IqXC6Q8kt0oSszig== X-Received: by 2002:a65:5144:: with SMTP id g4-v6mr2515135pgq.21.1529943664066; Mon, 25 Jun 2018 09:21:04 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id h24-v6sm8648807pfd.69.2018.06.25.09.21.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 09:21:03 -0700 (PDT) Date: Mon, 25 Jun 2018 09:21:02 -0700 From: Joel Fernandes To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Boqun Feng , Byungchul Park , Erick Reyes , Ingo Molnar , Julia Cartwright , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , Namhyung Kim , Paul McKenney , Peter Zijlstra , Shuah Khan , Steven Rostedt , Thomas Glexiner , Todd Kjos , Tom Zanussi , Will Deacon Subject: Re: [PATCH v9 7/7] kselftests: Add tests for the preemptoff and irqsoff tracers Message-ID: <20180625162102.GA49367@joelaf.mtv.corp.google.com> References: <20180621223236.211495-1-joel@joelfernandes.org> <20180621223236.211495-8-joel@joelfernandes.org> <20180625221302.8507c98e500d8efc70c19d88@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180625221302.8507c98e500d8efc70c19d88@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jun 25, 2018 at 10:13:02PM +0900, Masami Hiramatsu wrote: > Hi Joel, > > On Thu, 21 Jun 2018 15:32:36 -0700 > Joel Fernandes wrote: > [...] > > +++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc > > @@ -0,0 +1,74 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > +# description: test for the preemptirqsoff tracer > > + > > +MOD=test_atomic_sections > > + > > +fail() { > > + reset_tracer > > + rmmod $MOD || true > > + exit_fail > > +} > > + > > +unsup() { #msg > > + reset_tracer > > + rmmod $MOD || true > > + echo $1 > > + exit_unsupported > > +} > > + > > +modprobe $MOD || unsup "$MOD module not available" > > +rmmod $MOD > > + > > +grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled" > > +grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled" > > + > > +reset_tracer > > + > > +# Simulate preemptoff section for half a second couple of times > > +echo preemptoff > current_tracer > > +sleep 1 > > +modprobe test_atomic_sections atomic_mode=preempt atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > +modprobe test_atomic_sections atomic_mode=preempt atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > +modprobe test_atomic_sections atomic_mode=preempt atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > Why don't you use $MOD for these operations? Yes, I will. Thanks for the suggestion. > > + > > +cat trace > > + > > +# Confirm which tracer > > +grep -q "tracer: preemptoff" trace || fail > > + > > +# Check the end of the section > > +egrep -q "5.....us : " trace || fail > > + > > +# Check for 500ms of latency > > +egrep -q "latency: 5..... us" trace || fail > > + > > +reset_tracer > > + > > +# Simulate irqsoff section for half a second couple of times > > +echo irqsoff > current_tracer > > +sleep 1 > > +modprobe test_atomic_sections atomic_mode=irq atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > +modprobe test_atomic_sections atomic_mode=irq atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > +modprobe test_atomic_sections atomic_mode=irq atomic_time=500000 || fail > > +rmmod test_atomic_sections || fail > > Ditto. Done. > Other parts looks good to me. Cool, updated this patch below as "v9.1" ;-) thanks! - Joel ---8<----------------- From: "Joel Fernandes (Google)" Subject: [PATCH v9.1 7/7] kselftests: Add tests for the preemptoff and irqsoff tracers Here we add unit tests for the preemptoff and irqsoff tracer by using a kernel module introduced previously to trigger atomic sections in the kernel. Signed-off-by: Joel Fernandes (Google) Acked-by: Masami Hiramatsu --- tools/testing/selftests/ftrace/config | 3 + .../test.d/preemptirq/irqsoff_tracer.tc | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100755 tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index b01924c71c09..29588b328345 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config @@ -4,3 +4,6 @@ CONFIG_FUNCTION_PROFILER=y CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y +CONFIG_PREEMPT_TRACER=y +CONFIG_IRQSOFF_TRACER=y +CONFIG_TEST_ATOMIC_SECTIONS=m diff --git a/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc new file mode 100755 index 000000000000..2dcd5e4cafb4 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc @@ -0,0 +1,74 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: test for the preemptirqsoff tracer + +MOD=test_atomic_sections + +fail() { + reset_tracer + rmmod $MOD || true + exit_fail +} + +unsup() { #msg + reset_tracer + rmmod $MOD || true + echo $1 + exit_unsupported +} + +modprobe $MOD || unsup "$MOD module not available" +rmmod $MOD + +grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled" +grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled" + +reset_tracer + +# Simulate preemptoff section for half a second couple of times +echo preemptoff > current_tracer +sleep 1 +modprobe $MOD atomic_mode=preempt atomic_time=500000 || fail +rmmod $MOD || fail +modprobe $MOD atomic_mode=preempt atomic_time=500000 || fail +rmmod $MOD || fail +modprobe $MOD atomic_mode=preempt atomic_time=500000 || fail +rmmod $MOD || fail + +cat trace + +# Confirm which tracer +grep -q "tracer: preemptoff" trace || fail + +# Check the end of the section +egrep -q "5.....us : " trace || fail + +# Check for 500ms of latency +egrep -q "latency: 5..... us" trace || fail + +reset_tracer + +# Simulate irqsoff section for half a second couple of times +echo irqsoff > current_tracer +sleep 1 +modprobe $MOD atomic_mode=irq atomic_time=500000 || fail +rmmod $MOD || fail +modprobe $MOD atomic_mode=irq atomic_time=500000 || fail +rmmod $MOD || fail +modprobe $MOD atomic_mode=irq atomic_time=500000 || fail +rmmod $MOD || fail + +cat trace + +# Confirm which tracer +grep -q "tracer: irqsoff" trace || fail + +# Check the end of the section +egrep -q "5.....us : " trace || fail + +# Check for 500ms of latency +egrep -q "latency: 5..... us" trace || fail + +reset_tracer +exit 0 +