12c6c3946SNamhyung Kim#!/bin/sh 2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 32c6c3946SNamhyung Kim# description: event tracing - restricts events based on pid 4*3591e90fSMasami Hiramatsu# requires: set_event set_event_pid events/sched 535df6a89SSteven Rostedt (VMware)# flags: instance 62c6c3946SNamhyung Kim 72c6c3946SNamhyung Kimdo_reset() { 82c6c3946SNamhyung Kim echo > set_event 92c6c3946SNamhyung Kim echo > set_event_pid 102c6c3946SNamhyung Kim echo 0 > options/event-fork 112c6c3946SNamhyung Kim clear_trace 122c6c3946SNamhyung Kim} 132c6c3946SNamhyung Kim 142c6c3946SNamhyung Kimfail() { #msg 152c6c3946SNamhyung Kim do_reset 162c6c3946SNamhyung Kim echo $1 1742534b1fSMasami Hiramatsu exit_fail 182c6c3946SNamhyung Kim} 192c6c3946SNamhyung Kim 20e527c470SMasami Hiramatsuecho 0 > options/event-fork 212c6c3946SNamhyung Kim 222c6c3946SNamhyung Kimecho 1 > events/sched/sched_switch/enable 232c6c3946SNamhyung Kim 242c6c3946SNamhyung Kimyield 252c6c3946SNamhyung Kim 262c6c3946SNamhyung Kimcount=`cat trace | grep sched_switch | wc -l` 272c6c3946SNamhyung Kimif [ $count -eq 0 ]; then 282c6c3946SNamhyung Kim fail "sched_switch events are not recorded" 292c6c3946SNamhyung Kimfi 302c6c3946SNamhyung Kim 312c6c3946SNamhyung Kimdo_reset 322c6c3946SNamhyung Kim 332c6c3946SNamhyung Kimread mypid rest < /proc/self/stat 342c6c3946SNamhyung Kim 352c6c3946SNamhyung Kimecho $mypid > set_event_pid 36ddbc31e6SMasami Hiramatsugrep -q $mypid set_event_pid 372c6c3946SNamhyung Kimecho 'sched:sched_switch' > set_event 382c6c3946SNamhyung Kim 392c6c3946SNamhyung Kimyield 402c6c3946SNamhyung Kim 412c6c3946SNamhyung Kimcount=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 422c6c3946SNamhyung Kimif [ $count -ne 0 ]; then 432c6c3946SNamhyung Kim fail "sched_switch events from other task are recorded" 442c6c3946SNamhyung Kimfi 452c6c3946SNamhyung Kim 462c6c3946SNamhyung Kimdo_reset 472c6c3946SNamhyung Kim 482c6c3946SNamhyung Kimecho $mypid > set_event_pid 492c6c3946SNamhyung Kimecho 1 > options/event-fork 502c6c3946SNamhyung Kimecho 1 > events/sched/sched_switch/enable 512c6c3946SNamhyung Kim 522c6c3946SNamhyung Kimyield 532c6c3946SNamhyung Kim 542c6c3946SNamhyung Kimcount=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 552c6c3946SNamhyung Kimif [ $count -eq 0 ]; then 562c6c3946SNamhyung Kim fail "sched_switch events from other task are not recorded" 572c6c3946SNamhyung Kimfi 582c6c3946SNamhyung Kim 592c6c3946SNamhyung Kimdo_reset 602c6c3946SNamhyung Kim 612c6c3946SNamhyung Kimexit 0 62