#!/system/bin/sh
#Fly_core For Fly-On MOD by Slaid480!Thanks to zacharias.maladroit
# voku1987
# collin_ph@xda
# pikachu01


# VFS, VM,Kernel Tweaks

#echo 0 > /proc/sys/vm/swappiness #

mem=`free|grep Mem | awk '{print $2}'`;
totmem=`(echo - | awk -v A=$mem '{print A*1024;}')`;
max=`(echo - | awk -v A=$totmem '{print A*75/100;}')`;
page_size=`cat /proc/sys/kernel/shmmni`;
all=`(echo - | awk -v A=$totmem -v B=$page_size '{print A*80/100/B}')`;


sysctl -w kernel.sem="250 256000 32 1024";
sysctl -w kernel.shmmax="$max";
sysctl -w kernel.shmall="$all";

#echo $max > /proc/sys/kernel/shmmax;
#echo $all > /proc/sys/kernel/shmall;

#sysctl -w kernel.msgmni=1024;

if [ "$mem" -lt 524288 ];then
	sysctl -w vm.dirty_background_ratio=15;
	sysctl -w vm.dirty_ratio=30;
elif [ "$mem" -lt 1049776 ];then
	sysctl -w vm.dirty_background_ratio=10;
	sysctl -w vm.dirty_ratio=20;
else 
	sysctl -w vm.dirty_background_ratio=5;
	sysctl -w vm.dirty_ratio=10;
fi;



sysctl -w vm.page-cluster=3;
sysctl -w vm.laptop_mode=0;
sysctl -w vm.dirty_expire_centisecs=3000;
sysctl -w vm.dirty_writeback_centisecs=500;
sysctl -w vm.vfs_cache_pressure=50;
sysctl -w vm.overcommit_memory=1;
sysctl -w vm.oom_kill_allocating_task=0;

# Tweaking processes at wake

# Phone dialer app ###
#    renice -1 `pidof com.android.phone`;

    # System apps #
#    renice -1 `pidof com.android.mms`; # Text message app
#    renice -1 `pidof com.swype.android.inputmethod`; # Keyboard
#    renice -1 `pidof com.sec.android.app.controlpanel`; # Task manager
#    renice -1 `pidof com.android.systemui`; # Status bar
#    renice -1 `pidof com.android.settings`; # Settings menu
#    renice -1 `pidof com.android.vending`; # Market app
#    renice -1 `pidof com.sec.android.app.camera`; # Camera app
#    renice -1 `pidof android.process.acore`;
#    renice -1 `pidof kondemand/0`;
#    renice -1 `pidof ksmartass_up/0`;
  


# network speed and throughput

# TWEAKS: for TCP read/write

sysctl -w net.ipv4.tcp_timestamps=0;
sysctl -w net.ipv4.tcp_tw_reuse=1;
sysctl -w net.ipv4.tcp_sack=1;
sysctl -w net.ipv4.tcp_dsack=1;
sysctl -w net.ipv4.tcp_tw_recycle=1;
sysctl -w net.ipv4.tcp_window_scaling=1;
sysctl -w net.ipv4.tcp_keepalive_probes=5;
sysctl -w net.ipv4.tcp_keepalive_intvl=30;
sysctl -w net.ipv4.tcp_fin_timeout=30;
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1;

#echo 524288 > /proc/sys/net/core/wmem_max;
#echo 524288 > /proc/sys/net/core/rmem_max;


# increase Linux auto tuning TCP buffer limits
#echo "524280" > /proc/sys/net/core/rmem_default # default: 
#echo "524280" > /proc/sys/net/core/wmem_default # default: 


# Increase the maximum total TCP buffer-space allocatable
#sysctl -w net.ipv4.tcp_mem="57344 57344 524288";

#echo 256960 > /proc/sys/net/core/rmem_default;
#echo 256960 > /proc/sys/net/core/wmem_default;
#echo 4096 16384 404480 > /proc/sys/net/ipv4/tcp_wmem;
#echo 4096 87380 404480 > /proc/sys/net/ipv4/tcp_rmem;


# Increase the tcp-time-wait buckets pool size
#sysctl -w net.ipv4.tcp_max_tw_buckets="1440000"
# default: 180000


# Increase the maximum amount of option memory buffers
#sysctl -w net.core.optmem_max="57344"
# default: 20480


# disable ECN
# enable it - since it's needed for SFB to work properly/optimally
# echo "0" > /proc/sys/net/ipv4/tcp_ecn # default at 2
# explicitly disable it since there's still buggy routers and other stations involved that break networking


# network security related settings

# disables IP source routing (for ipv4)

#for i in /proc/sys/net/ipv4/conf/*; do
#         /bin/echo "0" >  $i/accept_source_route
#done # does not get applied - FIXME

## echo "1" > /proc/sys/net/ipv4/conf/all/accept_source_route ## fix wifi, networking issues # leave at default


#for i in /proc/sys/net/ipv6/conf/*; do
#         /bin/echo "0" >  $i/accept_source_route
#done # does not get applied - FIXME


## echo "1" > /proc/sys/net/ipv6/conf/all/accept_source_route ## fix wifi, networking issues # leave at default

