Skip to contentSkip to conversation

wait: drop wake_up_{all,one}()

PATCH Superseded Jan Beulich 2 participants 3 messages Feb 17

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wait: drop wake_up_{all,one}()

wake_up_one() isn't used at all, so violates Misra rule 2.1 (unreachable code). wake_up_all() is only used locally, yet rather than making it static its sole user can invoke wake_up_nr() in the intended way directly.

xen/common/wait.c +1 -11
@@ -85,11 +85,6 @@ void init_waitqueue_head(struct waitqueu
     INIT_LIST_HEAD(&wq->list);
 }
 
-void destroy_waitqueue_head(struct waitqueue_head *wq)
-{
-    wake_up_all(wq);
-}
-
 void wake_up_nr(struct waitqueue_head *wq, unsigned int nr)
 {
     struct waitqueue_vcpu *wqv;
@@ -107,12 +102,7 @@ void wake_up_nr(struct waitqueue_head *w
     spin_unlock(&wq->lock);
 }
 
-void wake_up_one(struct waitqueue_head *wq)
-{
-    wake_up_nr(wq, 1);
-}
-
-void wake_up_all(struct waitqueue_head *wq)
+void destroy_waitqueue_head(struct waitqueue_head *wq)
 {
     wake_up_nr(wq, UINT_MAX);
 }
xen/include/xen/wait.h +0 -2
@@ -31,8 +31,6 @@ void destroy_waitqueue_head(struct waitq
 
 /* Wake VCPU(s) waiting on specified waitqueue. */
 void wake_up_nr(struct waitqueue_head *wq, unsigned int nr);
-void wake_up_one(struct waitqueue_head *wq);
-void wake_up_all(struct waitqueue_head *wq);
 
 /* Wait on specified waitqueue until @condition is true. */
 #define wait_event(wq, condition)               \
#1 lore raw
Quoted 24 lines · Jan Beulich

wake_up_one() isn't used at all, so violates Misra rule 2.1 (unreachable code). wake_up_all() is only used locally, yet rather than making it static its sole user can invoke wake_up_nr() in the intended way directly.

xen/common/wait.c +0 -5
@@ -85,11 +85,6 @@ void init_waitqueue_head(struct waitqueu
     INIT_LIST_HEAD(&wq->list);
 }
 
-void destroy_waitqueue_head(struct waitqueue_head *wq)
-{
-    wake_up_all(wq);
-}
-
 void wake_up_nr(struct waitqueue_head *wq, unsigned int nr)
 {
     struct waitqueue_vcpu *wqv;
@@ -107,12 +102,7 @@ void wake_up_nr(struct waitqueue_head *w
     spin_unlock(&wq->lock);
 }
 

xen/common/wait.c void wake_up_nr(struct waitqueue_head *w · line 108

Quoted 10 lines
xen/common/wait.c +1 -6
-void wake_up_one(struct waitqueue_head *wq)
-{
-    wake_up_nr(wq, 1);
-}
-
-void wake_up_all(struct waitqueue_head *wq)
+void destroy_waitqueue_head(struct waitqueue_head *wq)
 {
     wake_up_nr(wq, UINT_MAX);
 }

The diff looks wonky because you also moved destroy_waitqueue_head(), despite wake_up_nr() not being static.

Keeping destroy_waitqueue_head() in it's old location will make the diff smaller and more obvious.

~Andrew

#2 lore raw
Quoted 39 lines · Andrew Cooper
Quoted 24 lines · Jan Beulich

wake_up_one() isn't used at all, so violates Misra rule 2.1 (unreachable code). wake_up_all() is only used locally, yet rather than making it static its sole user can invoke wake_up_nr() in the intended way directly.

xen/common/wait.c +0 -5
@@ -85,11 +85,6 @@ void init_waitqueue_head(struct waitqueu
     INIT_LIST_HEAD(&wq->list);
 }
 
-void destroy_waitqueue_head(struct waitqueue_head *wq)
-{
-    wake_up_all(wq);
-}
-
 void wake_up_nr(struct waitqueue_head *wq, unsigned int nr)
 {
     struct waitqueue_vcpu *wqv;
@@ -107,12 +102,7 @@ void wake_up_nr(struct waitqueue_head *w
     spin_unlock(&wq->lock);
 }
 

xen/common/wait.c void wake_up_nr(struct waitqueue_head *w · line 108

Quoted 10 lines
xen/common/wait.c +1 -6
-void wake_up_one(struct waitqueue_head *wq)
-{
-    wake_up_nr(wq, 1);
-}
-
-void wake_up_all(struct waitqueue_head *wq)
+void destroy_waitqueue_head(struct waitqueue_head *wq)
 {
     wake_up_nr(wq, UINT_MAX);
 }

The diff looks wonky because you also moved destroy_waitqueue_head(), despite wake_up_nr() not being static.

Quoted 2 lines

Keeping destroy_waitqueue_head() in it's old location will make the diff smaller and more obvious.

The diff size doesn't really change. As to "more obvious" - yes, the deletion of the two functions is more obvious then. The "keep the UINT_MAX use" aspect then becomes less obvious. That's why I did it the way shown. I'm okay doing it the other way, if that eases it making progress.

Jan