From patchwork Thu Jun 21 22:32:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10480811 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 C7222602CB for ; Thu, 21 Jun 2018 22:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72C928E2B for ; Thu, 21 Jun 2018 22:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA62828F2F; Thu, 21 Jun 2018 22:34:38 +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 4043C28E2B for ; Thu, 21 Jun 2018 22:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933934AbeFUWd4 (ORCPT ); Thu, 21 Jun 2018 18:33:56 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:41724 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933918AbeFUWdd (ORCPT ); Thu, 21 Jun 2018 18:33:33 -0400 Received: by mail-pf0-f194.google.com with SMTP id a11-v6so2204003pff.8 for ; Thu, 21 Jun 2018 15:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kSp3IhH/4pAsfMRsnkVO9/5eYKfhA0t2sIhKV7K2vMs=; b=WZb3vteZr23rQGbirG5V7uodyLB3of6lr0daP1GGh17AFbEn4fz5sy4c46pc24FkUg PreNjXD+K9Tf65nSN1fD2YgesOx3h9WE2NDd2ouzlRih42AelLLkLkaDHNlCuP0zKbSS +c176CIVT/nkXgDH1uB2kEO45zrNYg9BHcC5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kSp3IhH/4pAsfMRsnkVO9/5eYKfhA0t2sIhKV7K2vMs=; b=nyh8a7AeO0SllYj6J+284Qimr2Ua/1LBSVaLrOPmVZYZKBe240Tnc88UZMe85mo1qG GfDR4ouW8tQTuenBqMpMVFW/YLKvfI/ehNKOaJSesvuaoICZJDff3YOoVbBwb6PZRrAk /1Oxh6JqzSzZ3MG9qeO7ZQtG16z2m0/YcqGR6+t6iQiKxLn0LVbYE5GzkfTgqIDe30ql ycmkkfxBEXwoE6Ry7OTmTOGpCVKubFyXVetGKt0H4EtggllJrNqpUxO2ps3Ew0fBU8ph IsJVht7y0bw0ZtUGcHN9zMj4KkKatUHQBcPJ7QjTm7p9NlnfIGulFQWPPlECaLHUFNQf l/Cg== X-Gm-Message-State: APt69E1LRKcw/oCyz2YpoT3zJJiScBa3eoaYn7pV7LRRGOXRnJz1B0PF nDHiJZfiZ6TKHGNpDEyVpQem3A== X-Google-Smtp-Source: ADUXVKLAPm7rm7KbKCrgOlQHjENB7/4KMuc6b3gVFOhocdiPBIGnMlhj5d3ypjwpApDpuYGpaNJKew== X-Received: by 2002:a63:86c8:: with SMTP id x191-v6mr23553218pgd.2.1529620413092; Thu, 21 Jun 2018 15:33:33 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id x19-v6sm11060824pfi.5.2018.06.21.15.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 15:33:32 -0700 (PDT) From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, "Joel Fernandes (Google)" , Boqun Feng , Byungchul Park , Erick Reyes , Ingo Molnar , Julia Cartwright , linux-kselftest@vger.kernel.org, Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim , Paul McKenney , Peter Zijlstra , Shuah Khan , Steven Rostedt , Thomas Glexiner , Todd Kjos , Tom Zanussi , Will Deacon Subject: [PATCH v9 7/7] kselftests: Add tests for the preemptoff and irqsoff tracers Date: Thu, 21 Jun 2018 15:32:36 -0700 Message-Id: <20180621223236.211495-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog In-Reply-To: <20180621223236.211495-1-joel@joelfernandes.org> References: <20180621223236.211495-1-joel@joelfernandes.org> 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 From: "Joel Fernandes (Google)" 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) --- tools/testing/selftests/ftrace/config | 3 + .../test.d/preemptirq/irqsoff_tracer.tc | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 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 100644 index 000000000000..1764ff22c02b --- /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 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 + +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 + +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 +