lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200910121448.GA59606@localhost.localdomain>
Date:   Thu, 10 Sep 2020 15:14:48 +0300
From:   Alexey Dobriyan <adobriyan@...il.com>
To:     Tom Hromatka <tom.hromatka@...cle.com>
Cc:     linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        fweisbec@...il.com, tglx@...utronix.de, mingo@...nel.org
Subject: Re: [RESEND PATCH 2/2] /proc/stat: Simplify iowait and idle
 calculations when cpu is offline

On Wed, Sep 09, 2020 at 08:41:22AM -0600, Tom Hromatka wrote:
>  static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu)
>  {
> -	u64 idle, idle_usecs = -1ULL;
> +	u64 idle, idle_usecs;
>  
> -	if (cpu_online(cpu))
> -		idle_usecs = get_cpu_idle_time_us(cpu, NULL);
> -
> -	if (idle_usecs == -1ULL)
> -		/* !NO_HZ or cpu offline so we can rely on cpustat.idle */
> -		idle = kcs->cpustat[CPUTIME_IDLE];
> -	else
> -		idle = idle_usecs * NSEC_PER_USEC;
> +	idle_usecs = get_cpu_idle_time_us(cpu, NULL);
> +	idle = idle_usecs * NSEC_PER_USEC;
>  
>  	return idle;
>  }
>  
>  static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)
>  {
> -	u64 iowait, iowait_usecs = -1ULL;
> -
> -	if (cpu_online(cpu))
> -		iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
> +	u64 iowait, iowait_usecs;
>  
> -	if (iowait_usecs == -1ULL)
> -		/* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
> -		iowait = kcs->cpustat[CPUTIME_IOWAIT];
> -	else
> -		iowait = iowait_usecs * NSEC_PER_USEC;
> +	iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
> +	iowait = iowait_usecs * NSEC_PER_USEC;

You can gc variables in both cases:

	return get_cpu_iowait_time_us() * NSEC_PER_USEC;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