Skip to content

Commit

Permalink
cpu: Introduce smt_lowest()
Browse files Browse the repository at this point in the history
Recent CPUs have introduced a lower SMT priority. This uses the
Linux pattern of executing priority nops in descending order to
get a simple portable way to put the CPU into lowest SMT priority.

Introduce smt_lowest() and use it in place of smt_very_low and
smt_low ; smt_very_low sequences.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
npiggin authored and stewartsmith committed Jun 6, 2017
1 parent 41b14f9 commit 38b0c84
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions asm/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ secondary_wait:
*/
LOAD_IMM32(%r3, boot_flag - __head)
add %r3,%r3,%r30
1: smt_very_low
1: smt_lowest
lwz %r0,0(%r3)
cmpdi %r0,0
beq 1b
Expand All @@ -416,7 +416,7 @@ secondary_wait:
1:
/* Now wait for cpu_secondary_start to be set */
LOAD_ADDR_FROM_TOC(%r3, cpu_secondary_start)
1: smt_very_low
1: smt_lowest
ld %r0,0(%r3)
cmpdi %r0,0
beq 1b
Expand All @@ -441,7 +441,7 @@ secondary_wait:

/* Not found... what to do ? set some global error ? */
secondary_not_found:
smt_very_low
smt_lowest
b .

call_relocate:
Expand Down
2 changes: 1 addition & 1 deletion core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ void cpu_bringup(void)

/* Add a callin timeout ? If so, call cpu_remove_node(t). */
while (t->state != cpu_state_active) {
smt_very_low();
smt_lowest();
sync();
}
smt_medium();
Expand Down
6 changes: 3 additions & 3 deletions core/fast-reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ void __noreturn fast_reboot_entry(void)
if (this_cpu() != boot_cpu) {
this_cpu()->state = cpu_state_present;
while (!fast_boot_release) {
smt_very_low();
smt_lowest();
sync();
}
smt_medium();
Expand All @@ -511,7 +511,7 @@ void __noreturn fast_reboot_entry(void)

/* XXX Add a callin timeout ? */
while (cpu->state != cpu_state_present) {
smt_very_low();
smt_lowest();
sync();
}
smt_medium();
Expand All @@ -534,7 +534,7 @@ void __noreturn fast_reboot_entry(void)

/* XXX Add a callin timeout ? */
while (cpu->state == cpu_state_present) {
smt_very_low();
smt_lowest();
sync();
}
}
Expand Down
3 changes: 1 addition & 2 deletions include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ extern struct cpu_thread *boot_cpu;
static inline void __nomcount cpu_relax(void)
{
/* Relax a bit to give sibling threads some breathing space */
smt_low();
smt_very_low();
smt_lowest();
asm volatile("nop; nop; nop; nop;\n"
"nop; nop; nop; nop;\n"
"nop; nop; nop; nop;\n"
Expand Down
2 changes: 2 additions & 0 deletions include/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
#define smt_medium_low or 6,6,6
#define smt_extra_high or 7,7,7
#define smt_very_low or 31,31,31
#define smt_lowest smt_low ; smt_very_low

#else /* __ASSEMBLY__ */

Expand All @@ -214,6 +215,7 @@ static inline void smt_medium_high(void){ asm volatile("or 5,5,5"); }
static inline void smt_medium_low(void) { asm volatile("or 6,6,6"); }
static inline void smt_extra_high(void) { asm volatile("or 7,7,7"); }
static inline void smt_very_low(void) { asm volatile("or 31,31,31"); }
static inline void smt_lowest(void) { smt_low(); smt_very_low(); }

/*
* SPR access functions
Expand Down

0 comments on commit 38b0c84

Please sign in to comment.