Skip to content

Commit 5bef0a1

Browse files
jmberg-intelrichardweinberger
authored andcommitted
um: Implement cpu_relax() as ndelay(1) for time-travel
In time-travel mode, cpu_relax() currently does actual CPU relax, but that doesn't affect the simulation. Ideally, we wouldn't run anything that uses it in simulation, but if we actually have virtio devices combined with the same simulation it's possible. Implement cpu_relax() as ndelay(1) in this case, using time_travel_ndelay(1) directly to catch errors if this is used erroneously in builds that don't set CONFIG_UML_TIME_TRAVEL_SUPPORT. While at it, convert it to an __always_inline and also add that to rep_nop() like the original does now. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 0bc8fb4 commit 5bef0a1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/x86/um/asm/processor.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#ifndef __UM_PROCESSOR_H
33
#define __UM_PROCESSOR_H
4+
#include <linux/time-internal.h>
45

56
/* include faultinfo structure */
67
#include <sysdep/faultinfo.h>
@@ -21,12 +22,19 @@
2122
#include <asm/user.h>
2223

2324
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
24-
static inline void rep_nop(void)
25+
static __always_inline void rep_nop(void)
2526
{
2627
__asm__ __volatile__("rep;nop": : :"memory");
2728
}
2829

29-
#define cpu_relax() rep_nop()
30+
static __always_inline void cpu_relax(void)
31+
{
32+
if (time_travel_mode == TT_MODE_INFCPU ||
33+
time_travel_mode == TT_MODE_EXTERNAL)
34+
time_travel_ndelay(1);
35+
else
36+
rep_nop();
37+
}
3038

3139
#define task_pt_regs(t) (&(t)->thread.regs)
3240

0 commit comments

Comments
 (0)