mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
s390/idle: convert open coded idle time seqcount
s390 uses open coded seqcount to synchronize idle time accounting. Lets consolidate it with the standard API. Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
200e7c0ffb
commit
1ce2180498
@ -9,9 +9,10 @@
|
|||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/seqlock.h>
|
||||||
|
|
||||||
struct s390_idle_data {
|
struct s390_idle_data {
|
||||||
unsigned int sequence;
|
seqcount_t seqcount;
|
||||||
unsigned long long idle_count;
|
unsigned long long idle_count;
|
||||||
unsigned long long idle_time;
|
unsigned long long idle_time;
|
||||||
unsigned long long clock_idle_enter;
|
unsigned long long clock_idle_enter;
|
||||||
|
@ -38,15 +38,13 @@ void enabled_wait(void)
|
|||||||
trace_hardirqs_off();
|
trace_hardirqs_off();
|
||||||
|
|
||||||
/* Account time spent with enabled wait psw loaded as idle time. */
|
/* Account time spent with enabled wait psw loaded as idle time. */
|
||||||
idle->sequence++;
|
write_seqcount_begin(&idle->seqcount);
|
||||||
smp_wmb();
|
|
||||||
idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
|
idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
|
||||||
idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
|
idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
|
||||||
idle->idle_time += idle_time;
|
idle->idle_time += idle_time;
|
||||||
idle->idle_count++;
|
idle->idle_count++;
|
||||||
account_idle_time(idle_time);
|
account_idle_time(idle_time);
|
||||||
smp_wmb();
|
write_seqcount_end(&idle->seqcount);
|
||||||
idle->sequence++;
|
|
||||||
}
|
}
|
||||||
NOKPROBE_SYMBOL(enabled_wait);
|
NOKPROBE_SYMBOL(enabled_wait);
|
||||||
|
|
||||||
@ -55,14 +53,14 @@ static ssize_t show_idle_count(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
|
struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
|
||||||
unsigned long long idle_count;
|
unsigned long long idle_count;
|
||||||
unsigned int sequence;
|
unsigned int seq;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sequence = ACCESS_ONCE(idle->sequence);
|
seq = read_seqcount_begin(&idle->seqcount);
|
||||||
idle_count = ACCESS_ONCE(idle->idle_count);
|
idle_count = ACCESS_ONCE(idle->idle_count);
|
||||||
if (ACCESS_ONCE(idle->clock_idle_enter))
|
if (ACCESS_ONCE(idle->clock_idle_enter))
|
||||||
idle_count++;
|
idle_count++;
|
||||||
} while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
|
} while (read_seqcount_retry(&idle->seqcount, seq));
|
||||||
return sprintf(buf, "%llu\n", idle_count);
|
return sprintf(buf, "%llu\n", idle_count);
|
||||||
}
|
}
|
||||||
DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
|
DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
|
||||||
@ -72,15 +70,15 @@ static ssize_t show_idle_time(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
|
struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
|
||||||
unsigned long long now, idle_time, idle_enter, idle_exit;
|
unsigned long long now, idle_time, idle_enter, idle_exit;
|
||||||
unsigned int sequence;
|
unsigned int seq;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
now = get_tod_clock();
|
now = get_tod_clock();
|
||||||
sequence = ACCESS_ONCE(idle->sequence);
|
seq = read_seqcount_begin(&idle->seqcount);
|
||||||
idle_time = ACCESS_ONCE(idle->idle_time);
|
idle_time = ACCESS_ONCE(idle->idle_time);
|
||||||
idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
|
idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
|
||||||
idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
|
idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
|
||||||
} while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
|
} while (read_seqcount_retry(&idle->seqcount, seq));
|
||||||
idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
|
idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
|
||||||
return sprintf(buf, "%llu\n", idle_time >> 12);
|
return sprintf(buf, "%llu\n", idle_time >> 12);
|
||||||
}
|
}
|
||||||
@ -90,14 +88,14 @@ cputime64_t arch_cpu_idle_time(int cpu)
|
|||||||
{
|
{
|
||||||
struct s390_idle_data *idle = &per_cpu(s390_idle, cpu);
|
struct s390_idle_data *idle = &per_cpu(s390_idle, cpu);
|
||||||
unsigned long long now, idle_enter, idle_exit;
|
unsigned long long now, idle_enter, idle_exit;
|
||||||
unsigned int sequence;
|
unsigned int seq;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
now = get_tod_clock();
|
now = get_tod_clock();
|
||||||
sequence = ACCESS_ONCE(idle->sequence);
|
seq = read_seqcount_begin(&idle->seqcount);
|
||||||
idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
|
idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
|
||||||
idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
|
idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
|
||||||
} while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
|
} while (read_seqcount_retry(&idle->seqcount, seq));
|
||||||
return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
|
return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user