From patchwork Fri Aug 6 19:35:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 61137 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7624FB70A8 for ; Sat, 7 Aug 2010 05:38:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761976Ab0HFTiM (ORCPT ); Fri, 6 Aug 2010 15:38:12 -0400 Received: from suva.vyatta.com ([76.74.103.44]:35715 "EHLO suva.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761959Ab0HFTiE (ORCPT ); Fri, 6 Aug 2010 15:38:04 -0400 Received: from suva.vyatta.com (suva [127.0.0.1]) by suva.vyatta.com (8.13.7/8.13.7) with ESMTP id o76Jbw1h022341; Fri, 6 Aug 2010 12:37:58 -0700 Received: (from shemminger@localhost) by suva.vyatta.com (8.13.7/8.13.7/Submit) id o76JbwrF022340; Fri, 6 Aug 2010 12:37:58 -0700 Message-Id: <20100806193559.022225705@vyatta.com> User-Agent: quilt/0.48-1 Date: Fri, 06 Aug 2010 12:35:54 -0700 From: Stephen Hemminger To: David Miller Cc: netdev@vger.kernel.org Subject: [PATCH 6/9] netem: distribution table changes References: <20100806193548.007978639@vyatta.com> Content-Disposition: inline; filename=netem-dist-vmalloc.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 --- 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)