Commit 2d02cc1
anolis: sched: fix race condition when adjust guest cputime
ANBZ: torvalds#394
Cpuacct.proc_stat_show callback will read cpuacct's per-cpu kcpustat
by `per_cpu_ptr`. the `kcpustats` is not protected by any lock. When
adjust guest cputime, it will subtract tick_user by tick_guest.
In a extreme case, the tick_user version is older than tick_guest,
if the tick_guest value close the tick_user, the result will be
negative.
cpu0 | cpu1
__cpuacct_get_usage_result: |
per_cpu_ptr(ca->cpustat, 1); |
read tick_user |
| update tick_user and tick_guest
read tick_guest |
tick_user - tick_guest |
Fixes: a1bc632 (anolis: cpuacct: fix guest cgroup usage more than user usage)
Signed-off-by: Zeng Jiahao <zengjiahao@linux.alibaba.com>
Reviewed-by: Shanpei Chen <shanpeic@linux.alibaba.com>1 parent b348c22 commit 2d02cc1
1 file changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
984 | | - | |
985 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
986 | 991 | | |
987 | 992 | | |
988 | 993 | | |
| |||
0 commit comments