[Crash-utility] [PATCH] Fix for "timer -r -C" option to display all the per-CPU clocks

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Fri Jan 7 02:39:51 UTC 2022


Hi Lianbo,

Good catch.

-----Original Message-----
> Subject: [PATCH] Fix for "timer -r -C" option to display all the per-CPU clocks

Please remove "-C" here, it has no relation with the issue itself.

With this fix,
Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>

Thanks,
Kazu
> 
> Currently, the hrtimer_max_clock_bases is hard-coded to 3, which
> makes that crash only prints three clocks, and the rest of clocks
> are not displayed.

> 
> Without the patch:
> crash> timer -r -C 11
> CPU: 11  HRTIMER_CPU_BASE: ffff9a775f95ee00
>   CLOCK: 0  HRTIMER_CLOCK_BASE: ffff9a775f95ee80  [ktime_get]
>   (empty)
> 
>   CLOCK: 1  HRTIMER_CLOCK_BASE: ffff9a775f95ef00  [ktime_get_real]
>   (empty)
> 
>   CLOCK: 2  HRTIMER_CLOCK_BASE: ffff9a775f95ef80  [ktime_get_boottime]
>   (empty)
> 
> With the patch:
> crash> timer -r -C 11
> CPU: 11  HRTIMER_CPU_BASE: ffff9a775f95ee00
>   CLOCK: 0  HRTIMER_CLOCK_BASE: ffff9a775f95ee80  [ktime_get]
>   (empty)
> 
>   CLOCK: 1  HRTIMER_CLOCK_BASE: ffff9a775f95ef00  [ktime_get_real]
>   (empty)
> 
>   CLOCK: 2  HRTIMER_CLOCK_BASE: ffff9a775f95ef80  [ktime_get_boottime]
>   (empty)
> ...
>   CLOCK: 7  HRTIMER_CLOCK_BASE: ffff9a775f95f200  [ktime_get_clocktai]
>   (empty)
> 
> Signed-off-by: Lianbo Jiang <lijiang at redhat.com>
> ---
>  kernel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel.c b/kernel.c
> index 37b7af74ed2e..36c57ed501ad 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -7675,7 +7675,8 @@ dump_hrtimer_data(const ulong *cpus)
>  	if (VALID_STRUCT(hrtimer_clock_base)) {
>  		hrtimer_max_clock_bases = 2;
>  		if (symbol_exists("ktime_get_boottime"))
> -			hrtimer_max_clock_bases = 3;
> +			hrtimer_max_clock_bases = MEMBER_SIZE("hrtimer_cpu_base", "clock_base") /
> +							SIZE(hrtimer_clock_base);
>  	} else if (VALID_STRUCT(hrtimer_base)) {
>  		max_hrtimer_bases = 2;
>  	} else
> --
> 2.20.1





More information about the Crash-utility mailing list