tipc: improve function tipc_wait_for_cond() [Linux 5.0]

This Linux kernel change "tipc: improve function tipc_wait_for_cond()" is included in the Linux 5.0 release. This change is authored by Tung Nguyen <tung.q.nguyen [at] dektech.com.au> on Tue Feb 19 11:20:47 2019 +0700. The commit for this change in Linux stable tree is 223b732 (patch).

tipc: improve function tipc_wait_for_cond()

Commit 844cf763fba6 ("tipc: make macro tipc_wait_for_cond() smp safe")
replaced finish_wait() with remove_wait_queue() but still used
prepare_to_wait(). This causes unnecessary conditional
checking  before adding to wait queue in prepare_to_wait().

This commit replaces prepare_to_wait() with add_wait_queue()
as the pair function with remove_wait_queue().

Acked-by: Ying Xue <[email protected]>
Acked-by: Jon Maloy <[email protected]>
Signed-off-by: Tung Nguyen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/tipc/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1217c90..81b8791 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -388,7 +388,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout)
        rc_ = tipc_sk_sock_err((sock_), timeo_);               \
        if (rc_)                               \
            break;                             \
-       prepare_to_wait(sk_sleep(sk_), &wait_, TASK_INTERRUPTIBLE);    \
+       add_wait_queue(sk_sleep(sk_), &wait_);                         \
        release_sock(sk_);                         \
        *(timeo_) = wait_woken(&wait_, TASK_INTERRUPTIBLE, *(timeo_)); \
        sched_annotate_sleep();                            \

Leave a Reply

Your email address will not be published. Required fields are marked *