From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: mhocko@kernel.org, romieu@fr.zoreil.com, 3chas3@gmail.com,
andreyknvl@google.com, Cong Wang <xiyou.wangcong@gmail.com>
Subject: [Patch net] atm: switch to the new wait API for vcc_sendmsg()
Date: Wed, 11 Jan 2017 21:02:02 -0800 [thread overview]
Message-ID: <1484197322-958-2-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1484197322-958-1-git-send-email-xiyou.wangcong@gmail.com>
Andrey reported a kernel warning for the blocking ops
in between prepare_to_wait() and schedule(), that is
alloc_tx().
Of course, the logic itself is suspicious, other sendmsg()
could handle skb allocation failure very well, not sure
why ATM has to wait for a successful one here. But probably
it is too late to change since the errno and behavior is
visible to user-space. So just leave the logic as it is.
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/atm/common.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/atm/common.c b/net/atm/common.c
index 7ec3bbc..b672231 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -572,8 +572,8 @@ int vcc_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
{
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = sock->sk;
- DEFINE_WAIT(wait);
struct atm_vcc *vcc;
struct sk_buff *skb;
int eff, error;
@@ -605,14 +605,14 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
}
eff = (size+3) & ~3; /* align to word boundary */
- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
+ add_wait_queue(sk_sleep(sk), &wait);
error = 0;
while (!(skb = alloc_tx(vcc, eff))) {
if (m->msg_flags & MSG_DONTWAIT) {
error = -EAGAIN;
break;
}
- schedule();
+ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
if (signal_pending(current)) {
error = -ERESTARTSYS;
break;
@@ -624,9 +624,8 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
send_sig(SIGPIPE, current, 0);
break;
}
- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
}
- finish_wait(sk_sleep(sk), &wait);
+ remove_wait_queue(sk_sleep(sk), &wait);
if (error)
goto out;
skb->dev = NULL; /* for paths shared with net_device interfaces */
--
2.5.5
next prev parent reply other threads:[~2017-01-12 5:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 5:02 [Patch net] atm: remove an unnecessary loop Cong Wang
2017-01-12 5:02 ` Cong Wang [this message]
2017-01-12 8:43 ` Michal Hocko
2017-01-13 0:07 ` Francois Romieu
2017-01-13 0:14 ` Cong Wang
2017-01-13 13:23 ` Francois Romieu
2017-01-13 18:18 ` Cong Wang
2017-01-14 0:15 ` Francois Romieu
2017-01-14 0:41 ` Cong Wang
2017-01-13 17:10 ` David Miller
2017-01-13 18:20 ` Cong Wang
2017-01-13 23:54 ` Chas Williams
2017-01-14 0:30 ` Cong Wang
2017-01-14 11:34 ` Chas Williams
2017-01-14 0:14 ` Francois Romieu
2017-01-14 0:24 ` Francois Romieu
2017-01-14 0:36 ` Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484197322-958-2-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=3chas3@gmail.com \
--cc=andreyknvl@google.com \
--cc=mhocko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).