Skip to content

Commit 43ca5c3

Browse files
committed
[S390] Convert monitor calls to function calls.
Remove the program check generating monitor calls and use function calls instead. Theres is no real advantage in using monitor calls, but they do make debugging harder, because of all the program checks it generates. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
1 parent e177685 commit 43ca5c3

6 files changed

Lines changed: 42 additions & 46 deletions

File tree

‎arch/s390/kernel/process.c‎

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
7676
* Need to know about CPUs going idle?
7777
*/
7878
static ATOMIC_NOTIFIER_HEAD(idle_chain);
79+
DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
7980

8081
int register_idle_notifier(struct notifier_block *nb)
8182
{
@@ -89,20 +90,40 @@ int unregister_idle_notifier(struct notifier_block *nb)
8990
}
9091
EXPORT_SYMBOL(unregister_idle_notifier);
9192

92-
void do_monitor_call(struct pt_regs *regs, long interruption_code)
93+
static int s390_idle_enter(void)
94+
{
95+
struct s390_idle_data *idle;
96+
int nr_calls = 0;
97+
void *hcpu;
98+
int rc;
99+
100+
hcpu = (void *)(long)smp_processor_id();
101+
rc = __atomic_notifier_call_chain(&idle_chain, S390_CPU_IDLE, hcpu, -1,
102+
&nr_calls);
103+
if (rc == NOTIFY_BAD) {
104+
nr_calls--;
105+
__atomic_notifier_call_chain(&idle_chain, S390_CPU_NOT_IDLE,
106+
hcpu, nr_calls, NULL);
107+
return rc;
108+
}
109+
idle = &__get_cpu_var(s390_idle);
110+
spin_lock(&idle->lock);
111+
idle->idle_count++;
112+
idle->in_idle = 1;
113+
idle->idle_enter = get_clock();
114+
spin_unlock(&idle->lock);
115+
return NOTIFY_OK;
116+
}
117+
118+
void s390_idle_leave(void)
93119
{
94-
#ifdef CONFIG_SMP
95120
struct s390_idle_data *idle;
96121

97122
idle = &__get_cpu_var(s390_idle);
98123
spin_lock(&idle->lock);
99124
idle->idle_time += get_clock() - idle->idle_enter;
100125
idle->in_idle = 0;
101126
spin_unlock(&idle->lock);
102-
#endif
103-
/* disable monitor call class 0 */
104-
__ctl_clear_bit(8, 15);
105-
106127
atomic_notifier_call_chain(&idle_chain, S390_CPU_NOT_IDLE,
107128
(void *)(long) smp_processor_id());
108129
}
@@ -113,61 +134,30 @@ extern void s390_handle_mcck(void);
113134
*/
114135
static void default_idle(void)
115136
{
116-
int cpu, rc;
117-
int nr_calls = 0;
118-
void *hcpu;
119-
#ifdef CONFIG_SMP
120-
struct s390_idle_data *idle;
121-
#endif
122-
123137
/* CPU is going idle. */
124-
cpu = smp_processor_id();
125-
hcpu = (void *)(long)cpu;
126138
local_irq_disable();
127139
if (need_resched()) {
128140
local_irq_enable();
129141
return;
130142
}
131-
132-
rc = __atomic_notifier_call_chain(&idle_chain, S390_CPU_IDLE, hcpu, -1,
133-
&nr_calls);
134-
if (rc == NOTIFY_BAD) {
135-
nr_calls--;
136-
__atomic_notifier_call_chain(&idle_chain, S390_CPU_NOT_IDLE,
137-
hcpu, nr_calls, NULL);
143+
if (s390_idle_enter() == NOTIFY_BAD) {
138144
local_irq_enable();
139145
return;
140146
}
141-
142-
/* enable monitor call class 0 */
143-
__ctl_set_bit(8, 15);
144-
145147
#ifdef CONFIG_HOTPLUG_CPU
146-
if (cpu_is_offline(cpu)) {
148+
if (cpu_is_offline(smp_processor_id())) {
147149
preempt_enable_no_resched();
148150
cpu_die();
149151
}
150152
#endif
151-
152153
local_mcck_disable();
153154
if (test_thread_flag(TIF_MCCK_PENDING)) {
154155
local_mcck_enable();
155-
/* disable monitor call class 0 */
156-
__ctl_clear_bit(8, 15);
157-
atomic_notifier_call_chain(&idle_chain, S390_CPU_NOT_IDLE,
158-
hcpu);
156+
s390_idle_leave();
159157
local_irq_enable();
160158
s390_handle_mcck();
161159
return;
162160
}
163-
#ifdef CONFIG_SMP
164-
idle = &__get_cpu_var(s390_idle);
165-
spin_lock(&idle->lock);
166-
idle->idle_count++;
167-
idle->in_idle = 1;
168-
idle->idle_enter = get_clock();
169-
spin_unlock(&idle->lock);
170-
#endif
171161
trace_hardirqs_on();
172162
/* Wait for external, I/O or machine check interrupt. */
173163
__load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT |

‎arch/s390/kernel/s390_ext.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/errno.h>
1414
#include <linux/kernel_stat.h>
1515
#include <linux/interrupt.h>
16-
16+
#include <asm/cpu.h>
1717
#include <asm/lowcore.h>
1818
#include <asm/s390_ext.h>
1919
#include <asm/irq_regs.h>
@@ -119,7 +119,7 @@ void do_extint(struct pt_regs *regs, unsigned short code)
119119

120120
old_regs = set_irq_regs(regs);
121121
irq_enter();
122-
asm volatile ("mc 0,0");
122+
s390_idle_check();
123123
if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
124124
/**
125125
* Make sure that the i/o interrupt did not "overtake"

‎arch/s390/kernel/smp.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static int smp_cpu_state[NR_CPUS];
7373
static int cpu_management;
7474

7575
static DEFINE_PER_CPU(struct cpu, cpu_devices);
76-
DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
7776

7877
static void smp_ext_bitcall(int, ec_bit_sig);
7978

‎arch/s390/kernel/traps.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ int sysctl_userprocess_debug = 0;
5959

6060
extern pgm_check_handler_t do_protection_exception;
6161
extern pgm_check_handler_t do_dat_exception;
62-
extern pgm_check_handler_t do_monitor_call;
6362
extern pgm_check_handler_t do_asce_exception;
6463

6564
#define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; })
@@ -739,6 +738,5 @@ void __init trap_init(void)
739738
pgm_check_table[0x15] = &operand_exception;
740739
pgm_check_table[0x1C] = &space_switch_exception;
741740
pgm_check_table[0x1D] = &hfp_sqrt_exception;
742-
pgm_check_table[0x40] = &do_monitor_call;
743741
pfault_irq_init();
744742
}

‎drivers/s390/cio/cio.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/ipl.h>
2525
#include <asm/chpid.h>
2626
#include <asm/airq.h>
27+
#include <asm/cpu.h>
2728
#include "cio.h"
2829
#include "css.h"
2930
#include "chsc.h"
@@ -649,7 +650,7 @@ do_IRQ (struct pt_regs *regs)
649650

650651
old_regs = set_irq_regs(regs);
651652
irq_enter();
652-
asm volatile ("mc 0,0");
653+
s390_idle_check();
653654
if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
654655
/**
655656
* Make sure that the i/o interrupt did not "overtake"

‎include/asm-s390/cpu.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ struct s390_idle_data {
2222

2323
DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
2424

25+
void s390_idle_leave(void);
26+
27+
static inline void s390_idle_check(void)
28+
{
29+
if ((&__get_cpu_var(s390_idle))->in_idle)
30+
s390_idle_leave();
31+
}
32+
2533
#endif /* _ASM_S390_CPU_H_ */

0 commit comments

Comments
 (0)