1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: ftrace - function profiler with function tracing 4# requires: function_profile_enabled set_ftrace_filter 5 6# There was a bug after a rewrite of the ftrace infrastructure that 7# caused the function_profiler not to be able to run with the function 8# tracer, because the function_profiler used the function_graph tracer 9# and it was assumed the two could not run simultaneously. 10# 11# There was another related bug where the solution to the first bug 12# broke the way filtering of the function tracer worked. 13# 14# This test triggers those bugs on those kernels. 15# 16# We need function_graph and profiling to to run this test 17if ! grep -q function_graph available_tracers; then 18 echo "no function graph tracer configured" 19 exit_unsupported; 20fi 21 22fail() { # mesg 23 echo $1 24 exit_fail 25} 26 27echo "Testing function tracer with profiler:" 28echo "enable function tracer" 29echo function > current_tracer 30echo "enable profiler" 31echo 1 > function_profile_enabled 32 33sleep 1 34 35echo "Now filter on just schedule" 36echo '*schedule' > set_ftrace_filter 37clear_trace 38 39echo "Now disable function profiler" 40echo 0 > function_profile_enabled 41 42sleep 1 43 44# make sure only schedule functions exist 45 46echo "testing if only schedule is being traced" 47if grep -v -e '^#' -e 'schedule' trace; then 48 fail "more than schedule was found" 49fi 50 51echo "Make sure schedule was traced" 52if ! grep -e 'schedule' trace > /dev/null; then 53 cat trace 54 fail "can not find schedule in trace" 55fi 56 57echo > set_ftrace_filter 58clear_trace 59 60sleep 1 61 62echo "make sure something other than scheduler is being traced" 63if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then 64 cat trace 65 fail "no other functions besides schedule was found" 66fi 67 68exit 0 69