kernel_samsung_a53x/kernel/sched
Zheng Zucheng 185d961782 sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime
commit 77baa5bafcbe1b2a15ef9c37232c21279c95481c upstream.

In extreme test scenarios:
the 14th field utime in /proc/xx/stat is greater than sum_exec_runtime,
utime = 18446744073709518790 ns, rtime = 135989749728000 ns

In cputime_adjust() process, stime is greater than rtime due to
mul_u64_u64_div_u64() precision problem.
before call mul_u64_u64_div_u64(),
stime = 175136586720000, rtime = 135989749728000, utime = 1416780000.
after call mul_u64_u64_div_u64(),
stime = 135989949653530

unsigned reversion occurs because rtime is less than stime.
utime = rtime - stime = 135989749728000 - 135989949653530
		      = -199925530
		      = (u64)18446744073709518790

Trigger condition:
  1). User task run in kernel mode most of time
  2). ARM64 architecture
  3). TICK_CPU_ACCOUNTING=y
      CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not set

Fix mul_u64_u64_div_u64() conversion precision by reset stime to rtime

Fixes: 3dc167ba5729 ("sched/cputime: Improve cputime_adjust()")
Signed-off-by: Zheng Zucheng <zhengzucheng@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20240726023235.217771-1-zhengzucheng@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-23 23:20:24 +01:00
..
ems kernel: sched: ems: drop usage of SCHED_FEAT 2024-11-19 17:52:14 +01:00
autogroup.c
autogroup.h
clock.c
completion.c
core.c sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks 2024-11-23 23:20:12 +01:00
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq.c
cpufreq_schedutil.c schedutil: Allow CPU frequency changes to be amended before they're set 2024-11-19 18:06:02 +01:00
cpupri.c
cpupri.h
cputime.c sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime 2024-11-23 23:20:24 +01:00
deadline.c
debug.c
fair.c sched/fair: Use all little CPUs for CPU-bound workloads 2024-11-23 23:20:13 +01:00
features.h
idle.c
isolation.c
loadavg.c
Makefile
membarrier.c
pelt.c
pelt.h
psi.c
rt.c sched/rt: Disallow writing invalid values to sched_rt_period_us 2024-11-18 22:25:32 +01:00
sched-pelt.h
sched.h sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks 2024-11-23 23:20:12 +01:00
sec_mpam.c
sec_mpam_cpbm.h
sec_mpam_sysfs.c
sec_mpam_sysfs.h
smp.h
stats.c
stats.h
stop_task.c
swait.c
topology.c sched/fair: Allow disabling sched_balance_newidle with sched_relax_domain_level 2024-11-19 12:27:00 +01:00
wait.c
wait_bit.c