aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/smp.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2008-12-31 09:11:40 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-12-31 09:11:47 -0500
commit6f43092441bda528dd38f2dc6c1e2522c5079fb7 (patch)
treee8bba1cf80b19be3e3658b9351b32469ba8c6bac /arch/s390/kernel/smp.c
parentaa5e97ce4bbc9d5daeec16b1d15bb3f6b7b4f4d4 (diff)
[PATCH] improve precision of idle time detection.
Increase the precision of the idle time calculation that is exported to user space via /sys/devices/system/cpu/cpu<x>/idle_time_us Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/smp.c')
-rw-r--r--arch/s390/kernel/smp.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 6fc78541dc57..3979a6fc0882 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -851,9 +851,11 @@ static ssize_t show_idle_count(struct sys_device *dev,
851 unsigned long long idle_count; 851 unsigned long long idle_count;
852 852
853 idle = &per_cpu(s390_idle, dev->id); 853 idle = &per_cpu(s390_idle, dev->id);
854 spin_lock_irq(&idle->lock); 854 spin_lock(&idle->lock);
855 idle_count = idle->idle_count; 855 idle_count = idle->idle_count;
856 spin_unlock_irq(&idle->lock); 856 if (idle->idle_enter)
857 idle_count++;
858 spin_unlock(&idle->lock);
857 return sprintf(buf, "%llu\n", idle_count); 859 return sprintf(buf, "%llu\n", idle_count);
858} 860}
859static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL); 861static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL);
@@ -862,18 +864,17 @@ static ssize_t show_idle_time(struct sys_device *dev,
862 struct sysdev_attribute *attr, char *buf) 864 struct sysdev_attribute *attr, char *buf)
863{ 865{
864 struct s390_idle_data *idle; 866 struct s390_idle_data *idle;
865 unsigned long long new_time; 867 unsigned long long now, idle_time, idle_enter;
866 868
867 idle = &per_cpu(s390_idle, dev->id); 869 idle = &per_cpu(s390_idle, dev->id);
868 spin_lock_irq(&idle->lock); 870 spin_lock(&idle->lock);
869 if (idle->in_idle) { 871 now = get_clock();
870 new_time = get_clock(); 872 idle_time = idle->idle_time;
871 idle->idle_time += new_time - idle->idle_enter; 873 idle_enter = idle->idle_enter;
872 idle->idle_enter = new_time; 874 if (idle_enter != 0ULL && idle_enter < now)
873 } 875 idle_time += now - idle_enter;
874 new_time = idle->idle_time; 876 spin_unlock(&idle->lock);
875 spin_unlock_irq(&idle->lock); 877 return sprintf(buf, "%llu\n", idle_time >> 12);
876 return sprintf(buf, "%llu\n", new_time >> 12);
877} 878}
878static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL); 879static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL);
879 880