1f08c3bdfSopenharmony_ci#! /bin/sh
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_ci###########################################################################
4f08c3bdfSopenharmony_ci##                                                                       ##
5f08c3bdfSopenharmony_ci## Copyright (c) 2015, Red Hat Inc.                                      ##
6f08c3bdfSopenharmony_ci##                                                                       ##
7f08c3bdfSopenharmony_ci## This program is free software: you can redistribute it and/or modify  ##
8f08c3bdfSopenharmony_ci## it under the terms of the GNU General Public License as published by  ##
9f08c3bdfSopenharmony_ci## the Free Software Foundation, either version 3 of the License, or     ##
10f08c3bdfSopenharmony_ci## (at your option) any later version.                                   ##
11f08c3bdfSopenharmony_ci##                                                                       ##
12f08c3bdfSopenharmony_ci## This program is distributed in the hope that it will be useful,       ##
13f08c3bdfSopenharmony_ci## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
14f08c3bdfSopenharmony_ci## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
15f08c3bdfSopenharmony_ci## GNU General Public License for more details.                          ##
16f08c3bdfSopenharmony_ci##                                                                       ##
17f08c3bdfSopenharmony_ci## You should have received a copy of the GNU General Public License     ##
18f08c3bdfSopenharmony_ci## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
19f08c3bdfSopenharmony_ci##                                                                       ##
20f08c3bdfSopenharmony_ci## Author: Li Wang <liwang@redhat.com>                                   ##
21f08c3bdfSopenharmony_ci##                                                                       ##
22f08c3bdfSopenharmony_ci###########################################################################
23f08c3bdfSopenharmony_ci##                                                                       ##
24f08c3bdfSopenharmony_ci## Summary:  panic while using userstacktrace                            ##
25f08c3bdfSopenharmony_ci##                                                                       ##
26f08c3bdfSopenharmony_ci## BUG: unable to handle kernel paging request at 00000000417683c0       ##
27f08c3bdfSopenharmony_ci##      IP: [<ffffffff8105c834>] update_curr+0x124/0x1e0                 ##
28f08c3bdfSopenharmony_ci##      PGD 41a796067 PUD 0                                              ##
29f08c3bdfSopenharmony_ci##      Thread overran stack, or stack corrupted                         ##
30f08c3bdfSopenharmony_ci##      Oops: 0000 [#1] SMP                                              ##
31f08c3bdfSopenharmony_ci##      last sysfs file: ../system/cpu/cpu15/cache/index2/shared_cpu_map ##
32f08c3bdfSopenharmony_ci##                                                                       ##
33f08c3bdfSopenharmony_ci## The bug was fixed by:                                                 ##
34f08c3bdfSopenharmony_ci##      1dbd195 (tracing: Fix preempt count leak)                        ##
35f08c3bdfSopenharmony_ci##                                                                       ##
36f08c3bdfSopenharmony_ci###########################################################################
37f08c3bdfSopenharmony_ci
38f08c3bdfSopenharmony_ciexport TCID="ftrace_regression01"
39f08c3bdfSopenharmony_ciexport TST_TOTAL=1
40f08c3bdfSopenharmony_ci
41f08c3bdfSopenharmony_ci. ftrace_lib.sh
42f08c3bdfSopenharmony_ci
43f08c3bdfSopenharmony_ciLOOP=10
44f08c3bdfSopenharmony_ci
45f08c3bdfSopenharmony_ciTSTACK_TRACE_PATH="/proc/sys/kernel/stack_tracer_enabled"
46f08c3bdfSopenharmony_ciEXC_PAGE_FAULT_ENABLE="$TRACING_PATH/events/exceptions/page_fault_kernel/enable"
47f08c3bdfSopenharmony_ciMM_PAGE_FAULT_ENABLE="$TRACING_PATH/events/kmem/mm_kernel_pagefault/enable"
48f08c3bdfSopenharmony_ci
49f08c3bdfSopenharmony_ciftrace_userstacktrace_test()
50f08c3bdfSopenharmony_ci{
51f08c3bdfSopenharmony_ci	if [ ! -e "$TSTACK_TRACE_PATH" ]; then
52f08c3bdfSopenharmony_ci		tst_brkm TCONF "Stack Tracer is not cofigured in This kernel"
53f08c3bdfSopenharmony_ci	fi
54f08c3bdfSopenharmony_ci
55f08c3bdfSopenharmony_ci	for i in $(seq $LOOP); do
56f08c3bdfSopenharmony_ci		echo 1 >  $TSTACK_TRACE_PATH
57f08c3bdfSopenharmony_ci		echo userstacktrace > $TRACING_PATH/trace_options
58f08c3bdfSopenharmony_ci		grep -q "^userstacktrace"  $TRACING_PATH/trace_options
59f08c3bdfSopenharmony_ci		if [ $? -ne 0 ]; then
60f08c3bdfSopenharmony_ci			tst_brkm TBROK "Failed to set userstacktrace"
61f08c3bdfSopenharmony_ci		fi
62f08c3bdfSopenharmony_ci
63f08c3bdfSopenharmony_ci		if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
64f08c3bdfSopenharmony_ci			exc_page_fault_enable=`cat $EXC_PAGE_FAULT_ENABLE`
65f08c3bdfSopenharmony_ci			echo 1 > $EXC_PAGE_FAULT_ENABLE
66f08c3bdfSopenharmony_ci		else
67f08c3bdfSopenharmony_ci			mm_page_fault_enable=`cat $MM_PAGE_FAULT_ENABLE`
68f08c3bdfSopenharmony_ci			echo 1 > $MM_PAGE_FAULT_ENABLE
69f08c3bdfSopenharmony_ci		fi
70f08c3bdfSopenharmony_ci	done
71f08c3bdfSopenharmony_ci
72f08c3bdfSopenharmony_ci	if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
73f08c3bdfSopenharmony_ci		echo "$exc_page_fault_enable" > $EXC_PAGE_FAULT_ENABLE
74f08c3bdfSopenharmony_ci	else
75f08c3bdfSopenharmony_ci		echo "$mm_page_fault_enable" > $MM_PAGE_FAULT_ENABLE
76f08c3bdfSopenharmony_ci	fi
77f08c3bdfSopenharmony_ci
78f08c3bdfSopenharmony_ci	tst_resm TPASS "Finished running the test"
79f08c3bdfSopenharmony_ci}
80f08c3bdfSopenharmony_ci
81f08c3bdfSopenharmony_ciftrace_userstacktrace_test
82f08c3bdfSopenharmony_ci
83f08c3bdfSopenharmony_citst_exit
84