| Function report | 
| 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 activity | Download SCCT | Chinese | 
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 | 
| 861 | cur_ops = torture_ops[i] | 
| 862 | If strcmp(torture_type, name) == 0 Then Break | 
| 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") | 
| 873 | Go to unwind | 
| 876 | If nwriters_stress == 0 && nreaders_stress == 0 Then | 
| 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 | 
| 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 | 
| 931 | If nwriters_stress < 0 Then nrealwriters_stress = num_online_cpus() | 
| 936 | If nreaders_stress Then | 
| 937 | lock_is_read_held = 0 | 
| 938 | reader statistics = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc). | 
| 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) | 
| 965 | If shuffle_interval > 0 Then | 
| 970 | If shutdown_secs > 0 Then | 
| 976 | If stutter > 0 Then | 
| 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 | 
| 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 | 
| 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]) | 
| 1025 | create_reader : | 
| 1026 | If readlock == NULL || j >= nrealreaders_stress Then Continue | 
| 1034 | If stat_interval > 0 Then | 
| 1041 | Return 0 | 
| 1043 | unwind : | 
| 1045 | Forward reference. | 
| 1046 | Return firsterr | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |