Registering and Removing Shrinkers

register_shrinker is used to register a new shrinker: mm/vmscan.c void register_shrinker(struct shrinker *shrinker)

The function expects a shrinker instance where seek and shrink are set appropriately. Besides, the function only ensures that shrinker is added to the global list shrinker_list.

At present, only a small number of shrinkers are present in the kernel. This includes the following:

□ shrink_icache_memory shrinks the inode cache discussed in Chapter 8 and also manages struct Inode objects.

□ shrink_dcache_memory is responsible for the dentry cache also discussed in Chapter 8.

□ mb_cache_shrink_fn shrinks a general cache for filesystem metadata (currently used to implement enhanced attributes in the Ext2 and Ext3 filesystems).

The remove_shrinker function removes shrinkers from the global list by reference to their shrinker instance:

mm/vmscan.c void remove_shrinker(struct shrinker *shrinker)

Continue reading here: Shrinking Caches

Was this article helpful?

0 0