~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/kernel/idle.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Idle functions for s390.
  4  *
  5  * Copyright IBM Corp. 2014
  6  *
  7  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  8  */
  9 
 10 #include <linux/kernel.h>
 11 #include <linux/kernel_stat.h>
 12 #include <linux/notifier.h>
 13 #include <linux/init.h>
 14 #include <linux/cpu.h>
 15 #include <trace/events/power.h>
 16 #include <asm/cpu_mf.h>
 17 #include <asm/cputime.h>
 18 #include <asm/nmi.h>
 19 #include <asm/smp.h>
 20 #include "entry.h"
 21 
 22 static DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
 23 
 24 void account_idle_time_irq(void)
 25 {
 26         struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
 27         struct lowcore *lc = get_lowcore();
 28         unsigned long idle_time;
 29         u64 cycles_new[8];
 30         int i;
 31 
 32         if (smp_cpu_mtid) {
 33                 stcctm(MT_DIAG, smp_cpu_mtid, cycles_new);
 34                 for (i = 0; i < smp_cpu_mtid; i++)
 35                         this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
 36         }
 37 
 38         idle_time = lc->int_clock - idle->clock_idle_enter;
 39 
 40         lc->steal_timer += idle->clock_idle_enter - lc->last_update_clock;
 41         lc->last_update_clock = lc->int_clock;
 42 
 43         lc->system_timer += lc->last_update_timer - idle->timer_idle_enter;
 44         lc->last_update_timer = lc->sys_enter_timer;
 45 
 46         /* Account time spent with enabled wait psw loaded as idle time. */
 47         WRITE_ONCE(idle->idle_time, READ_ONCE(idle->idle_time) + idle_time);
 48         WRITE_ONCE(idle->idle_count, READ_ONCE(idle->idle_count) + 1);
 49         account_idle_time(cputime_to_nsecs(idle_time));
 50 }
 51 
 52 void noinstr arch_cpu_idle(void)
 53 {
 54         struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
 55         unsigned long psw_mask;
 56 
 57         /* Wait for external, I/O or machine check interrupt. */
 58         psw_mask = PSW_KERNEL_BITS | PSW_MASK_WAIT |
 59                    PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
 60         clear_cpu_flag(CIF_NOHZ_DELAY);
 61         set_cpu_flag(CIF_ENABLED_WAIT);
 62         if (smp_cpu_mtid)
 63                 stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter);
 64         idle->clock_idle_enter = get_tod_clock_fast();
 65         idle->timer_idle_enter = get_cpu_timer();
 66         bpon();
 67         __load_psw_mask(psw_mask);
 68 }
 69 
 70 static ssize_t show_idle_count(struct device *dev,
 71                                struct device_attribute *attr, char *buf)
 72 {
 73         struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
 74 
 75         return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_count));
 76 }
 77 DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
 78 
 79 static ssize_t show_idle_time(struct device *dev,
 80                               struct device_attribute *attr, char *buf)
 81 {
 82         struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
 83 
 84         return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_time) >> 12);
 85 }
 86 DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
 87 
 88 void arch_cpu_idle_enter(void)
 89 {
 90 }
 91 
 92 void arch_cpu_idle_exit(void)
 93 {
 94 }
 95 
 96 void __noreturn arch_cpu_idle_dead(void)
 97 {
 98         cpu_die();
 99 }
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php