Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\test_meminit.c Create Date:2022-07-28 06:37:36
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Test kmem_cache with given parameters:

Proto:static int __init do_kmem_cache_size(size_t size, bool want_ctor, bool want_rcu, bool want_zero, int *total_failures)

Type:int

Parameter:

TypeParameterName
size_tsize
boolwant_ctor use a constructor;
boolwant_rcu use SLAB_TYPESAFE_BY_RCU;
boolwant_zero use __GFP_ZERO.
int *total_failures
201  bool fail = false
202  alloc_mask = GFP_KERNEL | If use __GFP_ZERO. Then __GFP_ZERO Else 0
205  c = kmem_cache_create("test_cache", size, 1, use SLAB_TYPESAFE_BY_RCU; ? Defer freeing slabs to RCU : 0, use a constructor; ? Initialize the first 4 bytes of the object. : NULL)
208  When iter < 10 cycle
214  If Not ret Then
215  fail = true
216  Else
224  buf = kmem_cache_alloc(c, alloc_mask)
226  fail |= Check the invariants for the buffer allocated from a slab cache.* If the cache has a test constructor, the first 4 bytes of the object must* always remain equal to CTOR_PATTERN.* If the cache isn't an RCU-typesafe one, or if the allocation is done with
227  Fill a buffer with garbage, skipping |skip| first bytes.
229  If Not use SLAB_TYPESAFE_BY_RCU; Then
231  Continue
238  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
243  buf_copy = kmalloc(size, DOC: Useful GFP flag combinations* Useful GFP flag combinations* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~* Useful GFP flag combinations that are commonly used. It is recommended* that subsystems start with one of these combinations and then set/clear)
244  If buf_copy Then No 3D Now!(buf_copy, buf, size)
247  kmem_cache_free(c, buf)
253  fail |= Check the invariants for the buffer allocated from a slab cache.* If the cache has a test constructor, the first 4 bytes of the object must* always remain equal to CTOR_PATTERN.* If the cache isn't an RCU-typesafe one, or if the allocation is done with
255  If buf_copy Then
256  fail |= memcmp(buf, buf_copy, size)
257  kfree(buf_copy)
259  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
261  kmem_cache_destroy(c)
263  total_failures += fail
264  Return 1
Caller
NameDescribe
test_kmemcacheTest kmem_cache allocation by creating caches of different sizes, with and* without constructors, with and without SLAB_TYPESAFE_BY_RCU.