~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/bootconfig/scripts/bconf2ftrace.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/bootconfig/scripts/bconf2ftrace.sh (Version linux-6.11.5) and /tools/bootconfig/scripts/bconf2ftrace.sh (Version linux-2.6.32.71)


  1 #!/bin/sh                                         
  2 # SPDX-License-Identifier: GPL-2.0-only           
  3                                                   
  4 usage() {                                         
  5         echo "Ftrace boottime trace test tool"    
  6         echo "Usage: $0 [--apply|--init] [--de    
  7         echo "    --apply: Test actual apply t    
  8         echo "    --init:  Initialize ftrace b    
  9         exit 1                                    
 10 }                                                 
 11                                                   
 12 [ $# -eq 0 ] && usage                             
 13                                                   
 14 BCONF=                                            
 15 DEBUG=                                            
 16 APPLY=                                            
 17 INIT=                                             
 18 while [ x"$1" != x ]; do                          
 19         case "$1" in                              
 20         "--debug")                                
 21                 DEBUG=$1;;                        
 22         "--apply")                                
 23                 APPLY=$1;;                        
 24         "--init")                                 
 25                 APPLY=$1                          
 26                 INIT=$1;;                         
 27         *)                                        
 28                 [ ! -f $1 ] && usage              
 29                 BCONF=$1;;                        
 30         esac                                      
 31         shift 1                                   
 32 done                                              
 33                                                   
 34 if [ x"$APPLY" != x ]; then                       
 35         if [ `id -u` -ne 0 ]; then                
 36                 echo "This must be run by root    
 37                 exec sudo $0 $DEBUG $APPLY $BC    
 38         fi                                        
 39 fi                                                
 40                                                   
 41 run_cmd() { # command                             
 42         echo "$*"                                 
 43         if [ x"$APPLY" != x ]; then # apply co    
 44                 eval $*                           
 45         fi                                        
 46 }                                                 
 47                                                   
 48 if [ x"$DEBUG" != x ]; then                       
 49         set -x                                    
 50 fi                                                
 51                                                   
 52 TRACEFS=`grep -m 1 -w tracefs /proc/mounts | c    
 53 if [ -z "$TRACEFS" ]; then                        
 54         if ! grep -wq debugfs /proc/mounts; th    
 55                 echo "Error: No tracefs/debugf    
 56                 exit 1                            
 57         fi                                        
 58         TRACEFS=`grep -m 1 -w debugfs /proc/mo    
 59         if [ ! -d $TRACEFS ]; then                
 60                 echo "Error: ftrace is not ena    
 61                 exit 1                            
 62         fi                                        
 63 fi                                                
 64                                                   
 65 if [ x"$INIT" != x ]; then                        
 66         . `dirname $0`/ftrace.sh                  
 67         (cd $TRACEFS; initialize_ftrace)          
 68 fi                                                
 69                                                   
 70 . `dirname $0`/xbc.sh                             
 71                                                   
 72 ######## main #########                           
 73 set -e                                            
 74                                                   
 75 xbc_init $BCONF                                   
 76                                                   
 77 set_value_of() { # key file                       
 78         if xbc_has_key $1; then                   
 79                 val=`xbc_get_val $1 1`            
 80                 run_cmd "echo '$val' >> $2"       
 81         fi                                        
 82 }                                                 
 83                                                   
 84 set_array_of() { # key file                       
 85         if xbc_has_key $1; then                   
 86                 xbc_get_val $1 | while read li    
 87                         run_cmd "echo '$line'     
 88                 done                              
 89         fi                                        
 90 }                                                 
 91                                                   
 92 compose_synth() { # event_name branch             
 93         echo -n "$1 "                             
 94         xbc_get_val $2 | while read field; do     
 95 }                                                 
 96                                                   
 97 print_hist_array() { # prefix key                 
 98         __sep="="                                 
 99         if xbc_has_key ${1}.${2}; then            
100                 echo -n ":$2"                     
101                 xbc_get_val ${1}.${2} | while     
102                         echo -n "$__sep$field"    
103                 done                              
104         fi                                        
105 }                                                 
106                                                   
107 print_hist_action_array() { # prefix key          
108         __sep="("                                 
109         echo -n ".$2"                             
110         xbc_get_val ${1}.${2} | while read fie    
111                 echo -n "$__sep$field"; __sep=    
112         done                                      
113         echo -n ")"                               
114 }                                                 
115                                                   
116 print_hist_one_action() { # prefix handler par    
117         echo -n ":${2}("`xbc_get_val ${1}.${3}    
118         if xbc_has_key "${1}.trace"; then         
119                 print_hist_action_array ${1} "    
120         elif xbc_has_key "${1}.save"; then        
121                 print_hist_action_array ${1} "    
122         elif xbc_has_key "${1}.snapshot"; then    
123                 echo -n ".snapshot()"             
124         fi                                        
125 }                                                 
126                                                   
127 print_hist_actions() { # prefix handler param     
128         for __hdr in `xbc_subkeys ${1}.${2} 1     
129                 print_hist_one_action ${1}.${2    
130         done                                      
131         if xbc_has_key ${1}.${2}.${3} ; then      
132                 print_hist_one_action ${1}.${2    
133         fi                                        
134 }                                                 
135                                                   
136 print_hist_var() { # prefix varname               
137         echo -n ":${2}="`xbc_get_val ${1}.var.    
138 }                                                 
139                                                   
140 print_one_histogram() { # prefix                  
141         echo -n "hist"                            
142         print_hist_array $1 "keys"                
143         print_hist_array $1 "values"              
144         print_hist_array $1 "sort"                
145         if xbc_has_key "${1}.size"; then          
146                 echo -n ":size="`xbc_get_val $    
147         fi                                        
148         if xbc_has_key "${1}.name"; then          
149                 echo -n ":name="`xbc_get_val $    
150         fi                                        
151         for __var in `xbc_subkeys "${1}.var" 1    
152                 print_hist_var ${1} ${__var}      
153         done                                      
154         if xbc_has_key "${1}.pause"; then         
155                 echo -n ":pause"                  
156         elif xbc_has_key "${1}.continue"; then    
157                 echo -n ":continue"               
158         elif xbc_has_key "${1}.clear"; then       
159                 echo -n ":clear"                  
160         fi                                        
161         print_hist_actions ${1} "onmax" "var"     
162         print_hist_actions ${1} "onchange" "va    
163         print_hist_actions ${1} "onmatch" "eve    
164                                                   
165         if xbc_has_key "${1}.filter"; then        
166                 echo -n " if "`xbc_get_val ${1    
167         fi                                        
168 }                                                 
169                                                   
170 setup_one_histogram() { # prefix trigger-file     
171         run_cmd "echo '`print_one_histogram ${    
172 }                                                 
173                                                   
174 setup_histograms() { # prefix trigger-file        
175         for __hist in `xbc_subkeys ${1} 1 ".[0    
176                 setup_one_histogram ${1}.$__hi    
177         done                                      
178         if xbc_has_key ${1}.keys; then            
179                 setup_one_histogram ${1} ${2}     
180         fi                                        
181 }                                                 
182                                                   
183 setup_event() { # prefix group event [instance    
184         branch=$1.$2.$3                           
185         if [ "$4" ]; then                         
186                 eventdir="$TRACEFS/instances/$    
187         else                                      
188                 eventdir="$TRACEFS/events/$2/$    
189         fi                                        
190         # group enable                            
191         if [ "$3" = "enable" ]; then              
192                 run_cmd "echo 1 > ${eventdir}"    
193                 return                            
194         fi                                        
195                                                   
196         case $2 in                                
197         kprobes)                                  
198                 xbc_get_val ${branch}.probes |    
199                         run_cmd "echo 'p:kprob    
200                 done                              
201                 ;;                                
202         synthetic)                                
203                 run_cmd "echo '`compose_synth     
204                 ;;                                
205         esac                                      
206                                                   
207         set_value_of ${branch}.filter ${eventd    
208         set_array_of ${branch}.actions ${event    
209                                                   
210         setup_histograms ${branch}.hist ${even    
211                                                   
212         if xbc_has_key ${branch}.enable; then     
213                 run_cmd "echo 1 > ${eventdir}/    
214         fi                                        
215 }                                                 
216                                                   
217 setup_events() { # prefix("ftrace" or "ftrace.    
218         prefix="${1}.event"                       
219         if xbc_has_branch ${1}.event; then        
220                 for grpev in `xbc_subkeys ${1}    
221                         setup_event $prefix ${    
222                 done                              
223         fi                                        
224         if xbc_has_branch ${1}.event.enable; t    
225                 if [ "$2" ]; then                 
226                         run_cmd "echo 1 > $TRA    
227                 else                              
228                         run_cmd "echo 1 > $TRA    
229                 fi                                
230         fi                                        
231 }                                                 
232                                                   
233 size2kb() { # size[KB|MB]                         
234         case $1 in                                
235         *KB)                                      
236                 echo ${1%KB};;                    
237         *MB)                                      
238                 expr ${1%MB} \* 1024;;            
239         *)                                        
240                 expr $1 / 1024 ;;                 
241         esac                                      
242 }                                                 
243                                                   
244 setup_instance() { # [instance]                   
245         if [ "$1" ]; then                         
246                 instance="ftrace.instance.${1}    
247                 instancedir=$TRACEFS/instances    
248         else                                      
249                 instance="ftrace"                 
250                 instancedir=$TRACEFS              
251         fi                                        
252                                                   
253         set_array_of ${instance}.options ${ins    
254         set_value_of ${instance}.trace_clock $    
255         set_value_of ${instance}.cpumask ${ins    
256         set_value_of ${instance}.tracing_on ${    
257         set_value_of ${instance}.tracer ${inst    
258         set_array_of ${instance}.ftrace.filter    
259                 ${instancedir}/set_ftrace_filt    
260         set_array_of ${instance}.ftrace.notrac    
261                 ${instancedir}/set_ftrace_notr    
262                                                   
263         if xbc_has_key ${instance}.alloc_snaps    
264                 run_cmd "echo 1 > ${instancedi    
265         fi                                        
266                                                   
267         if xbc_has_key ${instance}.buffer_size    
268                 size=`xbc_get_val ${instance}.    
269                 size=`eval size2kb $size`         
270                 run_cmd "echo $size >> ${insta    
271         fi                                        
272                                                   
273         setup_events ${instance} $1               
274         set_array_of ${instance}.events ${inst    
275 }                                                 
276                                                   
277 # ftrace global configs (kernel.*)                
278 if xbc_has_key "kernel.dump_on_oops"; then        
279         dump_mode=`xbc_get_val "kernel.dump_on    
280         [ "$dump_mode" ] && dump_mode=`eval ec    
281         run_cmd "echo \"$dump_mode\" > /proc/s    
282 fi                                                
283                                                   
284 set_value_of kernel.fgraph_max_depth $TRACEFS/    
285 set_array_of kernel.fgraph_filters $TRACEFS/se    
286 set_array_of kernel.fgraph_notraces $TRACEFS/s    
287                                                   
288 # Per-instance/per-event configs                  
289 if ! xbc_has_branch "ftrace" ; then               
290         exit 0                                    
291 fi                                                
292                                                   
293 setup_instance # root instance                    
294                                                   
295 if xbc_has_branch "ftrace.instance"; then         
296         for i in `xbc_subkeys "ftrace.instance    
297                 run_cmd "mkdir -p $TRACEFS/ins    
298                 setup_instance $i                 
299         done                                      
300 fi                                                
301                                                   
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php