From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5056C4727C for ; Wed, 30 Sep 2020 04:46:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71CD1207C3 for ; Wed, 30 Sep 2020 04:46:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="WnoomW5k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725786AbgI3Eqf (ORCPT ); Wed, 30 Sep 2020 00:46:35 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:26090 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgI3Eqf (ORCPT ); Wed, 30 Sep 2020 00:46:35 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1601441194; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=A3rhz6VOuxhz1gApk6ziXDpUvE+cY9p88hAOu1BpWd4=; b=WnoomW5k/3nqtkHcT/PooTTNyeHrRQcRJV/F02GUdAPwb2yz6X1+gCfiszylQZK3OdYia18j gvSE80P5Ocw/YG0eqDIlrpnC/CCF7vKilHbmYwqlaha7OWRmx/1DqjegmsSs3GS9IQkLVdwX O2OaAFcdjsBbElPLGoxBDQ4OG2w= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI3ZjU0NiIsICJsaW51eC1tZWRpYUB2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5f740da019fe605f25eb03f4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 30 Sep 2020 04:46:24 GMT Sender: cgoldswo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 35D6DC43385; Wed, 30 Sep 2020 04:46:24 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cgoldswo) by smtp.codeaurora.org (Postfix) with ESMTPSA id BAD36C433C8; Wed, 30 Sep 2020 04:46:22 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 29 Sep 2020 21:46:22 -0700 From: Chris Goldsworthy To: John Stultz Cc: lkml , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [RFC][PATCH 5/6] dma-buf: system_heap: Add pagepool support to system heap In-Reply-To: <20200926042453.67517-6-john.stultz@linaro.org> References: <20200926042453.67517-1-john.stultz@linaro.org> <20200926042453.67517-6-john.stultz@linaro.org> Message-ID: <1e109a138c86be7b06e20cb30a243fc7@codeaurora.org> X-Sender: cgoldswo@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On 2020-09-25 21:24, John Stultz wrote: > Reuse/abuse the pagepool code from the network code to speed > up allocation performance. > > This is similar to the ION pagepool usage, but tries to > utilize generic code instead of a custom implementation. > > Cc: Sumit Semwal > Cc: Liam Mark > Cc: Laura Abbott > Cc: Brian Starkey > Cc: Hridya Valsaraju > Cc: Suren Baghdasaryan > Cc: Sandeep Patil > Cc: Ørjan Eide > Cc: Robin Murphy > Cc: Ezequiel Garcia > Cc: Simon Ser > Cc: James Jones > Cc: linux-media@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: John Stultz > --- > drivers/dma-buf/heaps/Kconfig | 1 + > drivers/dma-buf/heaps/system_heap.c | 32 +++++++++++++++++++++++++---- > 2 files changed, 29 insertions(+), 4 deletions(-) > > diff --git a/drivers/dma-buf/heaps/Kconfig > b/drivers/dma-buf/heaps/Kconfig > index a5eef06c4226..f13cde4321b1 100644 > --- a/drivers/dma-buf/heaps/Kconfig > +++ b/drivers/dma-buf/heaps/Kconfig > @@ -1,6 +1,7 @@ > config DMABUF_HEAPS_SYSTEM > bool "DMA-BUF System Heap" > depends on DMABUF_HEAPS > + select PAGE_POOL > help > Choose this option to enable the system dmabuf heap. The system > heap > is backed by pages from the buddy allocator. If in doubt, say Y. > diff --git a/drivers/dma-buf/heaps/system_heap.c > b/drivers/dma-buf/heaps/system_heap.c > index 882a632e9bb7..9f57b4c8ae69 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > struct dma_heap *sys_heap; > > @@ -46,6 +47,7 @@ struct dma_heap_attachment { > static gfp_t order_flags[] = {HIGH_ORDER_GFP, LOW_ORDER_GFP, > LOW_ORDER_GFP}; > static const unsigned int orders[] = {8, 4, 0}; > #define NUM_ORDERS ARRAY_SIZE(orders) > +struct page_pool *pools[NUM_ORDERS]; > > static struct sg_table *dup_sg_table(struct sg_table *table) > { > @@ -264,13 +266,17 @@ static void system_heap_dma_buf_release(struct > dma_buf *dmabuf) > struct system_heap_buffer *buffer = dmabuf->priv; > struct sg_table *table; > struct scatterlist *sg; > - int i; > + int i, j; > > table = &buffer->sg_table; > for_each_sg(table->sgl, sg, table->nents, i) { > struct page *page = sg_page(sg); > > - __free_pages(page, compound_order(page)); > + for (j = 0; j < NUM_ORDERS; j++) { > + if (compound_order(page) == orders[j]) > + break; > + } > + page_pool_put_full_page(pools[j], page, false); > } > sg_free_table(table); > kfree(buffer); > @@ -300,8 +306,7 @@ static struct page > *alloc_largest_available(unsigned long size, > continue; > if (max_order < orders[i]) > continue; > - > - page = alloc_pages(order_flags[i], orders[i]); > + page = page_pool_alloc_pages(pools[i], order_flags[i]); > if (!page) > continue; > return page; > @@ -406,6 +411,25 @@ static const struct dma_heap_ops system_heap_ops = > { > static int system_heap_create(void) > { > struct dma_heap_export_info exp_info; > + int i; > + > + for (i = 0; i < NUM_ORDERS; i++) { > + struct page_pool_params pp; > + > + memset(&pp, 0, sizeof(pp)); > + pp.order = orders[i]; > + pp.dma_dir = DMA_BIDIRECTIONAL; > + pools[i] = page_pool_create(&pp); > + > + if (IS_ERR(pools[i])) { > + int j; > + > + pr_err("%s: page pool creation failed!\n", __func__); > + for (j = 0; j < i; j++) > + page_pool_destroy(pools[j]); > + return PTR_ERR(pools[i]); > + } > + } > > exp_info.name = "system"; > exp_info.ops = &system_heap_ops; This is cool, I didn't know about this pooling code under /net/core. Nice and compact. -- The Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project