Patchwork [6/9] netem: distribution table changes

login
register
mail settings
Submitter stephen hemminger
Date Aug. 6, 2010, 7:35 p.m.
Message ID <20100806193559.022225705@vyatta.com>
Download mbox | patch
Permalink /patch/61137/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Aug. 6, 2010, 7:35 p.m.
Fix some issues with distribution table in netem:
  * Make maximum size visible to user space
  * Use vmalloc to avoid allocating large physical contiguous memory.
    (maybe this should use flex array?)

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>




--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/include/linux/pkt_sched.h	2010-08-02 16:22:42.197329627 -0700
+++ b/include/linux/pkt_sched.h	2010-08-03 08:29:43.926514463 -0700
@@ -466,6 +466,7 @@  struct tc_netem_corrupt {
 };
 
 #define NETEM_DIST_SCALE	8192
+#define NETEM_DIST_MAX		16384
 
 /* DRR */
 
--- a/net/sched/sch_netem.c	2010-08-03 08:29:39.546593787 -0700
+++ b/net/sched/sch_netem.c	2010-08-03 08:29:43.926514463 -0700
@@ -321,10 +321,10 @@  static int get_dist_table(struct Qdisc *
 	struct disttable *d;
 	int i;
 
-	if (n > 65536)
+	if (n > NETEM_DIST_MAX)
 		return -EINVAL;
 
-	d = kmalloc(sizeof(*d) + n*sizeof(d->table[0]), GFP_KERNEL);
+	d = vmalloc(sizeof(*d) + n*sizeof(d->table[0]));
 	if (!d)
 		return -ENOMEM;
 
@@ -332,7 +332,7 @@  static int get_dist_table(struct Qdisc *
 	for (i = 0; i < n; i++)
 		d->table[i] = data[i];
 
-	kfree(q->delay_dist);
+	vfree(q->delay_dist);
 	q->delay_dist = d;
 
 	return 0;
@@ -559,7 +559,7 @@  static void netem_destroy(struct Qdisc *
 
 	qdisc_watchdog_cancel(&q->watchdog);
 	qdisc_destroy(q->qdisc);
-	kfree(q->delay_dist);
+	vfree(q->delay_dist);
 }
 
 static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)