Hi Jon,

Iam adding one more patch, where i allow only user sockets to sleep.
The protocol messages should never be in the wakeupq.

"tipc: check for user before making congestion decision"

/Partha

On 12/20/2016 02:21 PM, Jon Maloy wrote:
> Thank you for your thorough testing. This is really the kind of work that 
> helps us keeping out of trouble.
> See my comments below.
>
> ///jon

---
 From f18c49d672eb991396a234165b534f9cfdeca5b3 Mon Sep 17 00:00:00 2001
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
Date: Wed, 21 Dec 2016 10:53:44 +0100
Subject: [PATCH net-next 1/5] tipc: check for user before making 
congestion decision

In this commit, we test link backlog limits only for users since
they are forced to sleep during congestion.

Signed-off-by: Parthasarathy Bhuvaragan 
<parthasarathy.bhuvara...@ericsson.com>
---
  net/tipc/link.c | 23 ++++++++++++-----------
  1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/net/tipc/link.c b/net/tipc/link.c
index 5f2b478ac720..a3819613fe92 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -783,24 +783,17 @@ int tipc_link_timeout(struct tipc_link *l, struct 
sk_buff_head *xmitq)
   */
  static int link_schedule_user(struct tipc_link *l, struct tipc_msg *hdr)
  {
-       int imp = msg_importance(hdr);
        u32 dnode = tipc_own_addr(l->net);
        u32 dport = msg_origport(hdr);
        struct sk_buff *skb;

-       /* This really cannot happen...  */
-       if (unlikely(imp > TIPC_CRITICAL_IMPORTANCE)) {
-               pr_warn("%s<%s>, send queue full", link_rst_msg, l->name);
-               return -ENOBUFS;
-       }
-
        /* Create and schedule wakeup pseudo message */
        skb = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0,
                              dnode, l->addr, dport, 0, 0);
        if (!skb)
                return -ENOBUFS;
        msg_set_dest_droppable(buf_msg(skb), true);
-       TIPC_SKB_CB(skb)->chain_imp = imp;
+       TIPC_SKB_CB(skb)->chain_imp = msg_importance(hdr);
        skb_queue_tail(&l->wakeupq, skb);
        l->stats.link_congs++;
        return -ELINKCONG;
@@ -889,9 +882,17 @@ int tipc_link_xmit(struct tipc_link *l, struct 
sk_buff_head *list,
                return -EMSGSIZE;
        }

-       /* Accept oversubscription of one message per source at congestion */
-       if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit))
-               rc = link_schedule_user(l, hdr);
+       if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {
+               if (unlikely(imp > TIPC_CRITICAL_IMPORTANCE)) {
+                       pr_warn("%s<%s>, send queue full",
+                               link_rst_msg, l->name);
+                       return -ENOBUFS;
+               }
+
+               /* Let oversubscription of one message per user at congestion */
+               if (msg_importance(hdr) < TIPC_SYSTEM_IMPORTANCE)
+                       rc = link_schedule_user(l, hdr);
+       }

        if (pkt_cnt > 1) {
                l->stats.sent_fragmented++;
-- 
2.1.4

 From 3d7023fe53b85db6010539d6b05e1b3acbaaef37 Mon Sep 17 00:00:00 2001
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
Date: Thu, 15 Dec 2016 16:02:20 +0100
Subject: [PATCH net-next 2/5] tipc: fix node error handling at link 
congestion

Since the link can return ELINKCONG, but still transmits the frame
on the link, we need to adjust the return code handling in the node.

Signed-off-by: Parthasarathy Bhuvaragan 
<parthasarathy.bhuvara...@ericsson.com>
---
  net/tipc/node.c | 16 +++++-----------
  1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index f51d360dac77..edfb05746131 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1206,10 +1206,10 @@ int tipc_node_xmit(struct net *net, struct 
sk_buff_head *list,
        spin_unlock_bh(&le->lock);
        tipc_node_read_unlock(n);

-       if (likely(rc == 0))
-               tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr);
-       else if (rc == -ENOBUFS)
+       if (unlikely(rc == -ENOBUFS))
                tipc_node_link_down(n, bearer_id, false);
+       else
+               tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr);

        tipc_node_put(n);

