From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: Re: [RFC PATCH 15/17] net: sched: pfifo_fast use skb_array Date: Wed, 15 Nov 2017 06:57:40 -0800 Message-ID: References: <20171113195256.6245.64676.stgit@john-Precision-Tower-5810> <20171113201235.6245.4870.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Daniel Borkmann , Eric Dumazet , make0818@gmail.com, Network Development , =?UTF-8?B?SmnFmcOtIFDDrXJr?= =?UTF-8?Q?o?= , Cong Wang To: Willem de Bruijn Return-path: Received: from mail-pg0-f41.google.com ([74.125.83.41]:46991 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757190AbdKOO6I (ORCPT ); Wed, 15 Nov 2017 09:58:08 -0500 Received: by mail-pg0-f41.google.com with SMTP id t10so17160287pgo.3 for ; Wed, 15 Nov 2017 06:58:07 -0800 (PST) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: [...] >> static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb) >> @@ -685,17 +688,40 @@ static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb) >> >> static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt) >> { >> - int prio; >> + unsigned int qlen = qdisc_dev(qdisc)->tx_queue_len; >> struct pfifo_fast_priv *priv = qdisc_priv(qdisc); >> + int prio; >> + >> + /* guard against zero length rings */ >> + if (!qlen) >> + return -EINVAL; >> >> - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) >> - qdisc_skb_head_init(band2list(priv, prio)); >> + for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) { >> + struct skb_array *q = band2list(priv, prio); >> + int err; >> + >> + err = skb_array_init(q, qlen, GFP_KERNEL); >> + if (err) >> + return -ENOMEM; > > This relies on the caller calling ops->destroy on error to free partially > allocated state. For uninitialized bands, that calls spin_lock on an > uninitialized spinlock from skb_array_cleanup -> ptr_ring_cleanup -> > ptr_ring_consume. Nice catch will fix in next version. And also make above suggested changes. Thanks, John.