[RFC PATCH] drm/i915/gvt: Try cma allocation first for oos page setup
Zhenyu Wang
zhenyuw at linux.intel.com
Wed Jan 30 03:00:42 UTC 2019
On 2019.01.28 11:53:05 +0800, Feng Tang wrote:
> Hi Yakui,
>
> Thanks for the review!
>
> On Mon, Jan 28, 2019 at 11:28:28AM +0800, Zhao, Yakui wrote:
> >
> >
> > >-----Original Message-----
> > >From: intel-gvt-dev [mailto:intel-gvt-dev-bounces at lists.freedesktop.org] On
> > >Behalf Of Feng Tang
> > >Sent: Monday, January 28, 2019 10:46 AM
> > >To: intel-gvt-dev at lists.freedesktop.org; Zhenyu Wang
> > ><zhenyuw at linux.intel.com>; Wang, Zhi A <zhi.a.wang at intel.com>; Xiao
> > >Zheng <xiao.zheng at intel.com>; He, Min <min.he at intel.com>; Bing Niu
> > ><bing.niu at intel.com>
> > >Cc: Tang, Feng <feng.tang at intel.com>
> > >Subject: [RFC PATCH] drm/i915/gvt: Try cma allocation first for oos page setup
> > >
> > >When doing boottime profiling, we found the oos page setup takes about
> > >25~30 ms, while using cma allocation takes less than 10 ms. And if the
> > >preallocated_oos_pages increases in future, it will save more.
> > >
> > >This commit will try to allocate the memory from CMA first, and fall back to
> > >the original kzalloc if CMA is not available.
> > >
> > >Signed-off-by: Feng Tang <feng.tang at intel.com>
> > >---
> > > drivers/gpu/drm/i915/gvt/gtt.c | 26 +++++++++++++++++++++-----
> > > 1 file changed, 21 insertions(+), 5 deletions(-)
> > >
> > >diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
> > >index c7103dd..e8d6f10 100644
> > >--- a/drivers/gpu/drm/i915/gvt/gtt.c
> > >+++ b/drivers/gpu/drm/i915/gvt/gtt.c
> > >@@ -2496,18 +2496,34 @@ static void clean_spt_oos(struct intel_gvt *gvt)
> > >static int setup_spt_oos(struct intel_gvt *gvt) {
> > > struct intel_gvt_gtt *gtt = &gvt->gtt;
> > >- struct intel_vgpu_oos_page *oos_page;
> > >+ struct intel_vgpu_oos_page *oos_page, *oos_page_base;
> > >+ struct page *cma_page;
> > >+ int npages;
> > > int i;
> > > int ret;
> > >
> > > INIT_LIST_HEAD(>t->oos_page_free_list_head);
> > > INIT_LIST_HEAD(>t->oos_page_use_list_head);
> > >
> > >+ /* Try cma allocation first to save setup time */
> > >+ npages = preallocated_oos_pages * sizeof(*oos_page);
> > >+ npages = DIV_ROUND_UP(npages, PAGE_SIZE);
> > >+
> > >+ cma_page = dma_alloc_from_contiguous(NULL, npages, 1, TRUE);
> > >+ if (cma_page) {
> > >+ oos_page_base = page_address(cma_page);
> > >+ memset(oos_page_base, 0, npages << PAGE_SHIFT);
> > >+ }
> > >+
> >
> > Currently it will try to call kzalloc for 8192 times.
> > So can we firstly use the kcalloc to allocate the memory for all the *oos_page and
> > then initialize the oos_page list?
>
> One concern with this is the size of the oos memory is about 33M, while kmalloc
> may not be able to allocate so big a block (MAX_ORDER is about 11, which is 8MB).
>
> Another question is if the kzalloc is necessary for this setup, while kmalloc
> will consume much less time.
>
> >
> > For the CMA: we need to reserve some regions for CMA. This is not recommended.
> This cma allocation is a one-time deal in boot phase, which should be fine. Also
> for platform with no cma explicitly allocated, this is a nop.
>
So I don't think we should depend on possible special cma config for benefit,
we should have solution in normal case. But currently GVT doesn't use oos page
actually, so better just skip all those setup now, would you send a patch for that?
btw, oos code seems pretty lame, surely need to rework if we'd really like to
use it, otherwise may just remove.
thanks
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20190130/4444761d/attachment.sig>
More information about the intel-gvt-dev
mailing list