# These commands configure the server to ignore redirects from machines that are listed as
# gateways. Redirect can be used to perform attacks, so we only want to allow them from
# trusted sources:


#for i in /proc/sys/net/ipv4/conf/*; do
#         /bin/echo "1" >  $i/secure_redirects
#done

## echo "0" > /proc/sys/net/ipv4/conf/all/secure_redirects ## fix wifi, networking issues # leave at default

#for i in /proc/sys/net/ipv6/conf/*; do
#         /bin/echo "1" >  $i/secure_redirects
#done


# disables IP redirects (for ipv4)
#for i in /proc/sys/net/ipv4/conf/*; do
#         /bin/echo "0" >  $i/accept_redirects
#done # does not get applied - FIXME

# echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects ## fix wifi, networking issues # leave at default

#for i in /proc/sys/net/ipv6/conf/*; do
#         /bin/echo "0" >  $i/accept_redirects
#done # does not get applied - FIXME

# echo "1" > /proc/sys/net/ipv6/conf/all/accept_redirects ## fix wifi, networking issues # leave at default

# If this server does not act as a router, it does not have to send redirects, so they can be
# disabled:

#for i in /proc/sys/net/ipv4/conf/*; do
#         /bin/echo "0" >  $i/send_redirects
#done # does not get applied - FIXME


# echo "1" > /proc/sys/net/ipv4/conf/all/send_redirects ## fix wifi, networking issues # # leave at default

# Configure the server to ignore broadcast pings and smurf attacks:
# (smurf-attacks)
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1;
if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts ]
then
	echo "1" >  /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts; # default
fi;

# Ignore all kinds of icmp packets or pings:
sysctl -w net.ipv4.icmp_echo_ignore_all=1;
if [ -e /proc/sys/net/ipv6/icmp_echo_ignore_all ]
then
	echo "1" >  /proc/sys/net/ipv6/icmp_echo_ignore_all; # default: 0
fi;


# For HSDPA low throughput
# setprop ro.ril.disable.power.collapse = 1

# Build.prop Tweaks#
setprop ro.telephony.call_ring.delay 1000; # let's minimize the time Android waits until it rings on a call
#setprop dalvik.vm.startheapsize 8m;
if [ "`getprop dalvik.vm.heapsize | sed 's/m//g'`" -lt 64 ];then
	setprop dalvik.vm.heapsize 48m; # leave that setting to cyanogenmod settings or uncomment it if needed
fi;
setprop wifi.supplicant_scan_interval 120; # higher is not recommended, scans while not connected anyway so shouldn't affect while connected
if  [ -z "`getprop windowsmgr.max_events_per_sec`"  ] || [ "`getprop windowsmgr.max_events_per_sec`" -lt 90 ];then
	setprop windowsmgr.max_events_per_sec 90; # smoother GUI
fi;


# TWEAKS:Disable Gentle Fair Sleepers

echo "NO_GENTLE_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;
echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;
echo "NO_NORMALIZED_SLEEPER" > /sys/kernel/debug/sched_features;



# remove lag when answering phone calls 

#MAX_PHONE() 
#{
#pidphone=`pidof com.android.phone`;
#if [ $pidphone ]; # Wait for com.android.phone to start;
#then#
#	echo -17 > /proc/$pidphone/oom_adj; # exclude com.android.phone from oom-killer;
#	renice -20 $pidphone; # set highest nice level for com.android.phone;
##	log -p i -t SSSwitch_v0.8 "*** MAX phone *** set oom_adj(-17) and nice(-20) for com.android.phone";
#	exit;
#else
#	sleep 5;
#	MAX_PHONE;
#fi;
#}




# Background process to optimize dialer process 
#(while [ 1 ];
#do
#	sleep 10;
#	MAX_PHONE;
#done &);






# renicing kswapd 

#KSWAPD_RENICE() 
#{
#pidkswapd=`pidof kswapd0`;
#if [ $pidkswapd ]; # Wait for kswapd to be available;
#then
#	renice 19 $pidkswapd; # set kswapd lowest nice level possible;
#	exit;
#else
#	sleep 5;
#	KSWAPD_RENICE;
#fi;
#}



# =========
#(while [ 1 ];
#do
#	sleep 10;
#	KSWAPD_RENICE;
#done &);





# Governor Tweaks

# Ondemand

	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/ondemand/up_threshold ]; then
	
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/sampling_rate;
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpufreq/ondemand/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
	fi;
	
	

# OndemandX

	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpu0/cpufreq/ondemandx/sampling_rate;
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/up_threshold ]; then
	
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpu1/cpufreq/ondemandx/sampling_rate;
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/ondemandx/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/ondemandx/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpufreq/ondemandx/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpufreq/ondemandx/io_is_busy;
		#echo "1" > /sys/devices/system/cpu/cpufreq/ondemandx/sampling_down_factor;
		#echo "20000" > /sys/devices/system/cpu/cpufreq/ondemandx/sampling_rate;
	fi;



