[PATCH 12/15] tick/sched: Consolidate idle time fetching APIs

Frederic Weisbecker frederic at kernel.org
Sat Feb 7 09:35:14 AEDT 2026


Le Fri, Feb 06, 2026 at 03:22:42PM +0100, Frederic Weisbecker a écrit :
> +static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx,
> +				 bool compute_delta, u64 *last_update_time)
> +{
> +	ktime_t now = ktime_get();
> +	u64 res;
> +
> +	if (vtime_generic_enabled_cpu(cpu))
> +		res = kcpustat_field(idx, cpu);
> +	else
> +		res = kcpustat_field_dyntick(cpu, idx, compute_delta, now);
> +
> +	do_div(res, NSEC_PER_USEC);
> +
> +	if (last_update_time)
> +		*last_update_time = res;

Urgh, this should be *last_update_time = ktime_to_us(now)

-- 
Frederic Weisbecker
SUSE Labs


More information about the Linuxppc-dev mailing list