Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\rcu\rcutorture.c Create Date:2022-07-28 10:21:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:RCU torture writer kthread. Repeatedly substitutes a new structure* for that pointed to by rcu_torture_current, freeing the old structure* after a series of grace periods (the "pipeline").

Proto:static int rcu_torture_writer(void *arg)

Type:int

Parameter:

TypeParameterName
void *arg
941  can_expedite = Not Should normal grace-period primitives be expedited? Intended for* use within RCU. Note that this function takes the rcu_expedited* sysfs/boot variable and rcu_scheduler_active into account as well* as the rcu_expedite_gp() nesting && Not Should expedited grace-period primitives always fall back to their* non-expedited counterparts? Intended for use within RCU. Note* that if the user specifies both rcu_expedited and rcu_normal, then* rcu_normal wins
942  expediting = 0
944  gp_cond1 = gp_cond , gp_exp1 = gp_exp , gp_normal1 = gp_normal
945  gp_sync1 = gp_sync
949  static
950  int synctype[] = {RTWS_DEF_FREE, RTWS_EXP_SYNC, RTWS_COND_GET, RTWS_SYNC}
952  nsynctypes = 0
954  VERBOSE_TOROUT_STRING("rcu_torture_writer task started")
955  If Not can_expedite Then pr_alert("%s"TORTURE_FLAG" GP expediting controlled from boot/sysfs for %s.\n", torture_type, name)
961  If Not gp_cond1 && Not gp_exp1 && Not gp_normal1 && Not gp_sync1 Then gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true
963  If gp_cond1 && get_state && cond_sync Then
964  synctype[nsynctypes++] = RTWS_COND_GET
965  pr_info("%s: Testing conditional GPs.\n", __func__)
966  Else if gp_cond && ( Not get_state || Not cond_sync ) Then
967  pr_alert("%s: gp_cond without primitives.\n", __func__)
969  If gp_exp1 && exp_sync Then
970  synctype[nsynctypes++] = RTWS_EXP_SYNC
971  pr_info("%s: Testing expedited GPs.\n", __func__)
972  Else if gp_exp && Not exp_sync Then
973  pr_alert("%s: gp_exp without primitives.\n", __func__)
975  If gp_normal1 && deferred_free Then
976  synctype[nsynctypes++] = RTWS_DEF_FREE
977  pr_info("%s: Testing asynchronous GPs.\n", __func__)
978  Else if gp_normal && Not deferred_free Then
979  pr_alert("%s: gp_normal without primitives.\n", __func__)
981  If gp_sync1 && sync Then
982  synctype[nsynctypes++] = RTWS_SYNC
983  pr_info("%s: Testing normal GPs.\n", __func__)
984  Else if gp_sync && Not sync Then
985  pr_alert("%s: gp_sync without primitives.\n", __func__)
987  If WARN_ONCE(nsynctypes == 0, "rcu_torture_writer: No update-side primitives.\n") Then
994  rcu_torture_writer_state = RTWS_STOPPING
995  Each kthread must wait for kthread_should_stop() before returning from* its top-level function, otherwise segfaults ensue
998  Do
999  rcu_torture_writer_state = RTWS_FIXED_DELAY
1000  schedule_timeout_uninterruptible(1)
1001  rp = Allocate an element from the rcu_tortures pool.
1002  If (rp == NULL) Then Continue
1004  rtort_pipe_count = 0
1005  rcu_torture_writer_state = RTWS_DELAY
1006  0x10c7 is 2**32 / 1000000 (rounded up) (torture_random( & rand) & 0x3ff)
1007  rcu_torture_writer_state = RTWS_REPLACE
1008  old_rp = cu_dereference_check() - rcu_dereference with debug checking*@p: The pointer to read, prior to dereferencing*@c: The conditions under which the dereference will take place* Do an rcu_dereference(), but check that the conditions under which the(rcu_torture_current, current process == writer_task)
1010  rtort_mbtest = 1
1011  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(rcu_torture_current, rp)
1012  smp_wmb()
1013  If old_rp Then
1014  i = rtort_pipe_count
1018  rtort_pipe_count++
1045  Default
1046  WARN_ON_ONCE(1)
1047  Break
1050  WRITE_ONCE(rcu_torture_current_version, rcu_torture_current_version + 1)
1053  If can_expedite && Not ( torture_random( & rand) & 0xff & Not Not expediting - 1 ) Then
1060  If ++expediting > 3 Then expediting = -expediting
1062  Else if Not can_expedite Then
1066  rcu_torture_writer_state = RTWS_STUTTER
1067  If Task stuttering, which forces load/no-load transitions. && Not READ_ONCE(Short rcu_torture_delay() delays. ) && Not slow_gps && Not Is it time for the current torture test to stop? Then When i < ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(rcu_tortures) cycle
1076  WARN(1, "%s: rtort_pipe_count: %d\n", __func__, rtort_pipe_count)
1078  When Not Is it time for the current torture test to stop? cycle
1080  If expediting > 0 Then expediting = -expediting
1082  When can_expedite && expediting++ < 0 cycle
1083  _unexpedite_gp - Cancel prior rcu_expedite_gp() invocation* Undo a prior call to rcu_expedite_gp()
1084  WARN_ON_ONCE(can_expedite && Should normal grace-period primitives be expedited? Intended for* use within RCU. Note that this function takes the rcu_expedited* sysfs/boot variable and rcu_scheduler_active into account as well* as the rcu_expedite_gp() nesting)
1085  If Not can_expedite Then pr_alert("%s"TORTURE_FLAG" Dynamic grace-period expediting was disabled.\n", torture_type)
1089  rcu_torture_writer_state = RTWS_STOPPING
1090  Each kthread must wait for kthread_should_stop() before returning from* its top-level function, otherwise segfaults ensue
1091  Return 0