Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:test_rht_init

Proto:static int __init test_rht_init(void)

Type:int

Parameter:Nothing

699  started_threads = 0 , failed_threads = 0
700  total_time = 0
704  If parm_entries < 0 Then parm_entries = 1
707  entries = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(parm_entries, MAX_ENTRIES)
709  automatic_shrinking = shrinking
710  max_size = If max_size Else undup_pow_of_two - round the given value up to nearest power of two*@n: parameter* round the given value up to the nearest power of two* - the result is undefined when n == 0* - this can be used to initialise global variables from constant data(entries)
711  nelem_hint = size
713  objs = 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.)
715  If Not objs Then Return -ENOMEM
718  pr_info("Running rhashtable test nelem=%d, max_size=%d, shrinking=%d\n", size, max_size, shrinking)
721  When i < runs cycle
724  pr_info("Test %02d:\n", i)
725  memset(objs, 0, max_size * sizeof(structtest_obj))
727  err = hashtable_init - initialize a new hash table*@ht: hash table to be initialized*@params: configuration parameters* Initializes a new hash table based on the provided configuration* parameters
728  If err < 0 Then
729  pr_warn("Test failed: Unable to initialize hashtable: %d\n", err)
731  Continue
734  time = test_rhashtable( & ht, objs, entries)
735  rhashtable_destroy( & ht)
736  If time < 0 Then
737  vfree(objs)
738  pr_warn("Test failed: return code %lld\n", time)
739  Return -EINVAL
742  total_time += time
745  pr_info("test if its possible to exceed max_size %d: %s\n", max_size, test_rhashtable_max(objs, entries) == 0 ? "no, ok" : "YES, failed")
748  vfree(objs)
750  do_div() is NOT a C function(total_time, runs)
751  pr_info("Average test time: %llu\n", total_time)
753  test_insert_duplicates_run()
755  If Not tcount Then Return 0
758  pr_info("Testing concurrent rhashtable access from %d threads\n", tcount)
760  atomic_set( & startup_count, tcount)
761  tdata = 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.)
762  If Not tdata Then Return -ENOMEM
764  objs = vzalloc(array3_size() - Calculate size of 3-dimensional array.*@a: dimension one*@b: dimension two*@c: dimension three* Calculates size of 3-dimensional array: @a *@b *@c.* Returns: number of bytes needed to represent the array or SIZE_MAX on* overflow.)
765  If Not objs Then
766  vfree(tdata)
767  Return -ENOMEM
770  max_size = If max_size Else undup_pow_of_two - round the given value up to nearest power of two*@n: parameter* round the given value up to the nearest power of two* - the result is undefined when n == 0* - this can be used to initialise global variables from constant data(tcount * entries)
772  err = hashtable_init - initialize a new hash table*@ht: hash table to be initialized*@params: configuration parameters* Initializes a new hash table based on the provided configuration* parameters
773  If err < 0 Then
774  pr_warn("Test failed: Unable to initialize hashtable: %d\n", err)
776  vfree(tdata)
777  vfree(objs)
778  Return -EINVAL
780  When i < tcount cycle
781  id = i
782  entries = entries
783  objs = objs + i * entries
784  task = kthread_run - create and wake a thread.*@threadfn: the function to run until signal_pending(current).*@data: data ptr for @threadfn.*@namefmt: printf-style name for the thread.* Description: Convenient wrapper for kthread_create() followed by(threadfunc, & tdata[i], "rhashtable_thrad[%d]", i)
786  If IS_ERR(task) Then
787  pr_err(" kthread_run failed for thread %d\n", i)
789  Else
790  started_threads++
793  If wait_event_interruptible - sleep until a condition gets true*@wq_head: the waitqueue to wait on*@condition: a C expression for the event to wait for* The process is put to sleep (TASK_INTERRUPTIBLE) until the(startup_wait, atomic_read( & startup_count) == 0) Then pr_err(" wait_event interruptible failed\n")
796  atomic_dec( & startup_count)
797  wake_up_all( & startup_wait)
798  When i < tcount cycle
799  If IS_ERR(task) Then Continue
801  If err = stop a thread Then
802  pr_warn("Test failed: thread %d returned: %d\n", i, err)
804  failed_threads++
807  rhashtable_destroy( & ht)
808  vfree(tdata)
809  vfree(objs)
815  err = test_rhltable(entries / 16)
816  pr_info("Started %d threads, %d failed, rhltable test returns %d\n", started_threads, failed_threads, err)
818  Return 0