Skip to contentSkip to conversation

xen/events: fix build

PATCH In review Juergen Gross 2 participants 5 messages Nov 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/events: fix build

Commit 5f2df45ead7c1195 ("xen/evtchn: rework per event channel lock") introduced a build failure for NDEBUG builds.

Fixes 5f2df45ead7c1195 ("xen/evtchn: rework per event channel lock")
---
 xen/common/event_channel.c | 2 ++
 xen/include/xen/sched.h    | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/common/event_channel.c +2 -0
index eacd96b92f..da85d536f4 100644
@@ -61,7 +61,9 @@ static inline void evtchn_write_lock(struct evtchn *evtchn)
 {
     write_lock(&evtchn->lock);
 
+#ifndef NDEBUG
     evtchn->old_state = evtchn->state;
+#endif
 }
 
 static inline void evtchn_write_unlock(struct evtchn *evtchn)
xen/include/xen/sched.h +0 -2
index 7251b3ae3e..95f96e7a33 100644
@@ -114,9 +114,7 @@ struct evtchn
         u16 virq;      /* state == ECS_VIRQ */
     } u;
     u8 priority;
-#ifndef NDEBUG
     u8 old_state;      /* State when taking lock in write mode. */
-#endif
     u8 last_priority;
     u16 last_vcpu_id;
 #ifdef CONFIG_XSM
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Juergen Gross
xen/common/event_channel.c +2 -0
@@ -61,7 +61,9 @@ static inline void evtchn_write_lock(struct evtchn *evtchn)
 {
     write_lock(&evtchn->lock);
 
+#ifndef NDEBUG
     evtchn->old_state = evtchn->state;
+#endif
 }
 
 static inline void evtchn_write_unlock(struct evtchn *evtchn)
xen/include/xen/sched.h +0 -0
index 7251b3ae3e..95f96e7a33 100644

xen/include/xen/sched.h struct evtchn · line 120

Quoted 9 lines
xen/include/xen/sched.h +0 -2
@@ -114,9 +114,7 @@ struct evtchn
         u16 virq;      /* state == ECS_VIRQ */
     } u;
     u8 priority;
-#ifndef NDEBUG
     u8 old_state;      /* State when taking lock in write mode. */
-#endif
     u8 last_priority;
     u16 last_vcpu_id;
 #ifdef CONFIG_XSM

Did you mean just either of the two changes (and then the former), not both? If so

and I'll be happy to drop the other half for committing.

Jan

#2 lore raw
Quoted 30 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
xen/common/event_channel.c +2 -0
@@ -61,7 +61,9 @@ static inline void evtchn_write_lock(struct evtchn *evtchn)
  {
      write_lock(&evtchn->lock);
 
+#ifndef NDEBUG
      evtchn->old_state = evtchn->state;
+#endif
  }
 
  static inline void evtchn_write_unlock(struct evtchn *evtchn)
xen/include/xen/sched.h +0 -0
index 7251b3ae3e..95f96e7a33 100644

xen/include/xen/sched.h struct evtchn · line 120

Quoted 9 lines
xen/include/xen/sched.h +0 -2
@@ -114,9 +114,7 @@ struct evtchn
          u16 virq;      /* state == ECS_VIRQ */
      } u;
      u8 priority;
-#ifndef NDEBUG
      u8 old_state;      /* State when taking lock in write mode. */
-#endif
      u8 last_priority;
      u16 last_vcpu_id;
  #ifdef CONFIG_XSM

Did you mean just either of the two changes (and then the former), not both? If so

Quoted 2 lines

and I'll be happy to drop the other half for committing.

The header fix is required for NDEBUG builds, while the other one is removing a write with no accompanied read for NDEBUG builds.

Juergen

#3 lore raw
Quoted 34 lines · Jürgen Groß
Quoted 30 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
xen/common/event_channel.c +2 -0
@@ -61,7 +61,9 @@ static inline void evtchn_write_lock(struct evtchn *evtchn)
  {
      write_lock(&evtchn->lock);
 
+#ifndef NDEBUG
      evtchn->old_state = evtchn->state;
+#endif
  }
 
  static inline void evtchn_write_unlock(struct evtchn *evtchn)
xen/include/xen/sched.h +0 -0
index 7251b3ae3e..95f96e7a33 100644

xen/include/xen/sched.h struct evtchn · line 120

Quoted 9 lines
xen/include/xen/sched.h +0 -2
@@ -114,9 +114,7 @@ struct evtchn
          u16 virq;      /* state == ECS_VIRQ */
      } u;
      u8 priority;
-#ifndef NDEBUG
      u8 old_state;      /* State when taking lock in write mode. */
-#endif
      u8 last_priority;
      u16 last_vcpu_id;
  #ifdef CONFIG_XSM

Did you mean just either of the two changes (and then the former), not both? If so

Quoted 2 lines

and I'll be happy to drop the other half for committing.

Quoted 2 lines

The header fix is required for NDEBUG builds, while the other one is removing a write with no accompanied read for NDEBUG builds.

Oh, that's because of our absurd ASSERT() implementation in the NDEBUG case. I stand by my position that the field should not be there in the first place for release builds. Even more so with the original patch having got re-based ahead of what was patch 1 of the series, which I did not the least because I want that one backported urgently, while I continue to be hesitant altogether about the other one.

I guess the course of action is then to put #ifndef NDEBUG around the ASSERT() itself, however strange this may look. Or introduce an evtchn_old_state() wrapper, perhaps returning ECS_RESERVED in the NDEBUG case. I guess it'll be quicker if I take your patch and massage it before throwing in, than to have you make a v2.

Janan

#4 lore raw
Quoted 46 lines · Jan Beulich
Quoted 34 lines · Jürgen Groß
Quoted 30 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
xen/common/event_channel.c +2 -0
@@ -61,7 +61,9 @@ static inline void evtchn_write_lock(struct evtchn *evtchn)
   {
       write_lock(&evtchn->lock);
 
+#ifndef NDEBUG
       evtchn->old_state = evtchn->state;
+#endif
   }
 
   static inline void evtchn_write_unlock(struct evtchn *evtchn)
xen/include/xen/sched.h +0 -0
index 7251b3ae3e..95f96e7a33 100644

xen/include/xen/sched.h struct evtchn · line 120

Quoted 9 lines
xen/include/xen/sched.h +0 -2
@@ -114,9 +114,7 @@ struct evtchn
           u16 virq;      /* state == ECS_VIRQ */
       } u;
       u8 priority;
-#ifndef NDEBUG
       u8 old_state;      /* State when taking lock in write mode. */
-#endif
       u8 last_priority;
       u16 last_vcpu_id;
   #ifdef CONFIG_XSM

Did you mean just either of the two changes (and then the former), not both? If so

Quoted 2 lines

and I'll be happy to drop the other half for committing.

Quoted 2 lines

The header fix is required for NDEBUG builds, while the other one is removing a write with no accompanied read for NDEBUG builds.

Oh, that's because of our absurd ASSERT() implementation in the NDEBUG case. I stand by my position that the field should not be there in the first place for release builds. Even more so with the original patch having got re-based ahead of what was patch 1 of the series, which I did not the least because I want that one backported urgently, while I continue to be hesitant altogether about the other one.

Quoted 6 lines

I guess the course of action is then to put #ifndef NDEBUG around the ASSERT() itself, however strange this may look. Or introduce an evtchn_old_state() wrapper, perhaps returning ECS_RESERVED in the NDEBUG case. I guess it'll be quicker if I take your patch and massage it before throwing in, than to have you make a v2.

Fine with me.

Juergen