[PATCHv6 7/7] ARM: dma-mapping: add support for IOMMU mapper

Arnd Bergmann arnd at arndb.de
Fri Feb 24 07:49:44 EST 2012


On Friday 24 February 2012, Marek Szyprowski wrote:
> > > +static struct page **__iommu_alloc_buffer(struct device *dev, size_t
> > > +size, gfp_t gfp) {
> > > +     struct page **pages;
> > > +     int count = size >> PAGE_SHIFT;
> > > +     int i=0;
> > > +
> > > +     pages = kzalloc(count * sizeof(struct page*), gfp);
> > > +     if (!pages)
> > > +             return NULL;
> > 
> > kzalloc can fail for any size bigger than PAGE_SIZE, if the system memory is
> > fully fragmented.
> > If there is a request for size bigger than 4MB, then the pages pointer array won't
> > Fit in one page and kzalloc may fail. we should use vzalloc()/vfree()
> > when pages pointer array size needed is bigger than PAGE_SIZE.
> 
> Right, thanks for spotting this. I will fix this in the next version.

It's not clear though if that is the best solution. vzalloc comes at the
price of using up space in the vmalloc area and as well as extra TLB entries,
so we try to limit its use where possible. The other current code might fail
in out of memory situations, but if a user wants to allocate a >4MB buffer
(using up more than one physically contiguous page of pointers to pages), the
following allocation of >1024 pages will likely fail as well, so we might
just fail early.

	Arnd



More information about the linux-arm-kernel mailing list