Skip to contentSkip to conversation

x86: eventinj: Do a real io_delay()

PATCH In review [email protected] 2 participants 3 messages May 3, 2019 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: eventinj: Do a real io_delay()

From: Nadav Amit <[email protected]>

There is no guarantee that a self-IPI would be delivered immediately. io_delay() is called after self-IPI is generated but does nothing. Instead, change io_delay() to wait for 10000 cycles, which should be enough on any system whatsoever.

---
 x86/eventinj.c | 5 +++++
 1 file changed, 5 insertions(+)
x86/eventinj.c +5 -0
index 8064eb9..250537b 100644
@@ -18,6 +18,11 @@ void do_pf_tss(void);
 
 static inline void io_delay(void)
 {
+	u64 start = rdtsc();
+
+	do {
+		pause();
+	} while (rdtsc() - start < 10000);
 }
 
 static void apic_self_ipi(u8 v)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · On 5/2/19 11:49 AM, [email protected] wrote:

From: Nadav Amit <[email protected]>

There is no guarantee that a self-IPI would be delivered immediately. io_delay() is called after self-IPI is generated but does nothing. Instead, change io_delay() to wait for 10000 cycles, which should be enough on any system whatsoever.

---
  x86/eventinj.c | 5 +++++
  1 file changed, 5 insertions(+)
x86/eventinj.c +0 -0
index 8064eb9..250537b 100644
@@ -18,6 +18,11 @@ void do_pf_tss(void);
 

x86/eventinj.c void do_pf_tss(void); · line 28

Quoted 10 lines
x86/eventinj.c +5 -0
  static inline void io_delay(void)
  {
+	u64 start = rdtsc();
+
+	do {
+		pause();
+	} while (rdtsc() - start < 10000);
  }
 
  static void apic_self_ipi(u8 v)

Perhaps call delay() (in delay.c)  inside of io_delay() OR perhaps replace all instances of io_delay() with delay() ?

author
#2 lore raw
Quoted 25 lines · Krish Sadhukhan
Quoted 21 lines · On 5/2/19 11:49 AM, [email protected] wrote:

From: Nadav Amit <[email protected]>

There is no guarantee that a self-IPI would be delivered immediately. io_delay() is called after self-IPI is generated but does nothing. Instead, change io_delay() to wait for 10000 cycles, which should be enough on any system whatsoever.

---
 x86/eventinj.c | 5 +++++
 1 file changed, 5 insertions(+)
x86/eventinj.c +2 -0
index 8064eb9..250537b 100644
@@ -18,6 +18,11 @@ void do_pf_tss(void);
   static inline void io_delay(void)
 {
+	u64 start = rdtsc();
+
Quoted 8 lines

x86/eventinj.c void do_pf_tss(void); · line 28

Quoted 5 lines
x86/eventinj.c +3 -0
+	do {
+		pause();
+	} while (rdtsc() - start < 10000);
 }
   static void apic_self_ipi(u8 v)

Perhaps call delay() (in delay.c) inside of io_delay() OR perhaps replace all instances of io_delay() with delay() ?

There is such a mess with this delay(). It times stuff based on number of pause() invocations. There is an additional implementation in ioapic.c (which by itself is broken, since there is no compiler barrier).

Let me see what I can do...