Today I want to know what happend in UBIFS during drop cache.
Drop Cache is part of sysctl, you can get the details from Documentation/sysctl/vm.txt as below:
Drop_caches
Writing to this would cause the kernel to drop clean caches, dentries and
Inodes from memory, causing the memory to become free.
To free Pagecache:
Echo 1 >/proc/sys/vm/drop_caches
To free dentries and inodes:
Echo 2 >/proc/sys/vm/drop_caches
To free Pagecache, dentries and Inodes:
Echo 3 >/proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects was not freeable, the
User should run ' sync ' first.
==============================================================
After echo N >/proc/sys/vm/drop_caches, kernel would call function Drop_caches_sysctl_handler, this is the top INTERFAC E to drop caches:
1 intDrop_caches_sysctl_handler (Ctl_table *table,intWrite,2 void__user *buffer, size_t *length, loff_t *PPOs)3 {4 intret;5 6RET =Proc_dointvec_minmax (table, write, buffer, length, ppos);7 if(ret)8 returnret;9 if(write) { Ten if(Sysctl_drop_caches &1) One iterate_supers (DROP_PAGECACHE_SB, NULL); A if(Sysctl_drop_caches &2) - Drop_slab (); - } the return 0; -}
FS/DROP_CACHES.C
Drop_slab would call all of the shrinkers to free memory, like Ubifs_shrinker.
In Ubifs_shinker, would free the znodes and TNC tree. Details refer to Ubifs_shrinker in fs/ubifs/shrinker.c.
Author:marty
Date:2016-8-24
The end.
What happened in UBIFS during drop cache?