@@ -1219,22 +1219,16 @@ int tipc_node_xmit(struct net *net, struct 
sk_buff_head *list,
  /* tipc_node_xmit_skb(): send single buffer to destination
   * Buffers sent via this functon are generally TIPC_SYSTEM_IMPORTANCE
   * messages, which will not be rejected
- * The only exception is datagram messages rerouted after secondary
- * lookup, which are rare and safe to dispose of anyway.
- * TODO: Return real return value, and let callers use
- * tipc_wait_for_sendpkt() where applicable
   */
  int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode,
                       u32 selector)
  {
        struct sk_buff_head head;
-       int rc;

        skb_queue_head_init(&head);
        __skb_queue_tail(&head, skb);
-       rc = tipc_node_xmit(net, &head, dnode, selector);
-       if (rc == -ELINKCONG)
-               kfree_skb(skb);
+       tipc_node_xmit(net, &head, dnode, selector);
+
        return 0;
  }

-- 
2.1.4

 From e1e7956b7941936f342a7cd3f6826f43eb08be7c Mon Sep 17 00:00:00 2001
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
Date: Tue, 20 Dec 2016 12:04:28 +0100
Subject: [PATCH net-next 3/5] tipc: fix sending to own node even at link
  congestion

We let the broadcast layer to transmit a copy to the own node even
if the link returns ELINKCONG.

Signed-off-by: Parthasarathy Bhuvaragan 
<parthasarathy.bhuvara...@ericsson.com>
---
  net/tipc/bcast.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 1a56cabbf389..247f87518565 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -196,8 +196,10 @@ int tipc_bcast_xmit(struct net *net, struct 
sk_buff_head *list)
                rc = tipc_link_xmit(l, list, &xmitq);
        tipc_bcast_unlock(net);

-       /* Don't send to local node if adding to link failed */
-       if (unlikely(rc)) {
+       /* Don't send to local node if adding to link failed
+        * for reasons other than -ELINKCONG.
+        */
+       if (unlikely(rc) && (rc != -ELINKCONG)) {
                __skb_queue_purge(&rcvq);
                return rc;
        }
-- 
2.1.4

 From 13763be23c46922e1a95522b2e54be21bda03e26 Mon Sep 17 00:00:00 2001
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
Date: Tue, 20 Dec 2016 08:33:21 +0100
Subject: [PATCH net-next 4/5] tipc: fix return code from bcast_xmit

We must send the return code from tipc_bcast_xmit() to the caller
tipc_sendmcast() to detect link congestion in socket layer.

Signed-off-by: Parthasarathy Bhuvaragan 
<parthasarathy.bhuvara...@ericsson.com>
---
  net/tipc/bcast.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 247f87518565..c91b276f6831 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -208,7 +208,7 @@ int tipc_bcast_xmit(struct net *net, struct 
sk_buff_head *list)
        tipc_bcbase_xmit(net, &xmitq);
        tipc_sk_mcast_rcv(net, &rcvq, &inputq);
        __skb_queue_purge(list);
-       return 0;
+       return rc;
  }

  /* tipc_bcast_rcv - receive a broadcast packet, and deliver to rcv link
-- 
2.1.4

 From b90659acf5f8f32398bbd01fd2188377b012f29a Mon Sep 17 00:00:00 2001
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
Date: Tue, 20 Dec 2016 10:21:26 +0100
Subject: [PATCH net-next 5/5] tipc: fix reset the congested link count 
at release

Signed-off-by: Parthasarathy Bhuvaragan 
<parthasarathy.bhuvara...@ericsson.com>
---
  net/tipc/socket.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 3dd851aaf050..98f661f70f40 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -553,6 +553,7 @@ static int tipc_release(struct socket *sock)
        /* Reject any messages that accumulated in backlog queue */
        release_sock(sk);
        u32_list_purge(&tsk->cong_links);
+       tsk->cong_link_cnt = 0;
        call_rcu(&tsk->rcu, tipc_sk_callback);
        sock->sk = NULL;

-- 
2.1.4

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to