Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\locktorture.c Create Date:2022-07-28 09:54:43
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:lock_torture_init

Proto:static int __init lock_torture_init(void)

Type:int

Parameter:Nothing

842  firsterr = 0
843  static struct lock_torture_ops * torture_ops[] = { & lock_busted_ops, & spin_lock_ops, & spin_lock_irq_ops, & rw_lock_ops, & rw_lock_irq_ops, & mutex_lock_ops, & ww_mutex_lock_ops, & rwsem_lock_ops, & percpu_rwsem_lock_ops, }
856  If Not Initialize torture module Then Return -EBUSY
860  When i < ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(torture_ops) cycle
861  cur_ops = torture_ops[i]
862  If strcmp(torture_type, name) == 0 Then Break
865  If i == ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(torture_ops) Then
866  pr_alert("lock-torture: invalid torture type: \"%s\"\n", torture_type)
868  pr_alert("lock-torture types:")
869  When i < ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(torture_ops) cycle pr_alert(" %s", name)
871  pr_alert("\n")
872  firsterr = -EINVAL
873  Go to unwind
876  If nwriters_stress == 0 && nreaders_stress == 0 Then
877  pr_alert("lock-torture: must run at least one locking thread\n")
878  firsterr = -EINVAL
879  Go to unwind
882  If init Then init()
885  If nwriters_stress >= 0 Then nrealwriters_stress = nwriters_stress
887  Else nrealwriters_stress = 2 * num_online_cpus()
905  If nwriters_stress Then
906  lock_is_write_held = 0
907  writer statistics = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
910  If ( writer statistics == NULL) Then
911  VERBOSE_TOROUT_STRING("cxt.lwsa: Out of memory")
912  firsterr = -ENOMEM
913  Go to unwind
916  When i < nrealwriters_stress cycle
917  n_lock_fail = 0
918  n_lock_acquired = 0
922  If readlock Then
923  If nreaders_stress >= 0 Then nrealreaders_stress = nreaders_stress
925  Else
936  If nreaders_stress Then
937  lock_is_read_held = 0
941  If ( reader statistics == NULL) Then
949  When i < nrealreaders_stress cycle
950  n_lock_fail = 0
951  n_lock_acquired = 0
956  lock_torture_print_module_parms(cur_ops, "Start of test")
959  If onoff_interval > 0 Then
960  firsterr = torture_onoff_init(onoff_holdoff * HZ, onoff_interval * HZ, NULL)
962  If firsterr Then Go to unwind
965  If shuffle_interval > 0 Then
966  firsterr = torture_shuffle_init(shuffle_interval)
967  If firsterr Then Go to unwind
970  If shutdown_secs > 0 Then
971  firsterr = torture_shutdown_init(shutdown_secs, Forward reference. )
973  If firsterr Then Go to unwind
976  If stutter > 0 Then
977  firsterr = torture_stutter_init(stutter, stutter)
978  If firsterr Then Go to unwind
982  If nwriters_stress Then
983  writer_tasks = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
986  If (writer_tasks == NULL) Then
987  VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory")
988  firsterr = -ENOMEM
989  Go to unwind
993  If readlock Then
994  reader_tasks = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
997  If (reader_tasks == NULL) Then
998  VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory")
1000  writer_tasks = NULL
1001  firsterr = -ENOMEM
1002  Go to unwind
1014  When i < nrealwriters_stress || j < nrealreaders_stress cycle
1016  If i >= nrealwriters_stress Then Go to create_reader
1020  firsterr = torture_create_kthread(Lock torture writer kthread. Repeatedly acquires and releases* the lock, checking for duplicate acquisitions., & writer statistics [i], writer_tasks[i])
1022  If firsterr Then Go to unwind
1025  create_reader :
1026  If readlock == NULL || j >= nrealreaders_stress Then Continue
1029  firsterr = torture_create_kthread(Lock torture reader kthread. Repeatedly acquires and releases* the reader lock., & reader statistics [j], reader_tasks[j])
1031  If firsterr Then Go to unwind
1034  If stat_interval > 0 Then
1035  firsterr = torture_create_kthread(Periodically prints torture statistics, if periodic statistics printing* was specified via the stat_interval module parameter.* No need to worry about fullstop here, since this one doesn't reference* volatile state or register callbacks., NULL, stats_task)
1037  If firsterr Then Go to unwind
1040  Tell the torture module that initialization is complete.
1041  Return 0
1043  unwind :
1044  Tell the torture module that initialization is complete.
1045  Forward reference.
1046  Return firsterr