[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAE2F3rAvg1-jtpsJdgzmBkZ5CDnGG4S0-oVxw74LY3O+N=0JZA@mail.gmail.com>
Date: Wed, 27 Jan 2021 23:04:15 -0800
From: Daniel Mentz <danielmentz@...gle.com>
To: John Stultz <john.stultz@...aro.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Daniel Vetter <daniel@...ll.ch>,
Sumit Semwal <sumit.semwal@...aro.org>,
Liam Mark <lmark@...eaurora.org>,
Chris Goldsworthy <cgoldswo@...eaurora.org>,
Laura Abbott <labbott@...nel.org>,
Brian Starkey <Brian.Starkey@....com>,
Hridya Valsaraju <hridya@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Sandeep Patil <sspatil@...gle.com>,
Ørjan Eide <orjan.eide@....com>,
Robin Murphy <robin.murphy@....com>,
Ezequiel Garcia <ezequiel@...labora.com>,
Simon Ser <contact@...rsion.fr>,
James Jones <jajones@...dia.com>,
linux-media <linux-media@...r.kernel.org>,
dri-devel <dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH v2 2/3] dma-buf: system_heap: Add pagepool support to
system heap
On Wed, Jan 27, 2021 at 9:10 PM John Stultz <john.stultz@...aro.org> wrote:
>
> On Wed, Jan 27, 2021 at 12:21 PM Daniel Mentz <danielmentz@...gle.com> wrote:
> >
> > On Fri, Jan 22, 2021 at 7:47 PM John Stultz <john.stultz@...aro.org> wrote:
> > > +static int system_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot)
> > > +{
> > > + void *addr = vmap(pages, num, VM_MAP, pgprot);
> > > +
> > > + if (!addr)
> > > + return -ENOMEM;
> > > + memset(addr, 0, PAGE_SIZE * num);
> > > + vunmap(addr);
> > > + return 0;
> > > +}
> >
> > I thought that vmap/vunmap are expensive, and I am wondering if
> > there's a faster way that avoids vmap.
> >
> > How about lifting this code from lib/iov_iter.c
> > static void memzero_page(struct page *page, size_t offset, size_t len)
> > {
> > char *addr = kmap_atomic(page);
> > memset(addr + offset, 0, len);
> > kunmap_atomic(addr);
> > }
> >
> > Or what about lifting that code from the old ion_cma_heap.c
> >
> > if (PageHighMem(pages)) {
> > unsigned long nr_clear_pages = nr_pages;
> > struct page *page = pages;
> >
> > while (nr_clear_pages > 0) {
> > void *vaddr = kmap_atomic(page);
> >
> > memset(vaddr, 0, PAGE_SIZE);
> > kunmap_atomic(vaddr);
> > page++;
> > nr_clear_pages--;
> > }
> > } else {
> > memset(page_address(pages), 0, size);
> > }
>
> Though, this last memset only works since CMA is contiguous, so it
> probably needs to always do the kmap_atomic for each page, right?
Yeah, but with the system heap page pool, some of these pages might be
64KB or 1MB large. kmap_atomic(page) just maps to page_address(page)
in most cases. I think iterating over all pages individually in this
manner might still be faster than using vmap.
>
> I'm still a little worried if this is right, as the current
> implementation with the vmap comes from the old ion_heap_sglist_zero
> logic, which similarly tries to batch the vmaps 32 pages at at time,
> but I'll give it a try.
Powered by blists - more mailing lists