Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:test_rhltable

Proto:static int __init test_rhltable(unsigned int entries)

Type:int

Parameter:

TypeParameterName
unsigned intentries
276  If entries == 0 Then entries = 1
279  rhl_test_objects = vzalloc(array_size() - Calculate size of 2-dimensional array.*@a: dimension one*@b: dimension two* Calculates size of 2-dimensional array: @a *@b.* Returns: number of bytes needed to represent the array or SIZE_MAX on* overflow.)
281  If Not rhl_test_objects Then Return -ENOMEM
284  ret = -ENOMEM
285  obj_in_table = vzalloc(array_size() - Calculate size of 2-dimensional array.*@a: dimension one*@b: dimension two* Calculates size of 2-dimensional array: @a *@b.* Returns: number of bytes needed to represent the array or SIZE_MAX on* overflow.)
287  If Not obj_in_table Then Go to out_free
290  err = hltable_init - initialize a new hash list table*@hlt: hash list table to be initialized*@params: configuration parameters* Initializes a new hash list table.* See documentation for rhashtable_init.
291  If WARN_ON(err) Then Go to out_free
294  k = prandom_u32()
295  ret = 0
296  When i < entries cycle
297  id = k
298  err = hltable_insert - insert object into hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Will take the per bucket bitlock to protect against mutual mutations* on the same bucket
300  If WARN(err, "error %d on element %d\n", err, i) Then Break
302  If err == 0 Then set_bit - Atomically set a bit in memory*@nr: the bit to set*@addr: the address to start counting from* This is a relaxed atomic operation (no implied memory barriers).* Note that @nr may be almost arbitrarily large; this function is not
306  If err Then ret = err
309  pr_info("test %d add/delete pairs into rhlist\n", entries)
310  When i < entries cycle
313  struct test_obj_val key = {id = k, }
318  _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
319  h = hltable_lookup - search hash list table*@hlt: hash table*@key: the pointer to the key*@params: hash table parameters* Computes the hash value for the key and traverses the bucket chain looking* for a entry with an identical key
320  If WARN(!h, "key not found during iteration %d of %d", i, entries) Then
322  Break
325  If i Then
326  j = i - 1
328  If WARN(pos == & list_node, "old element found, should be gone") Then Break
333  cond_resched_rcu()
335  found = false
338  If pos == list_node Then
339  found = true
340  Break
344  _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()
346  If WARN(!found, "element %d not found", i) Then Break
349  err = hltable_remove - remove object from hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Since the hash chain is single linked, the removal operation needs to
350  WARN(err, "rhltable_remove: err %d for iteration %d\n", err, i)
351  If err == 0 Then lear_bit - Clears a bit in memory*@nr: Bit to clear*@addr: Address to start counting from* This is a relaxed atomic operation (no implied memory barriers).
355  If ret == 0 && err Then ret = err
358  When i < entries cycle
359  WARN(st_bit - Determine whether a bit is set*@nr: bit number to test*@addr: Address to start counting from, "elem %d allegedly still present", i)
361  err = hltable_insert - insert object into hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Will take the per bucket bitlock to protect against mutual mutations* on the same bucket
363  If WARN(err, "error %d on element %d\n", err, i) Then Break
365  If err == 0 Then set_bit - Atomically set a bit in memory*@nr: the bit to set*@addr: the address to start counting from* This is a relaxed atomic operation (no implied memory barriers).* Note that @nr may be almost arbitrarily large; this function is not
369  pr_info("test %d random rhlist add/delete operations\n", entries)
370  When j < entries cycle
371  i = prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)*@ep_ro: right open interval endpoint* Returns a pseudo-random number that is in interval [0, ep_ro). Note* that the result depends on PRNG being well distributed in [0, ~0U]
372  prand = prandom_u32()
374  cond_resched()
376  If prand == 0 Then prand = prandom_u32()
379  If prand & 1 Then
380  prand >>= 1
381  Continue
384  err = hltable_remove - remove object from hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Since the hash chain is single linked, the removal operation needs to
387  If WARN(err, "cannot remove element at slot %d", i) Then Continue
389  Else
390  If WARN(err != - ENOENT, "removed non-existent element %d, error %d not %d", i, err, - ENOENT) Then Continue
395  If prand & 1 Then
396  prand >>= 1
397  Continue
400  err = hltable_insert - insert object into hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Will take the per bucket bitlock to protect against mutual mutations* on the same bucket
401  If err == 0 Then
404  Else
409  If prand & 1 Then
410  prand >>= 1
411  Continue
414  i = prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)*@ep_ro: right open interval endpoint* Returns a pseudo-random number that is in interval [0, ep_ro). Note* that the result depends on PRNG being well distributed in [0, ~0U]
417  WARN(err, "cannot remove element at slot %d", i)
420  Else
422  WARN(err, "failed to insert object %d", i)
428  When i < entries cycle
429  cond_resched()
430  err = hltable_remove - remove object from hash list table*@hlt: hash list table*@list: pointer to hash list head inside object*@params: hash table parameters* Since the hash chain is single linked, the removal operation needs to
432  If WARN(err, "cannot remove element at slot %d", i) Then Continue
434  Else
435  If WARN(err != - ENOENT, "removed non-existent element, error %d not %d", err, - ENOENT) Then Continue
441  rhltable_destroy( & rhlt)
442  out_free :
443  vfree(rhl_test_objects)
444  vfree(obj_in_table)
445  Return ret
Caller
NameDescribe
test_rht_init