-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoilwork_Performance_OP5.sh
589 lines (545 loc) · 22 KB
/
Soilwork_Performance_OP5.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
#!/system/bin/sh
#Original author: Alcolawl
#Original script By: RogerF81 + adanteon
#Settings By: RogerF81
#Device: OnePlus 5
#Codename: SoilWork UNIFIED
#SoC: Snapdragon 835
#Last Updated: 01/11/2017
#Credits: @Alcolawl @soniCron @Asiier @Freak07 @Mostafa Wael @Senthil360 @TotallyAnxious @RenderBroken @ZeroInfinity @Kyuubi10 @ivicask @RogerF81 @joshuous @boyd95 @ZeroKool76 @adanteon
codename=Soilwork
stype=Performance
version=V1.2
cdate=$(date)
DLL=/storage/emulated/0/soilwork_log.txt
#Disable BCL
if [ -e "/sys/devices/soc/soc:qcom,bcl/mode" ]; then
echo "*Disabling BCL" >> $DLL
chmod 644 /sys/devices/soc/soc:qcom,bcl/mode
echo -n disable > /sys/devices/soc/soc:qcom,bcl/mode
fi
##Configuring stune
if [ -d "/dev/stune" ]; then
echo "Configuring stune" >> $DLL
echo 10 > /dev/stune/top-app/schedtune.boost
echo 0 > /dev/stune/background/schedtune.boost
echo 0 > /dev/stune/foreground/schedtune.boost
echo 0 > /dev/stune/schedtune.prefer_idle
echo 0 > /proc/sys/kernel/sched_child_runs_first
#echo 0 > /proc/sys/kernel/sched_cfs_boost
echo 0 > /dev/stune/background/schedtune.prefer_idle
echo 1 > /dev/stune/foreground/schedtune.prefer_idle
echo 1 > /dev/stune/top-app/schedtune.prefer_idle
if [ -e "/proc/sys/kernel/sched_autogroup_enabled" ]; then
echo 0 > /proc/sys/kernel/sched_autogroup_enabled
fi
if [ -e "/proc/sys/kernel/sched_is_big_little" ]; then
echo 1 > /proc/sys/kernel/sched_is_big_little
fi
if [ -e "/proc/sys/kernel/sched_boost" ]; then
echo 0 > /proc/sys/kernel/sched_boost
fi
fi
#Do not decrease sleep time
sleep 30
#Initializing log
echo "$cdate" > $DLL
echo "$codename $stype" >> $DLL
echo "*Searching CPU frequencies" >> $DLL
big_max_value=0
little_max_value=0
big_min_value=0
little_min_value=0
little_max_value=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq);
big_max_value=$(cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_max_freq);
little_min_value=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq);
big_min_value=$(cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_min_freq);
#Stopping perfd
if [ -e "/data/system/perfd" ]; then
echo "*Stopping perfd" >> $DLL
stop perfd
fi
#Disable BCL
if [ -e "/sys/devices/soc/soc:qcom,bcl/mode" ]; then
echo "*Disabling BCL" >> $DLL
chmod 644 /sys/devices/soc/soc:qcom,bcl/mode
echo -n disable > /sys/devices/soc/soc:qcom,bcl/mode
fi
#Turn on all cores
echo "*Turning on cores" >> $DLL
chmod 644 /sys/devices/system/cpu/online
echo 0-7 > /sys/devices/system/cpu/online
chmod 444 /sys/devices/system/cpu/online
echo 1 > /sys/devices/system/cpu/cpu0/online
echo 1 > /sys/devices/system/cpu/cpu1/online
echo 1 > /sys/devices/system/cpu/cpu2/online
echo 1 > /sys/devices/system/cpu/cpu4/online
echo 1 > /sys/devices/system/cpu/cpu5/online
echo 1 > /sys/devices/system/cpu/cpu6/online
echo 1 > /sys/devices/system/cpu/cpu7/online
chmod 664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 664 /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
chmod 664 /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
echo $little_max_value > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $little_min_value > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $big_max_value > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
echo $big_min_value > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
#Apply settings to LITTLE cluster
echo "*Applying LITTLE settings" >> $DLL
echo " +Searching available governors" >> $DLL
if [ -d /sys/devices/system/cpu/cpufreq/policy0 ]; then
if [ -e /sys/devices/system/cpu/cpufreq/policy0 ]; then
LGP=/sys/devices/system/cpu/cpufreq/policy0
fi
AGL=/sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors;
if grep 'schedutil' $AGL; then
if [ -e $AGL ]; then
echo " +Applying & tuning schedutil" >> $DLL
echo schedutil > $LGP/scaling_governor
sleep 1
echo 500 > $LGP/schedutil/up_rate_limit_us
echo 20000 > $LGP/schedutil/down_rate_limit_us
echo 50 > /sys/module/cpu_boost/parameters/dynamic_stune_boost
echo 128 > /proc/sys/kernel/sched_nr_migrate
echo 1 > /proc/sys/kernel/sched_cstate_aware
echo 10 > /proc/sys/kernel/sched_initial_task_util
if [ -e "/proc/sys/kernel/sched_autogroup_enabled" ]; then
echo 0 > /proc/sys/kernel/sched_autogroup_enabled
fi
if [ -e "/proc/sys/kernel/sched_is_big_little" ]; then
echo 1 > /proc/sys/kernel/sched_is_big_little
fi
if [ -e "/proc/sys/kernel/sched_boost" ]; then
echo 0 > /proc/sys/kernel/sched_boost
fi
if [ -e "/proc/sys/kernel/sched_use_walt_task_util" ]; then
echo 1 > /proc/sys/kernel/sched_use_walt_task_util
echo 1 > /proc/sys/kernel/sched_use_walt_cpu_util
echo 10 > /proc/sys/kernel/sched_walt_init_task_load_pct
echo 10000000 > /proc/sys/kernel/sched_walt_cpu_high_irqload
fi
fi
echo " +Tuning finished for schedutil" >> $DLL
elif grep 'interactive' $AGL; then
if [ -e $AGL ]; then
echo 50 > /proc/sys/kernel/sched_upmigrate
echo 15 > /proc/sys/kernel/sched_downmigrate
echo 15 > /proc/sys/kernel/sched_small_wakee_task_load
echo 0 > /proc/sys/kernel/sched_init_task_load
if [ -e /proc/sys/kernel/sched_enable_power_aware ]; then
echo 1 > /proc/sys/kernel/sched_enable_power_aware
fi
echo 1 > /proc/sys/kernel/sched_enable_thread_grouping
echo 30 > /proc/sys/kernel/sched_big_waker_task_load
echo 3 > /proc/sys/kernel/sched_window_stats_policy
echo 4 > /proc/sys/kernel/sched_ravg_hist_size
if [ -e /proc/sys/kernel/sched_upmigrate_min_nice ]; then
echo 9 > /proc/sys/kernel/sched_upmigrate_min_nice
fi
echo 3 > /proc/sys/kernel/sched_spill_nr_run
echo 55 > /proc/sys/kernel/sched_spill_load
echo 1 > /proc/sys/kernel/sched_enable_thread_grouping
echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill
if [ -e /proc/sys/kernel/sched_wakeup_load_threshold ]; then
echo 110 > /proc/sys/kernel/sched_wakeup_load_threshold
fi
echo 30 > /proc/sys/kernel/sched_rr_timeslice_ms
if [ -e /proc/sys/kernel/sched_migration_fixup ]; then
echo 1 > /proc/sys/kernel/sched_migration_fixup
fi
if [ -e /proc/sys/kernel/sched_boost ]; then
echo 0 > /proc/sys/kernel/sched_boost
fi
if [ -e "/proc/sys/kernel/sched_heavy_task" ]; then
echo 55 > /proc/sys/kernel/sched_heavy_task
fi
if [ -e "/proc/sys/kernel/sched_enable_power_aware" ]; then
echo 1 > /proc/sys/kernel/sched_enable_power_aware
fi
if [ -e "/proc/sys/kernel/sched_small_task" ]; then
echo 10 > /proc/sys/kernel/sched_small_task
fi
if [ -e "/proc/sys/kernel/sched_migration_fixup" ]; then
echo 1 > /proc/sys/kernel/sched_migration_fixup
fi
if [ -e "/proc/sys/kernel/sched_boost" ]; then
echo 0 > /proc/sys/kernel/sched_boost
fi
if [ -e "/sys/devices/system/cpu/cpu0/cpufreq/interactive/screen_off_maxfreq" ]; then
echo 595200 > $LGP/interactive/screen_off_maxfreq
fi
if [ -e "/sys/devices/system/cpu/cpu0/cpufreq/interactive/powersave_bias" ]; then
echo 0 > $LGP/interactive/powersave_bias
fi
if grep 'blu_active' $AGL; then
if [ -e $AGL ]; then
echo " +Applying & tuning blu_active" >> $DLL
echo blu_active > $LGP/scaling_governor
sleep 1
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/blu_active/*
chmod 644 $LGP/blu_active/*
echo 70 595200:75 883200:83 1248000:85 1401600:90 > $LGP/blu_active/target_loads
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/blu_active/target_loads
echo 384050 > $LGP/blu_active/timer_slack
chmod 644 $LGP/blu_active/timer_rate
echo 20000 > $LGP/blu_active/timer_rate
echo 1248000 > $LGP/blu_active/hispeed_freq
echo 0 595200:20000 883200:50000 1401600:75000 > $LGP/blu_active/above_hispeed_delay
echo 400 > $LGP/blu_active/go_hispeed_load
echo 0 > $LGP/blu_active/min_sample_time
echo 1 > $LGP/blu_active/fastlane
echo 50 > $LGP/blu_active/fastlane_threshold
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/blu_active/*
chmod 444 $LGP/blu_active/*
fi
echo " +Tuning finished for blu_active" >> $DLL
else
if [ -e $AGL ]; then
echo " +Applying & tuning interactive" >> $DLL
echo interactive > $LGP/scaling_governor
sleep 1
chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/interactive/*
chmod 644 $LGP/interactive/*
echo 70 595200:75 883200:83 1248000:85 1401600:90 > $LGP/interactive/target_loads
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads
echo 384050 > $LGP/interactive/timer_slack
chmod 644 $LGP/interactive/timer_rate
echo 20000 > $LGP/interactive/timer_rate
echo 1248000 > $LGP/interactive/hispeed_freq
echo 0 595200:20000 883200:50000 1401600:75000 > $LGP/interactive/above_hispeed_delay
echo 400 > $LGP/interactive/go_hispeed_load
echo 0 > $LGP/interactive/min_sample_time
echo 0 > $LGP/interactive/max_freq_hysteresis
echo 1 > $LGP/interactive/ignore_hispeed_on_notif
echo 0 > $LGP/interactive/boost
echo 0 > $LGP/interactive/fast_ramp_down
echo 0 > $LGP/interactive/align_windows
echo 1 > $LGP/interactive/use_migration_notif
echo 1 > $LGP/interactive/use_sched_load
echo 0 > $LGP/interactive/boostpulse_duration
echo 0 > $LGP/interactive/io_is_busy
echo 0 > $LGP/interactive/enable_prediction
chmod 444 /sys/devices/system/cpu/cpu0/cpufreq/interactive/*
chmod 444 $LGP/interactive/*
echo " +Tuning finished for interactive" >> $DLL
fi
fi
fi
else
echo " -The governor's path is wrong or mod is incompatible" >> $DLL
echo " -Error Code #01" >> $DLL
fi
fi
echo " *LITTLE settings finished" >> $DLL
#Apply settings to big cluster
echo "*Applying big settings" >> $DLL
echo " +Searching available governors" >> $DLL
if [ -d /sys/devices/system/cpu/cpufreq/policy4 ]; then
if [ -e /sys/devices/system/cpu/cpufreq/policy4 ]; then
BGP=/sys/devices/system/cpu/cpufreq/policy4
fi
AGB=/sys/devices/system/cpu/cpufreq/policy4/scaling_available_governors;
if grep 'schedutil' $AGB; then
if [ -e $AGB ]; then
echo " +Applying schedutil" >> $DLL
echo schedutil > $BGP/scaling_governor
sleep 1
echo 500 > $BGP/schedutil/up_rate_limit_us
echo 20000 > $BGP/schedutil/down_rate_limit_us
fi
echo " +Tuning finished for schedutil" >> $DLL
elif grep 'blu_active' $AGB; then
if [ -e $AGB ]; then
echo " Applying & tuning blu_active" >> $DLL
echo blu_active > $BGP/scaling_governor
sleep 1
chmod 644 /sys/devices/system/cpu/cpu4/cpufreq/blu_active/*
chmod 644 $BGP/blu_active/*
echo 64 576000:75 1132800:85 2265600:93 > $BGP/blu_active/target_loads
chmod 444 /sys/devices/system/cpu/cpu4/cpufreq/blu_active/target_loads
echo 178470 > $BGP/blu_active/timer_slack
echo 2457400 > $BGP/blu_active/hispeed_freq
chmod 644 $BGP/blu_active/timer_rate
echo 30000 > $BGP/blu_active/timer_rate
echo 0 1132800:80000 > $BGP/blu_active/above_hispeed_delay
echo 350 > $BGP/blu_active/go_hispeed_load
echo 50000 > $BGP/blu_active/min_sample_time
echo 0 > $BGP/blu_active/align_windows
echo 1 > $BGP/blu_active/fastlane
echo 50 > $BGP/blu_active/fastlane_threshold
chmod 444 /sys/devices/system/cpu/cpu4/cpufreq/blu_active/*
chmod 444 $BGP/blu_active/*
echo " +Tuning finished for blu_active" >> $DLL
fi
elif grep 'interactive' $AGB; then
if [ -e $AGB ]; then
echo " Applying & tuning interactive" >> $DLL
echo interactive > $BGP/scaling_governor
sleep 1
chmod 644 /sys/devices/system/cpu/cpu4/cpufreq/interactive/*
chmod 644 $BGP/interactive/*
echo 64 576000:75 1132800:85 2265600:93 > $BGP/interactive/target_loads
chmod 444 /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads
echo 178470 > $BGP/interactive/timer_slack
echo 2457400 > $BGP/interactive/hispeed_freq
chmod 644 $BGP/interactive/timer_rate
echo 30000 > $BGP/interactive/timer_rate
echo 0 1132800:80000 > $BGP/interactive/above_hispeed_delay
echo 350 > $BGP/interactive/go_hispeed_load
echo 50000 > $BGP/interactive/min_sample_time
echo 0 > $BGP/interactive/max_freq_hysteresis
echo 1 > $BGP/interactive/ignore_hispeed_on_notif
echo 0 > $BGP/interactive/boost
echo 0 > $BGP/interactive/fast_ramp_down
echo 0 > $BGP/interactive/align_windows
echo 1 > $BGP/interactive/use_migration_notif
echo 1 > $BGP/interactive/use_sched_load
echo 0 > $BGP/interactive/boostpulse_duration
echo 0 > $BGP/interactive/io_is_busy
echo 0 > $BGP/interactive/enable_prediction
chmod 444 /sys/devices/system/cpu/cpu4/cpufreq/interactive/*
chmod 444 $BGP/interactive/*
echo " +Tuning finished for interactive" >> $DLL
fi
else
echo " -The governor's path is wrong or mod is incompatible" >> $DLL
echo " -Error Code #02" >> $DLL
fi
fi
echo " *big settings finished" >> $DLL
#Enable work queue to be power efficient
if [ -e /sys/module/workqueue/parameters/power_efficient ]; then
echo "*Enabling power saving work queue" >> $DLL
chmod 644 /sys/module/workqueue/parameters/power_efficient
echo Y > /sys/module/workqueue/parameters/power_efficient
chmod 444 /sys/module/workqueue/parameters/power_efficient
fi
# #Tweak VoxPopuli -- Only on EAS kernels
# if [ -d /dev/voxpopuli/ ]; then
# echo "*Tweaking Vox Populi PowerHal" >> $DLL
# VOX_P=/dev/voxpopuli/
# echo 1 > $VOX_P/enable_interaction_boost #Main switch
# echo 0 > $VOX_P/fling_min_boost_duration
# echo 2500 > $VOX_P/fling_max_boost_duration
# echo 10 > $VOX_P/fling_boost_topapp
# echo 940 > $VOX_P/fling_min_freq_big
# echo 960 > $VOX_P/fling_min_freq_little
# echo 200 > $VOX_P/touch_boost_duration
# echo 5 > $VOX_P/touch_boost_topapp
# echo 806 > $VOX_P/touch_min_freq_big
# echo 960 > $VOX_P/touch_min_freq_little
# fi
# #Tweak input boost -- Only Sultanized ROMs
# if [ -e "/sys/kernel/cpu_input_boost" ]; then
# echo "*Tweaking input boost" >> $dll
# chmod 644 /sys/kernel/cpu_input_boost/*
# echo 1 > /sys/kernel/cpu_input_boost/enable
# echo 66 > /sys/kernel/cpu_input_boost/ib_duration_ms
# echo 537600 537600 > /sys/kernel/cpu_input_boost/ib_freqs
# chmod 444 /sys/kernel/cpu_input_boost/*
# fi
# #Tweak cpu boost
if [ -e "/sys/module/cpu_boost" ]; then
echo "*Tweaking CPU Boost" >> $DLL
chmod 644 /sys/module/cpu_boost/parameters/input_boost_enabled
echo 1 > /sys/module/cpu_boost/parameters/input_boost_enabled
chmod 644 /sys/module/cpu_boost/parameters/input_boost_freq
echo 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 > /sys/module/cpu_boost/parameters/input_boost_freq
chmod 644 /sys/module/cpu_boost/parameters/input_boost_ms
echo 1000 > /sys/module/cpu_boost/parameters/input_boost_ms
if [ -e "/sys/module/msm_performance/parameters/touchboost/sched_boost_on_input " ]; then
echo N > /sys/module/msm_performance/parameters/touchboost/sched_boost_on_input
fi
fi
#Disable TouchBoost -- HMP only
if [ -e "/sys/module/msm_performance/parameters/touchboost" ]; then
echo "*Disabling TouchBoost" >> $DLL
chmod 644 /sys/module/msm_performance/parameters/touchboost
echo 0 > /sys/module/msm_performance/parameters/touchboost
fi
sleep 10
#I/0 Tweaks
if [ -d "/sys/block/sda/queue" ]; then
echo "*Applying I/O tweaks" >> $DLL
Q_PATH=/sys/block/sda/queue/
if grep 'cfq' $Q_PATH/scheduler; then
echo "cfq" > $Q_PATH/scheduler
sleep 1
echo 2048 > $Q_PATH/read_ahead_kb
echo 192 > $Q_PATH/nr_requests
# echo 1 > $Q_PATH/iosched/back_seek_penalty
# echo 16384 > $Q_PATH/iosched/back_seek_max
# echo 120 > $Q_PATH/iosched/fifo_expire_sync
# echo 250 > $Q_PATH/iosched/fifo_expire_async
# echo 0 > $Q_PATH/iosched/slice_idle
# echo 8 > $Q_PATH/iosched/group_idle
# echo 1 > $Q_PATH/iosched/low_latency
# echo 10 > $Q_PATH/iosched/quantum
# echo 40 > $Q_PATH/iosched/slice_async
# echo 2 > $Q_PATH/iosched/slice_async_rq
# echo 100 > $Q_PATH/iosched/slice_sync
# echo 300 > $Q_PATH/iosched/target_latency
echo " +Using cfq with tuned values" >> $DLL
else
echo " -Something went wrong while changing I/O Scheduler." >> $DLL
echo " -Error Code #03"
fi
echo 0 > $Q_PATH/add_random
echo 0 > $Q_PATH/iostats
echo 1 > $Q_PATH/nomerges
echo 0 > $Q_PATH/rotational
echo 1 > $Q_PATH/rq_affinity
fi
echo " *Finished tuning I/O scheduler" >> $DLL
#TCP tweaks
echo "*Tuning TCP" >> $DLL
if grep 'westwood' /proc/sys/net/ipv4/tcp_available_congestion_control; then
echo " +Applying westwood" >> $DLL
echo westwood > /proc/sys/net/ipv4/tcp_congestion_control
else
echo " +Applying cubic" >> $DLL
echo cubic > /proc/sys/net/ipv4/tcp_congestion_control
fi
echo 2 > /proc/sys/net/ipv4/tcp_ecn
echo 1 > /proc/sys/net/ipv4/tcp_dsack
echo 0 > /proc/sys/net/ipv4/tcp_low_latency
echo 1 > /proc/sys/net/ipv4/tcp_timestamps
echo 1 > /proc/sys/net/ipv4/tcp_sack
echo 1 > /proc/sys/net/ipv4/tcp_window_scaling
echo " *Finished tuning TCP" >> $DLL
#Wakelocks
echo "*Blocking wakelocks" >> $DLL
if [ -e "/sys/module/bcmdhd/parameters/wlrx_divide" ]; then
echo 10 > /sys/module/bcmdhd/parameters/wlrx_divide
fi
if [ -e "/sys/module/bcmdhd/parameters/wlctrl_divide" ]; then
echo 10 > /sys/module/bcmdhd/parameters/wlctrl_divide
fi
if [ -e "/sys/module/wakeup/parameters/enable_bluetooth_timer" ]; then
echo N > /sys/module/wakeup/parameters/enable_bluetooth_timer
fi
if [ -e "/sys/module/wakeup/parameters/enable_ipa_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_ipa_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_netlink_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_netlink_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_netmgr_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_netmgr_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_qcom_rx_wakelock_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_qcom_rx_wakelock_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_timerfd_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_timerfd_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_extscan_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_extscan_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_wow_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_wow_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_timerfd_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_timerfd_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_netmgr_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_netmgr_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_wow_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_wow_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_ipa_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_ipa_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_pno_wl_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wlan_pno_wl_ws
fi
if [ -e "/sys/module/wakeup/parameters/enable_wcnss_filter_lock_ws" ]; then
echo N > /sys/module/wakeup/parameters/enable_wcnss_filter_lock_ws
fi
# # #GPU
# echo "msm-adreno-tz" > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/governor
# GPU_FREQ=/sys/devices/soc/b00000.qcom,kgsl-3d0/devfreq/b00000.qcom,kgsl-3d0/max_freq
# av_freq=/sys/devices/soc/b00000.qcom,kgsl-3d0/devfreq/b00000.qcom,kgsl-3d0/available_frequencies
# if [ -e $GPU_FREQ ]; then
# echo "*Applying GPU tweaks" >> $DLL
# if grep '710000000' $av_freq; then
# chmod 644 /sys/class/kgsl/kgsl-3d0/max_gpuclk
# echo 710000000 > /sys/class/kgsl/kgsl-3d0/max_gpuclk
# echo 710000000 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/max_freq
# else
# echo "Patoka! - Banana?" >> $DLL
# fi
# if grep '180000000' $av_freq; then
# chmod 644 /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/target_freq
# echo 710000000 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/target_freq
# echo 180000000 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/min_freq
# else
# chmod 644 /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/target_freq
# echo 710000000 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/target_freq
# echo 257000000 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/min_freq
# fi
# if [ -e "/sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/adrenoboost" ]; then
# chmod 644 /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/adrenoboost
# echo 1 > /sys/devices/soc/5000000.qcom,kgsl-3d0/devfreq/5000000.qcom,kgsl-3d0/adrenoboost
# fi
# echo " +GPU tuned" >> $DLL
# fi
# echo " *GPU tweaks finished" >> $DLL
echo "*Applying minor tweaks" >> $DLL
## Vibration
chmod 644 /sys/class/timed_output/vibrator/vmax
echo 928 > /sys/class/timed_output/vibrator/vmax
chmod 644 /sys/class/timed_output/vibrator/vmax_mv_strong
echo 2691 > /sys/class/timed_output/vibrator/vmax_mv_strong
# # #File system
# echo " +File system tweaks" >> $DLL
# echo 60 > /proc/sys/fs/lease-break-time
#Virtual Memory
echo " +Virtual memory tweaks" >> $DLL
echo 300 > /proc/sys/vm/dirty_expire_centisecs
echo 500 > /proc/sys/vm/dirty_writeback_centisecs
echo 0 > /proc/sys/vm/oom_kill_allocating_task
echo 3 > /proc/sys/vm/page-cluster
echo 0 > /proc/sys/vm/swappiness
echo 100 > /proc/sys/vm/vfs_cache_pressure
echo 40 > /proc/sys/vm/dirty_ratio
echo 20 > /proc/sys/vm/dirty_background_ratio
echo 0 > /proc/sys/vm/overcommit_memory
echo 128 > /proc/sys/kernel/random/read_wakeup_threshold
echo 896 > /proc/sys/kernel/random/write_wakeup_threshold
#loop tweaks
echo " +loop tweaks" >> $DLL
for i in /sys/block/loop*; do
echo 0 > $i/queue/add_random
echo 0 > $i/queue/iostats
echo 1 > $i/queue/nomerges
echo 0 > $i/queue/rotational
echo 1 > $i/queue/rq_affinity
done
#ram tweaks
echo " +ram tweaks" >> $DLL
for j in /sys/block/ram*; do
echo 0 > $j/queue/add_random
echo 0 > $j/queue/iostats
echo 1 > $j/queue/nomerges
echo 0 > $j/queue/rotational
echo 1 > $j/queue/rq_affinity
done
# #Starting perfd
# if [ -e "/data/system/perfd" ]; then
# echo "*Starting perfd" >> $DLL
# start perfd
# fi
echo " *Minor tweaks applied" >> $DLL
echo "##### COMPLETED #####" >> $DLL
cdate=$(date)
echo "$cdate" >> $DLL
fstrim -v /data
fstrim -v /cache
fstrim -v /system
fstrim -v /preload