rmnet_shs: Fix consistent divide-by-zero when updating stats

- In rmnet_shs_wq_refresh_dl_mrkr_stats(), `tdiff` is used as a divisor and is set to `rmnet_shs_wq_tnsec - tbl_p->l_epoch`.
- However, the function called before it, rmnet_shs_wq_refresh_total_stats(), resets `tbl_p->l_epoch` to`rmnet_shs_wq_tnsec`, resulting in `tdiff` always being zero inside rmnet_shs_wq_refresh_dl_mrkr_stats().
- This results in a 100% consistent divide-by-zero exception:

[32.709616] Unexpected kernel BRK exception at EL1
[32.709626] Internal error: ptrace BRK handler: f20003e8 [#1] PREEMPT SMP
[32.709639] Process kworker/3:1 (pid: 79, stack limit = 0x0000000068506c9d)
[32.709647] CPU: 3 PID: 79 Comm: kworker/3:1 Tainted: G S      W         4.19.202-NeutrinoKernel-lothal-EXP #1
[32.709651] Hardware name: Qualcomm Technologies, Inc. kona MTP 19805 20809 (DT)
[32.709664] Workqueue: rmnet_shs_wq rmnet_shs_wq_process_wq
[32.709670] pstate: 60c00085 (nZCv daIf +PAN +UAO)
[32.709676] pc : rmnet_shs_wq_update_stats+0x3c8/0x5c0
[32.709680] lr : rmnet_shs_wq_update_stats+0x230/0x5c0
[32.709684] sp : ffffff801054bce0
[32.709687] x29: ffffff801054bce0 x28: ffffffa9fe579cdd
[32.709692] x27: ffffffa9fe57ada0 x26: ffffffa9fe57b1e0
[32.709697] x25: 0000000000000008 x24: ffffffa9fdc15920
[32.709702] x23: ffffffa9fe57e6b0 x22: 0000000000000007
[32.709706] x21: 0000000000000000 x20: 0000000000000000
[32.709711] x19: ffffffa9fddd4840 x18: 0000000000000000
[32.709716] x17: 0000000000000000 x16: 0000000000000005
[32.709720] x15: 0000000000000000 x14: 0000000000000179
[32.709725] x13: 0000000000000000 x12: 0000000000000000
[32.709730] x11: 0000000000000000 x10: 0000000000000000
[32.709734] x9 : 0000000000000000 x8 : 0000000000000000
[32.709739] x7 : 0000000000000000 x6 : 0000000000000000
[32.709743] x5 : 0000000000000000 x4 : ffffffa9fe57b218
[32.709748] x3 : fffffff2f1d31000 x2 : 0000000000000000
[32.709752] x1 : 0000000000000000 x0 : 0000000000000007
[32.709758] Call trace:
[32.709764]  rmnet_shs_wq_update_stats+0x3c8/0x5c0
[32.709768]  rmnet_shs_wq_process_wq+0x54/0xd0
[32.709775]  process_one_work+0x22c/0x3c0
[32.709779]  worker_thread+0x188/0x5e0
[32.709784]  kthread+0x130/0x160
[32.709790]  ret_from_fork+0x10/0x1c
[32.709797] Code: f9449860 f9022f60 f9449c60 f9023360 (d4207d00)
[32.709802] ---[ end trace 1ae09793f9d923fb ]---

- Reordering the function calls fixes the issue.
- It looks like this issue was hidden by Clang's dead store elimination depending on whether or not tracepoints were enabled, since the quotients in question are only ever used as arguments to trace_rmnet_shs_wq_high().

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx>
Signed-off-by: Samuel Pascua <sgpascua@ngcp.ph>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Sultan Alsawaf 2021-08-19 13:58:02 -07:00 committed by azrim
parent 8de2111758
commit 413b1aa7e3
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C

View File

@ -2012,8 +2012,8 @@ void rmnet_shs_wq_update_stats(void)
}
}
rmnet_shs_wq_refresh_all_cpu_stats();
rmnet_shs_wq_refresh_total_stats();
rmnet_shs_wq_refresh_dl_mrkr_stats();
rmnet_shs_wq_refresh_total_stats();
if (rmnet_shs_userspace_connected) {
rm_err("%s", "SHS_UPDATE: Userspace connected, relying on userspace evaluation");