Android device file system configuration without battery

Android device file system configuration without battery

Devices without batteries are recommended to operate as follows:

  • Modify the file system to ext4 and turn off disk encryption
  • Modify disk I/O configuration

Modify the file system to ext4 and turn off disk encryption

Reference document: Rockchip RK3588 Android SDK disables the disk encryption function of the data partition and modifies the file system of the data partition

Modify disk I/O configuration

File caching is an important performance improvement, and read caching is mostly beneficial in the vast majority of cases (programs can read data directly from RAM). The write cache is more complicated. The Linux kernel writes the disk to the cache, and then asynchronously flushes them to the disk after a while. This has a nice effect on speeding up disk I/O, but increases the chance of losing data when it is not written to disk.

  • vm.dirty_background_ratio is the percentage of memory that can be filled with dirty data. These dirty data will be written to the disk later, and the background processes such as pdflush/flush/kdmflush will clean up the dirty data later. For example, if I have 32G of memory, then 3.2G of dirty data can stay in the memory, and if it exceeds 3.2G, there will be a background process to clean it up.
  • vm.dirty_ratio is the absolute maximum amount of system memory that can be filled with dirty data. When the system reaches this point, all dirty data must be committed to disk, while all new I/O blocks are blocked until dirty data is written. disk. This is usually the cause of long I/O jank, but it is also a protection mechanism to ensure that excessive dirty data does not exist in memory.
  • vm.dirty_background_bytes and vm.dirty_bytes are another way to specify these parameters. If the _bytes version is set, the _ratio version will become 0 and vice versa.
  • vm.dirty_expire_centisecs specifies how long dirty data can survive. The default value is 3000, which is 30s. When pdflush/flush/kdmflush are running, they will check whether there is any data beyond this time limit, and if so, they will write it to disk asynchronously. After all, there is a risk of losing data if it stays in memory for too long.
  • vm.dirty_writeback_centisecs specifies how long pdflush/flush/kdmflush these processes will wake up once, and then check whether there is a cache that needs to be cleaned up. The default value is 500, and the unit is centisecs. In the actual kernel, *10 is used, that is, 5s.

For devices without batteries, in order to reduce the probability of data loss due to sudden power failure, it is recommended to increase the dirty data write-back frequency, which can be configured in the init.rc file:

wlq@sys2_206:~/4_Android12_29_sdk/device/rockchip/rk3588$ git diff init.rk3588.rc
diff --git a/init.rk3588.rc b/init.rk3588.rc
index dcac552..5da6a9e 100644
--- a/init.rk3588.rc
+++ b/init.rk3588.rc
@@ -66,6 +66,10 @@ on boot
     # The initial load of RT process, set the range of 0-1024, set the RT task above 300 will preferentially run on the cpuB(cpu4-cpu7)
     write /proc/sys/kernel/sched_util_clamp_min_rt_default 0

+    write /proc/sys/vm/dirty_ratio 10  //当脏数据达到内存的10%时强制回写到flash中,此时可能会导致IO负载高
+    write /proc/sys/vm/dirty_background_ratio 1 //当脏数据达到内存的1%时,开始后退回写脏数据
+    write /proc/sys/vm/dirty_writeback_centisecs 100  //1秒进行检查一次
+    write /proc/sys/vm/dirty_expire_centisecs 200   //脏数据能存活的时间2秒

Guess you like

Origin blog.csdn.net/weixin_43245753/article/details/127898965