Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4292518pxk; Tue, 29 Sep 2020 21:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi/zKIgLLyeqFHUG32i7Ed0HE1/L/nAn5qTc5TpgDAPgtPeMxbl7DtC6fSFiiCOPBxn/M2 X-Received: by 2002:a50:8fa3:: with SMTP id y32mr847587edy.78.1601441343902; Tue, 29 Sep 2020 21:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601441343; cv=none; d=google.com; s=arc-20160816; b=n+aLk20s7Sc+f6GD9/CN/jbRzKqGUhoRHW+4JhIfNq2/roGVX33Wh82EwRsWH0rzIX VsaZ7vIspUrH8KPP0O8QlK50cfg7nqsf38saZiAMIFGqqmZXOrP8hc7VNy5bzmSsHkqA VnHeKTNAO7OaSOaQtTSo5NO4ZREivy2mrxEty8Kevc83f0LsKXT37Fj9xMky2gRLDp4H d6mxUe7ZgNxFttMDFajNEohXiniHSc+kHJ2kd2met7iIfvEvLZIaXTO9an/WjjBrLXuY NWHjeeeTv7MqW6HgP4Gq260/bb6IhT8g3vloRds8sIejj786BfCjMZC400AvGFGUOZLn 0WHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=A3rhz6VOuxhz1gApk6ziXDpUvE+cY9p88hAOu1BpWd4=; b=HxEU9Z4wCWe+mV/Y+SBsu26BM9FTEAXXvYWtglkc4TxfsZY6qH0pfOONljvuYIO9M7 KF/0yCY2BekdWd5l9mtB3NH/SaMP8y/D19wrcJFE+V9umlsdAH+Q37W8bdZpDPQkIzWJ vKGxqmsmIir/zMcYVhS0BhZBtgyiGhKgyI6kydCu5mh3e5d+BCJqc4gNY55j1xftcO+R ILcYd+QsrLnXH3Xya079373viMpOh6QZmHTbZ1FrQFGZcYbH2hBrVX5n5h+aLFc3JFsJ 2tTj4+nlh4vJFq8OaEPyEx6YuouaNjk+h/r91TXQxgLde8KYWTCeTzQ3evU2SVj/UU1F VoiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=BcoJJZkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si267610edb.1.2020.09.29.21.48.40; Tue, 29 Sep 2020 21:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=BcoJJZkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725800AbgI3Eqh (ORCPT + 99 others); Wed, 30 Sep 2020 00:46:37 -0400 Received: from z5.mailgun.us ([104.130.96.5]:10627 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgI3Eqh (ORCPT ); Wed, 30 Sep 2020 00:46:37 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1601441196; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=A3rhz6VOuxhz1gApk6ziXDpUvE+cY9p88hAOu1BpWd4=; b=BcoJJZkGca/NFSIu0KGBhS/Z/93Chl++RQDTxMWoy32IwqvL4EQ4XhTSTKThPNNGW2H1JRNm Sppkx9SyWOS4ViR1IuWs2DPxojdynDLVdfY+WDxXSg0ds5Z4Aa1kJLtDp8H8SyDOthU1xL+G 09CSjf+vek8LMKmAZWl6gaQN1cU= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd 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 5f740da019fe605f25eb03f3 (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) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 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-kernel@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