Re: [PATCH 4.9 2/4] sched/cputime: Convert kcpustat to nsecs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 06, 2018 at 06:42:16PM -0700, Ivan Delalande wrote:
> From: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> 
> commit 7fb1327ee9b92fca27662f9b9d60c7c3376d6c69 upstream.
> 
> Kernel CPU stats are stored in cputime_t which is an architecture
> defined type, and hence a bit opaque and requiring accessors and mutators
> for any operation.
> 
> Converting them to nsecs simplifies the code and is one step toward
> the removal of cputime_t in the core code.
> 
> Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
> Cc: Paul Mackerras <paulus@xxxxxxxxx>
> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
> Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
> Cc: Tony Luck <tony.luck@xxxxxxxxx>
> Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxx>
> Cc: Stanislaw Gruszka <sgruszka@xxxxxxxxxx>
> Cc: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
> Link: http://lkml.kernel.org/r/1485832191-26889-4-git-send-email-fweisbec@xxxxxxxxx
> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
> [colona: minor conflict as 527b0a76f41d ("sched/cpuacct: Avoid %lld seq_printf
> warning") is missing from v4.9]
> Signed-off-by: Ivan Delalande <colona@xxxxxxxxxx>
> ---
>  arch/s390/appldata/appldata_os.c   | 16 +++----
>  drivers/cpufreq/cpufreq.c          |  6 +--
>  drivers/cpufreq/cpufreq_governor.c |  2 +-
>  drivers/cpufreq/cpufreq_stats.c    |  1 -
>  drivers/macintosh/rack-meter.c     |  2 +-
>  fs/proc/stat.c                     | 68 +++++++++++++++---------------
>  fs/proc/uptime.c                   |  7 +--
>  kernel/sched/cpuacct.c             |  2 +-
>  kernel/sched/cputime.c             | 22 +++++-----
>  9 files changed, 61 insertions(+), 65 deletions(-)
> 
> diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c
> index 69b23b25ac34..08b9e942a262 100644
> --- a/arch/s390/appldata/appldata_os.c
> +++ b/arch/s390/appldata/appldata_os.c
> @@ -113,21 +113,21 @@ static void appldata_get_os_data(void *data)
>  	j = 0;
>  	for_each_online_cpu(i) {
>  		os_data->os_cpu[j].per_cpu_user =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_USER]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_USER]);
>  		os_data->os_cpu[j].per_cpu_nice =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_NICE]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_NICE]);
>  		os_data->os_cpu[j].per_cpu_system =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]);
>  		os_data->os_cpu[j].per_cpu_idle =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IDLE]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IDLE]);
>  		os_data->os_cpu[j].per_cpu_irq =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IRQ]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IRQ]);
>  		os_data->os_cpu[j].per_cpu_softirq =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]);
>  		os_data->os_cpu[j].per_cpu_iowait =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IOWAIT]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_IOWAIT]);
>  		os_data->os_cpu[j].per_cpu_steal =
> -			cputime_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_STEAL]);
> +			nsecs_to_jiffies(kcpustat_cpu(i).cpustat[CPUTIME_STEAL]);
>  		os_data->os_cpu[j].cpu_id = i;
>  		j++;
>  	}
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index af5eff6835a8..d6d91e8afa9e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -132,7 +132,7 @@ static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
>  	u64 cur_wall_time;
>  	u64 busy_time;
>  
> -	cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
> +	cur_wall_time = jiffies64_to_nsecs(get_jiffies_64());
>  
>  	busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER];
>  	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM];
> @@ -143,9 +143,9 @@ static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
>  
>  	idle_time = cur_wall_time - busy_time;
>  	if (wall)
> -		*wall = cputime_to_usecs(cur_wall_time);
> +		*wall = div_u64(cur_wall_time, NSEC_PER_USEC);
>  
> -	return cputime_to_usecs(idle_time);
> +	return div_u64(idle_time, NSEC_PER_USEC);
>  }
>  
>  u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)
> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> index 642dd0f183a8..38d1a8216084 100644
> --- a/drivers/cpufreq/cpufreq_governor.c
> +++ b/drivers/cpufreq/cpufreq_governor.c
> @@ -152,7 +152,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
>  		if (ignore_nice) {
>  			u64 cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
>  
> -			idle_time += cputime_to_usecs(cur_nice - j_cdbs->prev_cpu_nice);
> +			idle_time += div_u64(cur_nice - j_cdbs->prev_cpu_nice, NSEC_PER_USEC);
>  			j_cdbs->prev_cpu_nice = cur_nice;
>  		}
>  
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index 06d3abdffd3a..b084708fd113 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -13,7 +13,6 @@
>  #include <linux/cpufreq.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
> -#include <linux/cputime.h>
>  
>  static DEFINE_SPINLOCK(cpufreq_stats_lock);
>  
> diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
> index 25852e399ab2..13b16f34256c 100644
> --- a/drivers/macintosh/rack-meter.c
> +++ b/drivers/macintosh/rack-meter.c
> @@ -91,7 +91,7 @@ static inline cputime64_t get_cpu_idle_time(unsigned int cpu)
>  	if (rackmeter_ignore_nice)
>  		retval += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
>  
> -	return retval;
> +	return nsecs_to_cputime64(retval);

Turns out this patch breaks the build here on powerpc :(

And I can't easily figure out how to fix it up.

So I'm going to drop this series from the 4.9 tree right now.  Can you
fix this up and resend?

thanks,

greg k-h



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux