Home | History | Annotate | Download | only in ftrace_stress
      1 #! /bin/sh
      2 
      3 ###############################################################################
      4 #                                                                             #
      5 # Copyright (c) 2010 FUJITSU LIMITED                                          #
      6 #                                                                             #
      7 # This program is free software; you can redistribute it and/or modify it     #
      8 # under the terms of the GNU General Public License as published by the Free  #
      9 # Software Foundation; either version 2 of the License, or (at your option)   #
     10 # any later version.                                                          #
     11 #                                                                             #
     12 # Author: Li Zefan <lizf (at] cn.fujitsu.com>                                      #
     13 #                                                                             #
     14 ###############################################################################
     15 
     16 LOOP=200
     17 
     18 # Use up to 10% of free memory
     19 free_mem=`cat /proc/meminfo | grep '^MemFree' | awk '{ print $2 }'`
     20 cpus=`tst_ncpus`
     21 
     22 step=$(( $free_mem / 10 / $LOOP / $cpus ))
     23 
     24 if [ $step -eq 0 ]; then
     25 	step=1
     26 	LOOP=50
     27 fi
     28 
     29 while true; do
     30 	new_size=1
     31 	i=0
     32 	while [ $i -lt $LOOP ]; do
     33 		echo $new_size > "$TRACING_PATH"/buffer_size_kb
     34 		new_size=$(( $new_size + $step ))
     35 		i=$((i + 1))
     36 	done
     37 
     38 	i=0
     39 	while [ $i -lt $LOOP ]; do
     40 		new_size=$(( $new_size - $step ))
     41 		echo $new_size > "$TRACING_PATH"/buffer_size_kb
     42 		i=$((i + 1))
     43 	done
     44 	sleep 1
     45 done
     46