# Conservative 


	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/conservative/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/up_threshold;
		echo "75" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
        	echo "100" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/conservative/up_threshold ]; then
	
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/conservative/up_threshold;
		echo "75" > /sys/devices/system/cpu/cpu1/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
        	echo "100" > /sys/devices/system/cpu/cpu1/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/conservative/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold;
		echo "75" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
        	echo "100" > /sys/devices/system/cpu/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
	fi;


# lulzactive 

	if [ -e /sys/devices/system/cpu/cpufreq/lulzactive/inc_cpu_load ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/lulzactive/inc_cpu_load;
#		if [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1200000 ]; then
#			echo "4" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
			
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1400000 ]; then 
#			echo "5" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1600000 ]; then 
#			echo "6" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 100000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1200000 ]; then 
#			echo "5" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 100000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1400000 ]; then 
#			echo "6" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 100000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1600000 ]; then 
#			echo "7" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 100000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 800000 ]; then 
#			echo "3" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 100000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1000000 ]; then 
#			echo "4" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 800000 ]; then 
#			echo "2" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		elif [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ] && [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`" -eq 1000000 ]; then 
#			echo "3" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_up_step;
#		fi;
		echo "1" > /sys/devices/system/cpu/cpufreq/lulzactive/pump_down_step;
#		echo "4" > /sys/devices/system/cpu/cpufreq/lulzactive/screen_off_min_step;
	fi;

# smartassV2 


	if [ -e /sys/devices/system/cpu/cpufreq/smartass/awake_ideal_freq ]; then

		echo "500000" > /sys/devices/system/cpu/cpufreq/smartass/awake_ideal_freq;
		if [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ]; then
			echo "200000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_ideal_freq;
		else 
			echo "100000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_ideal_freq;
		fi;
		
		echo "800000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_wakeup_freq;

		echo "85" > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load;
		echo "75" > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load;

		echo "200000" > /sys/devices/system/cpu/cpufreq/smartass/ramp_down_step;
		echo "0" > /sys/devices/system/cpu/cpufreq/smartass/ramp_up_step;

	fi;


# abyssplug

	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpu0/cpufreq/abyssplug/sampling_rate;
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpu1/cpufreq/abyssplug/sampling_rate;
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/abyssplug/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/abyssplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpufreq/abyssplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpufreq/abyssplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpufreq/abyssplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpufreq/abyssplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpufreq/abyssplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpufreq/abyssplug/sampling_rate;
	fi;


# Pegasusq


	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/io_is_busy;
		echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/sampling_down_factor;
		echo "20000" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/sampling_rate;
		echo "100" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/freq_step;
		echo "5" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/cpu_up_rate;
		echo "20" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/cpu_down_rate;
		echo "100000" > /sys/devices/system/cpu/cpu0/cpufreq/pegasusq/freq_for_responsiveness;
		
		
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/io_is_busy;
		echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/sampling_down_factor;
		echo "20000" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/sampling_rate;
		echo "100" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/freq_step;
		echo "5" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/cpu_up_rate;
		echo "20" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/cpu_down_rate;
		echo "100000" > /sys/devices/system/cpu/cpu1/cpufreq/pegasusq/freq_for_responsiveness;
		
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/pegasusq/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/pegasusq/up_threshold;
		echo "10" > /sys/devices/system/cpu/cpufreq/pegasusq/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpufreq/pegasusq/io_is_busy;
		echo "1" > /sys/devices/system/cpu/cpufreq/pegasusq/sampling_down_factor;
		echo "20000" > /sys/devices/system/cpu/cpufreq/pegasusq/sampling_rate;
		echo "100" > /sys/devices/system/cpu/cpufreq/pegasusq/freq_step;
		echo "5" > /sys/devices/system/cpu/cpufreq/pegasusq/cpu_up_rate;
		echo "20" > /sys/devices/system/cpu/cpufreq/pegasusq/cpu_down_rate;
		echo "100000" > /sys/devices/system/cpu/cpufreq/pegasusq/freq_for_responsiveness;
		
		
	fi;


# Hotplug


	if [ -e /sys/devices/system/cpu/cpu0/cpufreq/hotplug/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpu0/cpufreq/hotplug/sampling_rate;
	fi;		
	if [ -e /sys/devices/system/cpu/cpu1/cpufreq/hotplug/up_threshold ]; then
		echo "85" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpu1/cpufreq/hotplug/sampling_rate;
		
	fi;
	if [ -e /sys/devices/system/cpu/cpufreq/hotplug/up_threshold ]; then

		echo "85" > /sys/devices/system/cpu/cpufreq/hotplug/up_threshold;
		echo "40" > /sys/devices/system/cpu/cpufreq/hotplug/down_threshold;
		echo "5" > /sys/devices/system/cpu/cpufreq/hotplug/hotplug_in_sampling_periods;
		echo "20" > /sys/devices/system/cpu/cpufreq/hotplug/hotplug_out_sampling_periods;
		echo "10" > /sys/devices/system/cpu/cpufreq/hotplug/down_differential;
		#echo "1" > /sys/devices/system/cpu/cpufreq/hotplug/io_is_busy;
		echo "20000" > /sys/devices/system/cpu/cpufreq/hotplug/sampling_rate;
	fi;

