From 3d5ca29dd634b4628d7dc82423b2680718e6eb2a Mon Sep 17 00:00:00 2001 From: Xu Yu Date: Wed, 18 Mar 2020 17:39:35 +0800 Subject: [PATCH] alinux: mm, memcg: optimize division operation with memsli counters to #26424368 Specifically, replace `val / 1000000` with `val >> 20` to do the optimization. This also fixes the possible compiling error when building with ARCH=i386, which reports undefined reference to `__udivdi3`. Signed-off-by: Xu Yu Reviewed-by: Yang Shi --- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c5e4f15d6ea3..4817580f53e3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4599,7 +4599,7 @@ static int memcg_lat_stat_show(struct seq_file *m, void *v) seq_printf(m, ">=1000ms: \t%llu\n", memcg_lat_stat_gather(memcg, idx, MEM_LAT_1000_INF)); seq_printf(m, "total(ms): \t%llu\n", - memcg_lat_stat_gather(memcg, idx, MEM_LAT_TOTAL) / 1000000); + memcg_lat_stat_gather(memcg, idx, MEM_LAT_TOTAL) >> 20); return 0; } @@ -4608,7 +4608,7 @@ static enum mem_lat_count_t get_mem_lat_count_idx(u64 duration) { enum mem_lat_count_t idx; - duration = duration / 1000000; + duration = duration >> 20; if (duration < 1) idx = MEM_LAT_0_1; else if (duration < 5) -- GitLab