This is a note to let you know that I've just added the patch titled

    pkt_sched: fq: do not hold qdisc lock while allocating

to the 3.13-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pkt_sched-fq-do-not-hold-qdisc-lock-while-allocating.patch
and it can be found in the queue-3.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From foo@baz Thu Apr 10 22:03:04 PDT 2014
From: Eric Dumazet <[email protected]>
Date: Thu, 6 Mar 2014 22:57:52 -0800
Subject: pkt_sched: fq: do not hold qdisc lock while allocating
 memory

From: Eric Dumazet <[email protected]>

[ Upstream commit 2d8d40afd187bced0a3d056366fb58d66fe845e3 ]

Resizing fq hash table allocates memory while holding qdisc spinlock,
with BH disabled.

This is definitely not good, as allocation might sleep.

We can drop the lock and get it when needed, we hold RTNL so no other
changes can happen at the same time.

Signed-off-by: Eric Dumazet <[email protected]>
Fixes: afe4fd062416 ("pkt_sched: fq: Fair Queue packet scheduler")
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 net/sched/sch_fq.c |   28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -578,9 +578,11 @@ static void fq_rehash(struct fq_sched_da
        q->stat_gc_flows += fcnt;
 }
 
-static int fq_resize(struct fq_sched_data *q, u32 log)
+static int fq_resize(struct Qdisc *sch, u32 log)
 {
+       struct fq_sched_data *q = qdisc_priv(sch);
        struct rb_root *array;
+       void *old_fq_root;
        u32 idx;
 
        if (q->fq_root && log == q->fq_trees_log)
@@ -593,13 +595,19 @@ static int fq_resize(struct fq_sched_dat
        for (idx = 0; idx < (1U << log); idx++)
                array[idx] = RB_ROOT;
 
-       if (q->fq_root) {
-               fq_rehash(q, q->fq_root, q->fq_trees_log, array, log);
-               kfree(q->fq_root);
-       }
+       sch_tree_lock(sch);
+
+       old_fq_root = q->fq_root;
+       if (old_fq_root)
+               fq_rehash(q, old_fq_root, q->fq_trees_log, array, log);
+
        q->fq_root = array;
        q->fq_trees_log = log;
 
+       sch_tree_unlock(sch);
+
+       kfree(old_fq_root);
+
        return 0;
 }
 
@@ -675,9 +683,11 @@ static int fq_change(struct Qdisc *sch,
                q->flow_refill_delay = usecs_to_jiffies(usecs_delay);
        }
 
-       if (!err)
-               err = fq_resize(q, fq_log);
-
+       if (!err) {
+               sch_tree_unlock(sch);
+               err = fq_resize(sch, fq_log);
+               sch_tree_lock(sch);
+       }
        while (sch->q.qlen > sch->limit) {
                struct sk_buff *skb = fq_dequeue(sch);
 
@@ -723,7 +733,7 @@ static int fq_init(struct Qdisc *sch, st
        if (opt)
                err = fq_change(sch, opt);
        else
-               err = fq_resize(q, q->fq_trees_log);
+               err = fq_resize(sch, q->fq_trees_log);
 
        return err;
 }


Patches currently in stable-queue which might be from [email protected] are

queue-3.13/tcp-fix-get_timewait4_sock-delay-computation-on-64bit.patch
queue-3.13/inet-frag-make-sure-forced-eviction-removes-all.patch
queue-3.13/tcp-tcp_release_cb-should-release-socket-ownership.patch
queue-3.13/pkt_sched-fq-do-not-hold-qdisc-lock-while-allocating.patch
queue-3.13/net-unix-non-blocking-recvmsg-should-not-return.patch
queue-3.13/tcp-syncookies-do-not-use-getnstimeofday.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to