From patchwork Thu Jun 7 20:38:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10453531 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 2E10E60146 for ; Thu, 7 Jun 2018 20:39:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E602298E6 for ; Thu, 7 Jun 2018 20:39:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11B1329917; Thu, 7 Jun 2018 20:39: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_ADSP_CUSTOM_MED, 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 A4DD1298E6 for ; Thu, 7 Jun 2018 20:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932634AbeFGUjD (ORCPT ); Thu, 7 Jun 2018 16:39:03 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:42344 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932604AbeFGUjA (ORCPT ); Thu, 7 Jun 2018 16:39:00 -0400 Received: by mail-pl0-f67.google.com with SMTP id w17-v6so6858067pll.9 for ; Thu, 07 Jun 2018 13:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=441C7lwFc1IlCq9sxMR+Pf6T5lduVGISOUsJh5XbCc4=; b=WHAJiPOkTvFkFRKr+Ww6OnubbGHxnmgYilTbBomKCI/Jh0pHyA5mPnF8YSLwsyypAw JYWhXQulkwTREmqYImG0+OLzZMUlONAIqBKpv7snM6K89M4cZarGviHumV4l+AJGnZWe lqd7iJF8XJ/Lcgv3l7TDHz4pOtXMxLxLEF5Iqu2za8SCWMrAbmo8ocsAeMJxGF+0H5IH m/GfX58RHHsgCBhl0qYrM2RijjUe3Fahm9hsQeANZeLxbOQdZ12hXsxLlVh7b3i5Qr3H 1v7Jo4sFh6w8teZ7x8O7lqrldH3UoXVpEOuNMykB62lf3mnc8OHu/6r5axCMEVNDkGdT nEQA== 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=441C7lwFc1IlCq9sxMR+Pf6T5lduVGISOUsJh5XbCc4=; b=B63HrxYPPjTg1g8wIK3wWydHk4DZLs2ZXRrE+jOWVQjFzI5Gz8uT1HJ8lC07GABCji 2Q9h/8IiUu+32vpDwswrAkas571k8EN/Qwli1aKmyRmQ1yKoS6tUoZrK6AIzbMJwVrQj QJEpkGn8TbT1pIkaDepePCkyckjy68eqNRjZgAaGVzAArq/dlvCUZcio7uLUSI4rgEa5 wMYi7jO09GhT55R3ERRgJHYgcIxAnA8B8k/BChnjNSANqoH9SC+2OsZ0Xkqa+E350LHO JrumfIWM8si4zqfEopHBodgOJXjlAD28ChZ3EPOJRqyH9kst2yg9yRYG0oJLNttBOBbq 2wPw== X-Gm-Message-State: APt69E1PydQo8OnHjQhcQPesQ0PSHNCekM8Z91cpCtXF8Rk63a2V4/L7 UURbZ+EEPqag8fWxNopl/WYWVw== X-Google-Smtp-Source: ADUXVKLwt1oz9Go8sOFkH39wGl+4A3C6DppxaZFVhv0xT+ov1DO7tED7ZcLVO4dnHTDEe+3NvFycUw== X-Received: by 2002:a17:902:d697:: with SMTP id v23-v6mr3501608ply.193.1528403939191; Thu, 07 Jun 2018 13:38:59 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id v27-v6sm10324174pfi.23.2018.06.07.13.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 13:38:58 -0700 (PDT) From: Joel Fernandes X-Google-Original-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 Subject: [PATCH v9 7/7] kselftests: Add tests for the preemptoff and irqsoff tracers Date: Thu, 7 Jun 2018 13:38:15 -0700 Message-Id: <20180607203815.255845-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.17.1.1185.g55be947832-goog In-Reply-To: <20180607203815.255845-1-joel@joelfernandes.org> References: <20180607203815.255845-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 +