Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\mbcache.c Create Date:2022-07-28 20:29:33
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:mb_cache_create - create cache*@bucket_bits: log2 of the hash table size* Create cache for keys with 2^bucket_bits hash entries.

Proto:struct mb_cache *mb_cache_create(int bucket_bits)

Type:struct mb_cache

Parameter:

TypeParameterName
intbucket_bits
347  bucket_count = 1UL << bucket_bits
350  cache = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
351  If Not cache Then Go to err_out
353  log2 of hash table size = bucket_bits
354  Maximum entries in cache to avoid degrading hash too much = bucket_count << 4
355  Initialization list head
356  Process spin lock initialization( & Protects c_list, c_entry_count )
357  Hash table of entries = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
360  If Not Hash table of entries Then
361  kfree(cache)
362  Go to err_out
364  When i < bucket_count cycle INIT_HLIST_BL_HEAD( & Hash table of entries [i])
367  count_objects = mb_cache_count
368  scan_objects = mb_cache_scan
369  seeks to recreate an obj = A good number if you don't know better.
370  If register_shrinker( & c_shrink) Then
371  kfree(Hash table of entries )
372  kfree(cache)
373  Go to err_out
376  INIT_WORK( & Work for shrinking when the cache has too many entries , mb_cache_shrink_worker)
378  Return cache
380  err_out :
381  Return NULL