您的位置:首页 > 移动开发

What happened in UBIFS during drop cache?

2016-08-24 16:35 701 查看
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 will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that 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 are not freeable, the
user should run `sync' first.

==============================================================

After echo N > /proc/sys/vm/drop_caches, kernel will call function drop_caches_sysctl_handler, this is the top interface to drop caches:

int drop_caches_sysctl_handler(ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
int ret;

ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
if (ret)
return ret;
if (write) {
if (sysctl_drop_caches & 1)
iterate_supers(drop_pagecache_sb, NULL);
if (sysctl_drop_caches & 2)
drop_slab();
}
return 0;
}


fs/drop_caches.c

drop_slab will call all the shrinkers to free memory, like ubifs_shrinker.

In ubifs_shinker, will free the znodes and tnc tree. Details please refer to ubifs_shrinker in fs/ubifs/shrinker.c.

Author: Marty

Date: 2016-8-24

The end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: