From: <erik.hugne@ericsson.com>
To: <netdev@vger.kernel.org>, <tipc-discussion@lists.sourceforge.net>,
<jon.maloy@ericsson.com>, <maloy@donjonn.com>
Cc: <ying.xue@windriver.com>, <paul.gortmaker@windriver.com>,
<richard.alpe@ericsson.com>
Subject: [PATCH net-next v2 3/6] tipc: avoid to unnecessary process switch under non-block mode
Date: Wed, 5 Mar 2014 08:56:15 +0100 [thread overview]
Message-ID: <1394006178-23966-4-git-send-email-erik.hugne@ericsson.com> (raw)
In-Reply-To: <1394006178-23966-1-git-send-email-erik.hugne@ericsson.com>
From: Ying Xue <ying.xue@windriver.com>
When messages are received via tipc socket under non-block mode,
schedule_timeout() is called in tipc_wait_for_rcvmsg(), that is,
the process of receiving messages will be scheduled once although
timeout value passed to schedule_timeout() is 0. The same issue
exists in accept()/wait_for_accept(). To avoid this unnecessary
process switch, we only call schedule_timeout() if the timeout
value is non-zero.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index fb88597..96978fb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1001,7 +1001,7 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long timeo)
for (;;) {
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
- if (skb_queue_empty(&sk->sk_receive_queue)) {
+ if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
if (sock->state == SS_DISCONNECTING) {
err = -ENOTCONN;
break;
@@ -1627,7 +1627,7 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo)
for (;;) {
prepare_to_wait_exclusive(sk_sleep(sk), &wait,
TASK_INTERRUPTIBLE);
- if (skb_queue_empty(&sk->sk_receive_queue)) {
+ if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock(sk);
--
1.8.3.2
next prev parent reply other threads:[~2014-03-05 7:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 7:56 [PATCH net-next v2 0/6] tipc: refcount and memory leak fixes erik.hugne
2014-03-05 7:56 ` [PATCH net-next v2 1/6] tipc: allow connection shutdown callback to be invoked in advance erik.hugne
2014-03-06 4:56 ` David Miller
2014-03-06 9:06 ` Erik Hugne
2014-03-09 17:48 ` Ben Hutchings
2014-03-05 7:56 ` [PATCH net-next v2 2/6] tipc: fix connection refcount leak erik.hugne
2014-03-05 7:56 ` erik.hugne [this message]
2014-03-05 7:56 ` [PATCH net-next v2 4/6] tipc: drop subscriber connection id invalidation erik.hugne
2014-03-05 7:56 ` [PATCH net-next v2 5/6] tipc: fix memory leak during module removal erik.hugne
2014-03-05 7:56 ` [PATCH net-next v2 6/6] tipc: don't log disabled tasklet handler errors erik.hugne
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=1394006178-23966-4-git-send-email-erik.hugne@ericsson.com \
--to=erik.hugne@ericsson.com \
--cc=jon.maloy@ericsson.com \
--cc=maloy@donjonn.com \
--cc=netdev@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=richard.alpe@ericsson.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.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).