From patchwork Thu Jun 28 18:21:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10494661 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 99A526022E for ; Thu, 28 Jun 2018 18:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D0DB29F58 for ; Thu, 28 Jun 2018 18:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F90E29F92; Thu, 28 Jun 2018 18:22:22 +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 299E729F58 for ; Thu, 28 Jun 2018 18:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967769AbeF1SWH (ORCPT ); Thu, 28 Jun 2018 14:22:07 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46345 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030462AbeF1SWF (ORCPT ); Thu, 28 Jun 2018 14:22:05 -0400 Received: by mail-pl0-f67.google.com with SMTP id 30-v6so3153722pld.13 for ; Thu, 28 Jun 2018 11:22:04 -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=gag227hePDfIGVTZWUYWhRUYWZH54U22ruXf0gi5J0k=; b=YWuf6O75iI3D5iHwrIMaghaxHacrqha8YhzwsMuX3hPez43UTaMjOoMtaXXPSpoJgv 89FdckHQkBKpybim75/Sjg+D7y0+WaoFMBmN2HEy4h9VshMT9PLcSKax5LYtdQv9KEJ9 FMJ4TiM+JaBq8EsRjvnI9oMBc5+oOY4Xwnjlw= 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=gag227hePDfIGVTZWUYWhRUYWZH54U22ruXf0gi5J0k=; b=jUPzn67sF/5KBc2BsOH4jbCr2UV2Hmr0o7pS4IcgpSI3LhzqE6p9UxyOVtwwMnTHua 5XPU6L4AA5kfG+juVCR75Al57491NHYEq2Ew/hrERymHbtU5uFeQXCGLYYaDrSueI8hF Scx5Tge1v2gHwB5X9/P5H1a0Zl1UKNNgD4x6ezGJf3/aOPTxmDVENaG0zKj7YMtCjIa4 hh8cDBcyQDMISXWRo8wwSSq1PfAzmKYhqgHz8nS1pm+RkEaicoPdElQob9TJCbeWrG22 YGnsY3G5cfc0Cj9eT8CQUIRU/pN/ZiZo4xK72fIB1wS1yvX9y57H1xnYWU+M/XmfHxJK CWgA== X-Gm-Message-State: APt69E0A5fjRKE2sfEaZ4oO4Q7fyek2Xi6MUYNv9mtsa3TgupTd4pGVS 3oILHfemUWdu8YJTztMzMpHs7Q== X-Google-Smtp-Source: ADUXVKJJyUrRrca5tIM88ESxbjvrTee6MR0f8H7r/DebHgN/WbA5wpz0jpsgEeqHHjsDhL4h7Piiag== X-Received: by 2002:a17:902:903:: with SMTP id 3-v6mr11440508plm.106.1530210124519; Thu, 28 Jun 2018 11:22:04 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id q10-v6sm13686027pfj.7.2018.06.28.11.22.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 11:22:03 -0700 (PDT) From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Boqun Feng , Byungchul Park , Ingo Molnar , Julia Cartwright , linux-kselftest@vger.kernel.org, Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim , Paul McKenney , Peter Zijlstra , Steven Rostedt , Thomas Glexiner , Tom Zanussi Subject: [PATCH v9 7/7] kselftests: Add tests for the preemptoff and irqsoff tracers Date: Thu, 28 Jun 2018 11:21:49 -0700 Message-Id: <20180628182149.226164-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog In-Reply-To: <20180628182149.226164-1-joel@joelfernandes.org> References: <20180628182149.226164-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. Reviewed-by: Masami Hiramatsu Acked-by: Masami Hiramatsu Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/ftrace/config | 3 + .../test.d/preemptirq/irqsoff_tracer.tc | 73 +++++++++++++++++++ 2 files changed, 76 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..1806d340035d --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc @@ -0,0 +1,73 @@ +#!/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