Case Analysis of SWT Restart

Posted by tpearce2 on Tue, 03 Sep 2019 12:32:19 +0200

Strongly Recommend Articles: Welcome to Collection
Android Dry Goods Sharing

Read for five minutes, ten o'clock a day, and study with you for life. Here's Android, a programmer.

This article mainly introduces some knowledge points in Android development. By reading this article, you will gain the following contents:

1. Copy large files, IO wait high, leading to SWT restart
II. Solutions to Restart Caused by High IO wait

1. Copy large files, IO wait high, leading to SWT restart

1. Logs captured by AEE

Some logs are as follows:

2. High IO leads to high CPU utilization

Some logs are as follows:

II. Solutions to Restart Caused by High IO Wait

##### 1. Tuning the Kernel and Optimizing IO

By adjusting the parameters of the kernel, the peak of write activity is distributed into frequent multiple writes, with less data written each time. This method is inefficient, but it reduces the chance of combining write operations and the probability of restart.

Modify init.rc file
The file path is as follows:
system/core/rootdir/init.rc

     # Tweak background writeout
     write /proc/sys/vm/dirty_expire_centisecs 200
-    write /proc/sys/vm/dirty_background_ratio  3
-    write /proc/sys/vm/dirty_ratio 10
+    write /proc/sys/vm/dirty_background_ratio  1
+    write /proc/sys/vm/dirty_ratio 2
        
     # Permissions for System Server and daemons.
     chown radio system /sys/android_power/state
2. Turn off ANR dump information

Modify the init.aee.customer.rc file
The modification code is as follows:
/vendor/mediatek/proprietary/external/aee/config_external/init.aee.customer.rc

 on init
     export LD_PRELOAD libdirect-coredump.so
     write /proc/self/coredump_filter 39
+       setprop persist.dbg.anrflow 1
 
 on property:vold.decrypt=trigger_restart_framework
     restart debuggerd
3. Close the log information of the WTF dump file

When a large file is copied into a mobile phone (more than 5G), IO wait of the mobile phone will be very high. At this time, information such as Dump ANR wtf will seriously affect IO wait. If the system does not respond for more than one minute, the watchdog will automatically restart the mobile phone. Therefore, in the case of high IO wait, it is suggested that dump information can be turned off to ease CPU load. Excessive problem.

Annotate Log Printing in AMS
The Activity Manager Service code path is as follows:
/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService

 public final class ActivityManagerService extends ActivityManagerNative

                 // should be protected to avoid security holes, so yell loudly

                 // to ensure we examine these cases.

                 if (callerApp != null) {

-                    Log.wtf(TAG, "Sending non-protected broadcast " + action

-                            + " from system " + callerApp.toShortString() + " pkg " + callerPackage,

-                            new Throwable());

+                                       // add for copy 5G file reboot 

+                                       android.util.Log.e("wangjie","Sending non-protected broadcast cause reboot pkg "+callerPackage);                

+                    //Log.wtf(TAG, "Sending non-protected broadcast " + action

+                     //       + " from system " + callerApp.toShortString() + " pkg " + callerPackage,

+                      //      new Throwable());

+                                       // add for copy 5G file reboot          

                 } else {

-                    Log.wtf(TAG, "Sending non-protected broadcast " + action

-                            + " from system uid " + UserHandle.formatUid(callingUid)

-                            + " pkg " + callerPackage,

-                            new Throwable());

-                }

+                                       // add for copy 5G file reboot 

+                                       android.util.Log.e("wangjie","Sending non-protected broadcast cause reboot pkg "+callerPackage);        

+                    //  Log.wtf(TAG, "Sending non-protected broadcast " + action

+                    //        + " from system uid " + UserHandle.formatUid(callingUid)

+                   //         + " pkg " + callerPackage,

+                   //         new Throwable());

+                                  // add for copy 5G file reboot 

+                }

+                               

+                               // add for copy 5G file reboot 

             }

         } else {

So far, this article is over. If there are any mistakes, you are welcome to make suggestions and corrections. At the same time look forward to your attention, thank you for reading, thank you!

Topics: Android Mobile less Java