Messages in this thread | | | Date | Fri, 30 Aug 2019 00:00:58 +0200 | From | Thomas Bogendoerfer <> | Subject | Re: [PATCH v2 net-next 05/15] net: sgi: ioc3-eth: allocate space for desc rings only once |
| |
On Thu, 29 Aug 2019 14:05:37 -0700 Jakub Kicinski <jakub.kicinski@netronome.com> wrote:
> On Thu, 29 Aug 2019 17:50:03 +0200, Thomas Bogendoerfer wrote: > > + if (skb) > > + dev_kfree_skb_any(skb); > > I think dev_kfree_skb_any() accepts NULL
yes, I'll drop the if
> > + > > + /* Allocate and rx ring. 4kb = 512 entries */ > > + ip->rxr = (unsigned long *)get_zeroed_page(GFP_ATOMIC); > > + if (!ip->rxr) { > > + pr_err("ioc3-eth: rx ring allocation failed\n"); > > + err = -ENOMEM; > > + goto out_stop; > > + } > > + > > + /* Allocate tx rings. 16kb = 128 bufs. */ > > + ip->txr = (struct ioc3_etxd *)__get_free_pages(GFP_KERNEL, 2); > > + if (!ip->txr) { > > + pr_err("ioc3-eth: tx ring allocation failed\n"); > > + err = -ENOMEM; > > + goto out_stop; > > + } > > Please just use kcalloc()/kmalloc_array() here,
both allocation will be replaced in patch 11 with dma_direct_alloc_pages. So I hope I don't need to change it here.
Out of curiosity does kcalloc/kmalloc_array give me the same guarantees about alignment ? rx ring needs to be 4KB aligned, tx ring 16KB aligned.
>, and make sure the flags > are set to GFP_KERNEL whenever possible. Here and in ioc3_alloc_rings() > it looks like GFP_ATOMIC is unnecessary.
yes, I'll change it
Thomas.
-- SUSE Software Solutions Germany GmbH HRB 247165 (AG München) Geschäftsführer: Felix Imendörffer
| |