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 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
autogroup.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
completion.c sched/completion: Expose wait_for_common*() to drivers 2024-11-17 17:45:08 +01:00
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 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpudeadline.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpudeadline.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpufreq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
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 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpupri.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cputime.c sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime 2024-11-23 23:20:24 +01:00
deadline.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fair.c sched/fair: Use all little CPUs for CPU-bound workloads 2024-11-23 23:20:13 +01:00
features.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
idle.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
isolation.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
loadavg.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
membarrier.c sched/membarrier: reduce the ability to hammer on sys_membarrier 2024-11-18 12:13:39 +01:00
pelt.c kernel: sched: Provide more PELT half-life options 2024-11-17 17:41:17 +01:00
pelt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
psi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rt.c sched/rt: Disallow writing invalid values to sched_rt_period_us 2024-11-18 22:25:32 +01:00
sched-pelt.h kernel: sched: Provide more PELT half-life options 2024-11-17 17:41:17 +01:00
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 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sec_mpam_cpbm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sec_mpam_sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sec_mpam_sysfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stats.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stats.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stop_task.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
swait.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
topology.c sched/fair: Allow disabling sched_balance_newidle with sched_relax_domain_level 2024-11-19 12:27:00 +01:00
wait.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wait_bit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00