* [tipc-discussion][net 0/2] improvement for wait and wakeup
@ 2019-02-19 4:20 Tung Nguyen
2019-02-19 4:20 ` [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond() Tung Nguyen
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
Some improvements for tipc_wait_for_xzy().
Tung Nguyen (2):
tipc: improve function tipc_wait_for_cond()
tipc: improve function tipc_wait_for_rcvmsg()
net/tipc/socket.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond()
2019-02-19 4:20 [tipc-discussion][net 0/2] improvement for wait and wakeup Tung Nguyen
@ 2019-02-19 4:20 ` Tung Nguyen
2023-03-14 17:45 ` [STABLE REQUEST] " Lee Jones
2019-02-19 4:20 ` [tipc-discussion][net 2/2] tipc: improve function tipc_wait_for_rcvmsg() Tung Nguyen
2019-02-21 21:58 ` [tipc-discussion][net 0/2] improvement for wait and wakeup David Miller
2 siblings, 1 reply; 8+ messages in thread
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
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 <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
---
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 1217c90a363b..81b87916a0eb 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(); \
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tipc-discussion][net 2/2] tipc: improve function tipc_wait_for_rcvmsg()
2019-02-19 4:20 [tipc-discussion][net 0/2] improvement for wait and wakeup Tung Nguyen
2019-02-19 4:20 ` [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond() Tung Nguyen
@ 2019-02-19 4:20 ` Tung Nguyen
2019-02-21 21:58 ` [tipc-discussion][net 0/2] improvement for wait and wakeup David Miller
2 siblings, 0 replies; 8+ messages in thread
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
This commit replaces schedule_timeout() with wait_woken()
in function tipc_wait_for_rcvmsg(). wait_woken() uses
memory barriers in its implementation to avoid potential
race condition when putting a process into sleeping state
and then waking it up.
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
---
net/tipc/socket.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 81b87916a0eb..684f2125fc6b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1677,7 +1677,7 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
{
struct sock *sk = sock->sk;
- DEFINE_WAIT(wait);
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
long timeo = *timeop;
int err = sock_error(sk);
@@ -1685,15 +1685,17 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
return err;
for (;;) {
- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
if (sk->sk_shutdown & RCV_SHUTDOWN) {
err = -ENOTCONN;
break;
}
+ add_wait_queue(sk_sleep(sk), &wait);
release_sock(sk);
- timeo = schedule_timeout(timeo);
+ timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
+ sched_annotate_sleep();
lock_sock(sk);
+ remove_wait_queue(sk_sleep(sk), &wait);
}
err = 0;
if (!skb_queue_empty(&sk->sk_receive_queue))
@@ -1709,7 +1711,6 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
if (err)
break;
}
- finish_wait(sk_sleep(sk), &wait);
*timeop = timeo;
return err;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [tipc-discussion][net 0/2] improvement for wait and wakeup
2019-02-19 4:20 [tipc-discussion][net 0/2] improvement for wait and wakeup Tung Nguyen
2019-02-19 4:20 ` [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond() Tung Nguyen
2019-02-19 4:20 ` [tipc-discussion][net 2/2] tipc: improve function tipc_wait_for_rcvmsg() Tung Nguyen
@ 2019-02-21 21:58 ` David Miller
2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2019-02-21 21:58 UTC (permalink / raw)
To: tung.q.nguyen; +Cc: netdev, tipc-discussion
From: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Date: Tue, 19 Feb 2019 11:20:46 +0700
> Some improvements for tipc_wait_for_xzy().
Series applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [STABLE REQUEST] tipc: improve function tipc_wait_for_cond()
2019-02-19 4:20 ` [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond() Tung Nguyen
@ 2023-03-14 17:45 ` Lee Jones
2023-03-14 17:57 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2023-03-14 17:45 UTC (permalink / raw)
To: Tung Nguyen, stable; +Cc: davem, netdev, tipc-discussion
Dear Stable,
> 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 <ying.xue@windriver.com>
> Acked-by: Jon Maloy <jon.maloy@ericsson.com>
> Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
> ---
> 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 1217c90a363b..81b87916a0eb 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(); \
Could we have this ol' classic backported to v4.19 and v4.14 please?
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [STABLE REQUEST] tipc: improve function tipc_wait_for_cond()
2023-03-14 17:45 ` [STABLE REQUEST] " Lee Jones
@ 2023-03-14 17:57 ` Greg KH
2023-03-14 18:04 ` Lee Jones
0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2023-03-14 17:57 UTC (permalink / raw)
To: Lee Jones; +Cc: Tung Nguyen, stable, davem, netdev, tipc-discussion
On Tue, Mar 14, 2023 at 05:45:37PM +0000, Lee Jones wrote:
> Dear Stable,
>
> > 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 <ying.xue@windriver.com>
> > Acked-by: Jon Maloy <jon.maloy@ericsson.com>
> > Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
> > ---
> > 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 1217c90a363b..81b87916a0eb 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(); \
>
> Could we have this ol' classic backported to v4.19 and v4.14 please?
What is the git commit id?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [STABLE REQUEST] tipc: improve function tipc_wait_for_cond()
2023-03-14 17:57 ` Greg KH
@ 2023-03-14 18:04 ` Lee Jones
2023-03-15 7:24 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2023-03-14 18:04 UTC (permalink / raw)
To: Greg KH; +Cc: Tung Nguyen, stable, davem, netdev, tipc-discussion
On Tue, 14 Mar 2023, Greg KH wrote:
> On Tue, Mar 14, 2023 at 05:45:37PM +0000, Lee Jones wrote:
> > Dear Stable,
> >
> > > 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 <ying.xue@windriver.com>
> > > Acked-by: Jon Maloy <jon.maloy@ericsson.com>
> > > Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
> > > ---
> > > 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 1217c90a363b..81b87916a0eb 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(); \
> >
> > Could we have this ol' classic backported to v4.19 and v4.14 please?
>
> What is the git commit id?
Sorry, it's 223b7329ec6a0.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [STABLE REQUEST] tipc: improve function tipc_wait_for_cond()
2023-03-14 18:04 ` Lee Jones
@ 2023-03-15 7:24 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2023-03-15 7:24 UTC (permalink / raw)
To: Lee Jones; +Cc: Tung Nguyen, stable, davem, netdev, tipc-discussion
On Tue, Mar 14, 2023 at 06:04:30PM +0000, Lee Jones wrote:
> On Tue, 14 Mar 2023, Greg KH wrote:
>
> > On Tue, Mar 14, 2023 at 05:45:37PM +0000, Lee Jones wrote:
> > > Dear Stable,
> > >
> > > > 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 <ying.xue@windriver.com>
> > > > Acked-by: Jon Maloy <jon.maloy@ericsson.com>
> > > > Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
> > > > ---
> > > > 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 1217c90a363b..81b87916a0eb 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(); \
> > >
> > > Could we have this ol' classic backported to v4.19 and v4.14 please?
> >
> > What is the git commit id?
>
> Sorry, it's 223b7329ec6a0.
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-15 7:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 4:20 [tipc-discussion][net 0/2] improvement for wait and wakeup Tung Nguyen
2019-02-19 4:20 ` [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond() Tung Nguyen
2023-03-14 17:45 ` [STABLE REQUEST] " Lee Jones
2023-03-14 17:57 ` Greg KH
2023-03-14 18:04 ` Lee Jones
2023-03-15 7:24 ` Greg KH
2019-02-19 4:20 ` [tipc-discussion][net 2/2] tipc: improve function tipc_wait_for_rcvmsg() Tung Nguyen
2019-02-21 21:58 ` [tipc-discussion][net 0/2] improvement for wait and wakeup David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).