[RFC,v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap
Message ID | 20240603114008.16235-1-hailong.liu@oppo.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers |
Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <linux-media+bounces-12454-patchwork=linuxtv.org@vger.kernel.org>) id 1sE63g-0005bS-1r for patchwork@linuxtv.org; Mon, 03 Jun 2024 11:41:02 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 18DEF1F25D70 for <patchwork@linuxtv.org>; Mon, 3 Jun 2024 11:40:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2022284D23; Mon, 3 Jun 2024 11:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="Q/DFzWx5" X-Original-To: linux-media@vger.kernel.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2068.outbound.protection.outlook.com [40.107.255.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B934B84D05; Mon, 3 Jun 2024 11:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414852; cv=fail; b=B0AJdcmIwEJTKqkL5iLGxM8KqvABc9wIz9IICiN5UBvIfdWeAssEsabW3FQH6hXRiQdWC1G0QAtLdAxh2mmwrnQxWe5Y9nomWq/V/0VD8KSNq9EKe73czcxXlpWUk+2E0HL+kdIoLf6z68UfnEPl9p/seKZXKAUb/VUUK4Oh38s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414852; c=relaxed/simple; bh=VWQXlrWaqgeWJGNJEQGyrWGp5OBw+8/CihEgW72KAz4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ShqrdDxPecjpB/umzCqc9ylLLkXhwhlZIaS2b1QHyJRONaXRkvcTmTwso+pBpZu6IDIflZ1XVPi/ER2rSMMmG1ONyevZWcw5A09yDy09cPuStIBiofrb7sd6YEz8ntEXJj+o+l0+J9bDOpdfT/j9kUBkc8CkV2jd+9ntkl41SlE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com; spf=pass smtp.mailfrom=oppo.com; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b=Q/DFzWx5; arc=fail smtp.client-ip=40.107.255.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oppo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReHEXSbxPFaj32VjD0sHxhn8+d/MfQniPC1YN6ycckO/K/OEiWTb4ulgRLGx6InKHs7Df9m1CpCzrr6fwpamT6qndDKEsST5jj8M8mYQzvZlfgSrxS3nTM2h+urmwUDujOwnFs575Mx4FEtWwJIbfjITO08QFEDY/9qP99/po+ZUScJlqHQ6PvfWgnP9L8F3O/FQx8+lvo8hATcnAHmbPuE5G7tHPlGMUc63B4Y5coHTmiwA2XaFrTnMwlqNQWHflf6aTbFek+6GxaQkqbU+TF9U9wx9vTp5YNxIJ6q9GVrodZwUOjaO79/ABt+j+WAFj6ecRAMI2o84N850CF5Akg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yoIM7lC3W2CmzRv5ldHqXT4NLmee7//rWVqgOuxoapU=; b=Jn15r9SryYqAxsdKhMpvALdBExiIthl5c33WVxb1sPy1iESS04xLXbtZO1KWXgk4XDlffdMY28jomNx/Lv4f9ji468zGQl6yMAiOM+46mTD8kVEz+nbcGY+82t4cD02EEJtj3ZyzFuNpTbcVKHz9sVYK5x3IbTsecarccnygVTCgnBl55tyWbSWdrl5iL+iLQzk62oMbKsFPvzD2Ulwsekdhm71PcLvnMnISW1gvIwnBLLlSOerM0lfwLOybLezJpWKewrFmqfxfvr9jfrXYAHm5mXFapY/Mxphpt0EhWj0jO7PJhteYfCgUilbcJrrXgboTyJ2ru/jclq9OS/f7QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=linaro.org smtp.mailfrom=oppo.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=oppo.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yoIM7lC3W2CmzRv5ldHqXT4NLmee7//rWVqgOuxoapU=; b=Q/DFzWx5bafjt7/E5pgCq7hcJYc0Dy/FvJe2pjgmDvQzqPkMyJ9Pm3Il9K3RNuHejcR4bUsfO0VyqKT54T6aUGEMWcQ6cq5i4WTTnlV2yMuYz0irHWlkor3g/7kGDTfcf8Fgw7dZiFJhB/LiwvzLCDq8mydg7WvgvFv6musvTgs= Received: from SG2PR01CA0134.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::14) by TY0PR02MB6803.apcprd02.prod.outlook.com (2603:1096:405:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.23; Mon, 3 Jun 2024 11:40:47 +0000 Received: from SG2PEPF000B66D0.apcprd03.prod.outlook.com (2603:1096:4:8f:cafe::60) by SG2PR01CA0134.outlook.office365.com (2603:1096:4:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.29 via Frontend Transport; Mon, 3 Jun 2024 11:40:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 58.252.5.68) smtp.mailfrom=oppo.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=oppo.com; Received-SPF: Pass (protection.outlook.com: domain of oppo.com designates 58.252.5.68 as permitted sender) receiver=protection.outlook.com; client-ip=58.252.5.68; helo=mail.oppo.com; pr=C Received: from mail.oppo.com (58.252.5.68) by SG2PEPF000B66D0.mail.protection.outlook.com (10.167.240.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 11:40:46 +0000 Received: from PH80250894.adc.com (172.16.40.118) by mailappw31.adc.com (172.16.56.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 3 Jun 2024 19:40:46 +0800 From: <hailong.liu@oppo.com> To: Sumit Semwal <sumit.semwal@linaro.org>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Brian Starkey <Brian.Starkey@arm.com>, John Stultz <jstultz@google.com>, "T.J. Mercier" <tjmercier@google.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com> CC: <21cnbao@gmail.com>, Hailong.Liu <hailong.liu@oppo.com>, <linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>, <linaro-mm-sig@lists.linaro.org>, <linux-kernel@vger.kernel.org> Subject: [RFC PATCH v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap Date: Mon, 3 Jun 2024 19:40:05 +0800 Message-ID: <20240603114008.16235-1-hailong.liu@oppo.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: <linux-media.vger.kernel.org> List-Subscribe: <mailto:linux-media+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-media+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: mailappw31.adc.com (172.16.56.198) To mailappw31.adc.com (172.16.56.198) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PEPF000B66D0:EE_|TY0PR02MB6803:EE_ X-MS-Office365-Filtering-Correlation-Id: 586d08e1-1f6f-4a70-f977-08dc83c2029d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AgVuV+1NbMK0sdGnbqwjVGvePgkefL0?= =?utf-8?q?qnUPnuCBIirYKtmy6AwlxQKrVF2yUgpP3Y11xLgUB7uQU2Tx9CjKuUvPmbcj+gmSp?= =?utf-8?q?8QkkJTRmtNjpqie44haIXpJd2uUQs9HPNuhxq0+RF2IyendV4EtwLlWLQX0ZC5Jy8?= =?utf-8?q?158SfoYahm4Yqo/rg09gCvV7AKDj/vOs7Fs7//hywCLe656L6OPmpKvmCU2K8Ves/?= =?utf-8?q?10HRVpFMgCSofjKJ88wsZ2otAtWkC28yOXKColxVlaBZSk36nrNB6X0JUoKbfJ+kw?= =?utf-8?q?imFovbhl6IlWk7gPAQj+PXF/aPBaEkOwFAwqi4A+zYh9fe1D4fkYH7gds4C+8apD+?= =?utf-8?q?aTm8HJUdBI7d5ExN9HA/UmpWnO2wiBmsO8rLyGOxLGCMjQleGqzCDwjCj6XKXddpS?= =?utf-8?q?jEDJQigyJU6Y7fT64MJFCzShERapTP4v+UZghm95hYtIRVOjmAsc22roEi/gR1/Ku?= =?utf-8?q?qaCNjb0ncuDskI8SqOwaRS23aJvT7kjnya20U+Qp008Nw2EeBZviIu45hf7Pc1F7f?= =?utf-8?q?btpJ9alQOiqyJL+MLA598EQW/wsbfFgQjVKbBcmzFA1q+SS9jcw3BzPEtEGSmERHx?= =?utf-8?q?v+JYtEN1oRcEj78QnFTjQAOUfoTJ2fBgzlQSjikf493gtwAR9zHkVNAFhHiud25vb?= =?utf-8?q?zYXw0dYKb8ihiKfPowSlMQg52CaTWNeUr0LB7WzWQd5LifmaxzxetDHvmK+mlGxUZ?= =?utf-8?q?5MeKCutzFrlPOhv7vyYaB72PeVf10dDaAql8uJcJ29o5KsX/QcwaP7wEsKLKCczdn?= =?utf-8?q?PgW8v5PhUJFvGZQCEgrhhVaE/N5dnjAI5+R09yfIVGA3SElZN/DNi5n3dAgWZoqmY?= =?utf-8?q?4S3ytwEiZHK4sBxQii6robp+8vu5s7s8KPrnYBLPr3shTbIGru0x+lcdMflWqD9eh?= =?utf-8?q?gZ/1vIqJDVUhiV1n07BthoJhOO4RB0+AKqeHFopx+4L5LoZvSwBDnqsG9nw6ZdpO2?= =?utf-8?q?Z1l0qQp9NkXy6i+B13moCtI/F1YWG6cv+suIP4DnHum7+pPMg0eHr0gAjjozFlLuR?= =?utf-8?q?aCkQIDrzOskDlmewVxw0C4sD0WqdEsBdcH9evxsVc/rIcOGDEl1oPzXdn/i6ur+Dk?= =?utf-8?q?9kUPhxJuLwhbJE3taCkTerylbKqEakbly4tIx2Y2ulP+FJ+jolysZsmZYu44lkdtT?= =?utf-8?q?azkZxahWIo2MOtz9YHSNzdyZcd4Qd83yhAs1UGSZg0yjITslkjmtKh32TOe+jQZnI?= =?utf-8?q?sJQdAIqWiHla50Q79Solm/po/wGN1chRPAW63SIU0X2vJcTEfNu6ILEgCE8t/tZUn?= =?utf-8?q?4L0j1lhZswCB88Lsn30/bvDUYjiiTlDWXPDFfr7+t3ye0M1BBkJTbau0pOVqj9eo7?= =?utf-8?q?zoKTe01c9Hr9?= X-Forefront-Antispam-Report: CIP:58.252.5.68;CTRY:CN;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.oppo.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 11:40:46.9475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 586d08e1-1f6f-4a70-f977-08dc83c2029d X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f1905eb1-c353-41c5-9516-62b4a54b5ee6;Ip=[58.252.5.68];Helo=[mail.oppo.com] X-MS-Exchange-CrossTenant-AuthSource: SG2PEPF000B66D0.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR02MB6803 X-LSpam-Score: -2.6 (--) X-LSpam-Report: No, score=-2.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no |
Series |
[RFC,v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap
|
|
Commit Message
Hailong Liu
June 3, 2024, 11:40 a.m. UTC
From: "Hailong.Liu" <hailong.liu@oppo.com> This help module use heap_flags to determine the type of dma-buf, so that some mechanisms can be used to speed up allocation, such as memory_pool, to optimize the allocation time of dma-buf. Signed-off-by: Hailong.Liu <hailong.liu@oppo.com> --- drivers/dma-buf/dma-heap.c | 3 --- drivers/dma-buf/heaps/cma_heap.c | 3 +++ drivers/dma-buf/heaps/system_heap.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) --- In fact, there are many differences between the main Linux code and Android code, I’m not sure if it’s appropriate to submit here. -- 2.34.1
Comments
On Mon, Jun 3, 2024 at 4:40 AM <hailong.liu@oppo.com> wrote: > > From: "Hailong.Liu" <hailong.liu@oppo.com> > > This help module use heap_flags to determine the type of dma-buf, > so that some mechanisms can be used to speed up allocation, such as > memory_pool, to optimize the allocation time of dma-buf. This feels like it's trying to introduce heap specific flags, but doesn't introduce any details about what those flags might be? This seems like it would re-allow the old opaque vendor specific heap flags that we saw in the ION days, which was problematic as different userspaces would use the same interface with potentially colliding heap flags with different meanings. Resulting in no way to properly move to an upstream solution. With the dma-heaps interface, we're trying to make sure it is well defined. One can register a number of heaps with different behaviors, and the heap name is used to differentiate the behavior. Any flags introduced will need to be well defined and behaviorally consistent between heaps. That way when an upstream solution lands, if necessary we can provide backwards compatibility via symlinks. So I don't think this is a good direction to go for dma-heaps. It would be better if you were able to clarify what flag requirements you need, so we can better understand how they might apply to other heaps, and see if it was something we would want to define as a flag (see the discussion here for similar thoughts: https://lore.kernel.org/lkml/CANDhNCoOKwtpstFE2VDcUvzdXUWkZ-Zx+fz6xrdPWTyciVXMXQ@mail.gmail.com/ ) But if your vendor heap really needs some sort of flags argument that you can't generalize, you can always implement your own dmabuf exporter driver with whatever ioctl interface you'd prefer. thanks -john
On Mon, 03. Jun 09:01, John Stultz wrote: > On Mon, Jun 3, 2024 at 4:40 AM <hailong.liu@oppo.com> wrote: > > > > From: "Hailong.Liu" <hailong.liu@oppo.com> > > > > This help module use heap_flags to determine the type of dma-buf, > > so that some mechanisms can be used to speed up allocation, such as > > memory_pool, to optimize the allocation time of dma-buf. > > This feels like it's trying to introduce heap specific flags, but > doesn't introduce any details about what those flags might be? > > This seems like it would re-allow the old opaque vendor specific heap > flags that we saw in the ION days, which was problematic as different > userspaces would use the same interface with potentially colliding > heap flags with different meanings. Resulting in no way to properly > move to an upstream solution. > > With the dma-heaps interface, we're trying to make sure it is well > defined. One can register a number of heaps with different behaviors, > and the heap name is used to differentiate the behavior. Any flags > introduced will need to be well defined and behaviorally consistent > between heaps. That way when an upstream solution lands, if necessary > we can provide backwards compatibility via symlinks. > > So I don't think this is a good direction to go for dma-heaps. > > It would be better if you were able to clarify what flag requirements > you need, so we can better understand how they might apply to other > heaps, and see if it was something we would want to define as a flag > (see the discussion here for similar thoughts: > https://lore.kernel.org/lkml/CANDhNCoOKwtpstFE2VDcUvzdXUWkZ-Zx+fz6xrdPWTyciVXMXQ@mail.gmail.com/ > ) > > But if your vendor heap really needs some sort of flags argument that > you can't generalize, you can always implement your own dmabuf > exporter driver with whatever ioctl interface you'd prefer. Thanks for your reply. Let’s continue our discussion here instead of on android-review. We aim to enhance memory allocation on each all heaps. Your pointer towards heap_flags used in /dev/ion for heap identification was helpful. We now aim to improve priority dma-buf allocation. Consider android animations scene: when device is in low memory, Allocating dma-buf as animation buffers enter direct_reclaimation, longer allocation time result in a laggy UI. But if we know the usage of the dma-buf, we can use some mechanisms to boost, e.g. animation-memory-pool. However, dma-buf usage identification becomes a challenge. A potential solution could be heap_flags. the use of heap_flags seems ugly and contrary to the intended design as you said, How aboult extending dma_heap_allocation_data as follows? struct dma_heap_allocation_data { __u64 len; __u32 fd; __u32 fd_flags; __u64 heap_flags; __u64 buf_flags: // buf usage }; Do you have any better suggestion? > > thanks > -john -- Best Regards, Hailong.
On Mon, Jun 3, 2024 at 10:21 AM Hailong Liu <hailong.liu@oppo.com> wrote: > On Mon, 03. Jun 09:01, John Stultz wrote: > > On Mon, Jun 3, 2024 at 4:40 AM <hailong.liu@oppo.com> wrote: > > > > > > From: "Hailong.Liu" <hailong.liu@oppo.com> > > > > > > This help module use heap_flags to determine the type of dma-buf, > > > so that some mechanisms can be used to speed up allocation, such as > > > memory_pool, to optimize the allocation time of dma-buf. > > > > This feels like it's trying to introduce heap specific flags, but > > doesn't introduce any details about what those flags might be? > > > > This seems like it would re-allow the old opaque vendor specific heap > > flags that we saw in the ION days, which was problematic as different > > userspaces would use the same interface with potentially colliding > > heap flags with different meanings. Resulting in no way to properly > > move to an upstream solution. > > > > With the dma-heaps interface, we're trying to make sure it is well > > defined. One can register a number of heaps with different behaviors, > > and the heap name is used to differentiate the behavior. Any flags > > introduced will need to be well defined and behaviorally consistent > > between heaps. That way when an upstream solution lands, if necessary > > we can provide backwards compatibility via symlinks. > > > > So I don't think this is a good direction to go for dma-heaps. > > > > It would be better if you were able to clarify what flag requirements > > you need, so we can better understand how they might apply to other > > heaps, and see if it was something we would want to define as a flag > > (see the discussion here for similar thoughts: > > https://lore.kernel.org/lkml/CANDhNCoOKwtpstFE2VDcUvzdXUWkZ-Zx+fz6xrdPWTyciVXMXQ@mail.gmail.com/ > > ) > > > > But if your vendor heap really needs some sort of flags argument that > > you can't generalize, you can always implement your own dmabuf > > exporter driver with whatever ioctl interface you'd prefer. > > Thanks for your reply. Let’s continue our discussion here instead > of on android-review. We aim to enhance memory allocation on each > all heaps. Your pointer towards heap_flags used in /dev/ion for heap > identification was helpful. > > We now aim to improve priority dma-buf allocation. Consider android > animations scene: > > when device is in low memory, Allocating dma-buf as animation > buffers enter direct_reclaimation, longer allocation time result in a > laggy UI. But if we know the usage of the dma-buf, we can use some > mechanisms to boost, e.g. animation-memory-pool. Can you generalize this a bit further? When would userland know to use this new flag? If it is aware, would it make sense to just use a separate heap name instead? (Also: These other mechanisms you mention should probably also be submitted upstream, however for upstream there's also the requirement that we have open users and are not just enabling proprietary blob userspace, which makes any changes to dma-buf heaps for out of tree code quite difficult) > However, dma-buf usage identification becomes a challenge. A potential > solution could be heap_flags. the use of heap_flags seems ugly and > contrary to the intended design as you said, How aboult extending > dma_heap_allocation_data as follows? > > struct dma_heap_allocation_data { > __u64 len; > __u32 fd; > __u32 fd_flags; > __u64 heap_flags; > __u64 buf_flags: // buf usage > }; This would affect the ABI (forcing a new ioctl number). And it's unclear what flags you envision as buffer specific (rather than heap specific as this patch suggested). I think we need more details about the specific problem you're seeing and trying to resolve. thanks -john
On 6/4/2024 2:06 AM, John Stultz wrote: > On Mon, Jun 3, 2024 at 10:21 AM Hailong Liu <hailong.liu@oppo.com> wrote: >> On Mon, 03. Jun 09:01, John Stultz wrote: >>> On Mon, Jun 3, 2024 at 4:40 AM <hailong.liu@oppo.com> wrote: >>>> >>>> From: "Hailong.Liu" <hailong.liu@oppo.com> >>>> >>>> This help module use heap_flags to determine the type of dma-buf, >>>> so that some mechanisms can be used to speed up allocation, such as >>>> memory_pool, to optimize the allocation time of dma-buf. >>> >>> This feels like it's trying to introduce heap specific flags, but >>> doesn't introduce any details about what those flags might be? >>> >>> This seems like it would re-allow the old opaque vendor specific heap >>> flags that we saw in the ION days, which was problematic as different >>> userspaces would use the same interface with potentially colliding >>> heap flags with different meanings. Resulting in no way to properly >>> move to an upstream solution. >>> >>> With the dma-heaps interface, we're trying to make sure it is well >>> defined. One can register a number of heaps with different behaviors, >>> and the heap name is used to differentiate the behavior. Any flags >>> introduced will need to be well defined and behaviorally consistent >>> between heaps. That way when an upstream solution lands, if necessary >>> we can provide backwards compatibility via symlinks. >>> >>> So I don't think this is a good direction to go for dma-heaps. >>> >>> It would be better if you were able to clarify what flag requirements >>> you need, so we can better understand how they might apply to other >>> heaps, and see if it was something we would want to define as a flag >>> (see the discussion here for similar thoughts: >>> https://lore.kernel.org/lkml/CANDhNCoOKwtpstFE2VDcUvzdXUWkZ-Zx+fz6xrdPWTyciVXMXQ@mail.gmail.com/ >>> ) >>> >>> But if your vendor heap really needs some sort of flags argument that >>> you can't generalize, you can always implement your own dmabuf >>> exporter driver with whatever ioctl interface you'd prefer. >> >> Thanks for your reply. Let’s continue our discussion here instead >> of on android-review. We aim to enhance memory allocation on each >> all heaps. Your pointer towards heap_flags used in /dev/ion for heap >> identification was helpful. >> >> We now aim to improve priority dma-buf allocation. Consider android >> animations scene: >> >> when device is in low memory, Allocating dma-buf as animation >> buffers enter direct_reclaimation, longer allocation time result in a >> laggy UI. But if we know the usage of the dma-buf, we can use some >> mechanisms to boost, e.g. animation-memory-pool. > > Can you generalize this a bit further? When would userland know to use > this new flag? > If it is aware, would it make sense to just use a separate heap name instead? > > (Also: These other mechanisms you mention should probably also be > submitted upstream, however for upstream there's also the requirement > that we have open users and are not just enabling proprietary blob > userspace, which makes any changes to dma-buf heaps for out of tree > code quite difficult) > >> However, dma-buf usage identification becomes a challenge. A potential >> solution could be heap_flags. the use of heap_flags seems ugly and >> contrary to the intended design as you said, How aboult extending >> dma_heap_allocation_data as follows? >> >> struct dma_heap_allocation_data { >> __u64 len; >> __u32 fd; >> __u32 fd_flags; >> __u64 heap_flags; >> __u64 buf_flags: // buf usage >> }; > > This would affect the ABI (forcing a new ioctl number). And it's > unclear what flags you envision as buffer specific (rather than heap > specific as this patch suggested). > > I think we need more details about the specific problem you're seeing > and trying to resolve. This patch mainly focuses on optimization for Android scenarios. Let’s discuss it on the issue website. Bug: 344501512 Brs, Hailong. > > thanks > -john
On Mon, Jun 3, 2024 at 11:30 PM Hailong Liu <hailong.liu@oppo.com> wrote: > On 6/4/2024 2:06 AM, John Stultz wrote: > > On Mon, Jun 3, 2024 at 10:21 AM Hailong Liu <hailong.liu@oppo.com> wrote: > >> We now aim to improve priority dma-buf allocation. Consider android > >> animations scene: > >> > >> when device is in low memory, Allocating dma-buf as animation > >> buffers enter direct_reclaimation, longer allocation time result in a > >> laggy UI. But if we know the usage of the dma-buf, we can use some > >> mechanisms to boost, e.g. animation-memory-pool. > > > > Can you generalize this a bit further? When would userland know to use > > this new flag? > > If it is aware, would it make sense to just use a separate heap name instead? > > > > (Also: These other mechanisms you mention should probably also be > > submitted upstream, however for upstream there's also the requirement > > that we have open users and are not just enabling proprietary blob > > userspace, which makes any changes to dma-buf heaps for out of tree > > code quite difficult) > > > >> However, dma-buf usage identification becomes a challenge. A potential > >> solution could be heap_flags. the use of heap_flags seems ugly and > >> contrary to the intended design as you said, How aboult extending > >> dma_heap_allocation_data as follows? > >> > >> struct dma_heap_allocation_data { > >> __u64 len; > >> __u32 fd; > >> __u32 fd_flags; > >> __u64 heap_flags; > >> __u64 buf_flags: // buf usage > >> }; > > > > This would affect the ABI (forcing a new ioctl number). And it's > > unclear what flags you envision as buffer specific (rather than heap > > specific as this patch suggested). > > > > I think we need more details about the specific problem you're seeing > > and trying to resolve. > This patch mainly focuses on optimization for Android scenarios. Let’s > discuss it on the issue website. > Bug: 344501512 Ok, we can do that if you need. But if this is ever going to go upstream (and it's more and more important that we minimize out of tree technical debt), conversations about how to generalize this will need to happen on the list. thanks -john
On 6/4/2024 11:33 PM, John Stultz wrote: > On Mon, Jun 3, 2024 at 11:30 PM Hailong Liu <hailong.liu@oppo.com> wrote: >> On 6/4/2024 2:06 AM, John Stultz wrote: >>> On Mon, Jun 3, 2024 at 10:21 AM Hailong Liu <hailong.liu@oppo.com> wrote: >>>> We now aim to improve priority dma-buf allocation. Consider android >>>> animations scene: >>>> >>>> when device is in low memory, Allocating dma-buf as animation >>>> buffers enter direct_reclaimation, longer allocation time result in a >>>> laggy UI. But if we know the usage of the dma-buf, we can use some >>>> mechanisms to boost, e.g. animation-memory-pool. >>> >>> Can you generalize this a bit further? When would userland know to use >>> this new flag? >>> If it is aware, would it make sense to just use a separate heap name instead? >>> >>> (Also: These other mechanisms you mention should probably also be >>> submitted upstream, however for upstream there's also the requirement >>> that we have open users and are not just enabling proprietary blob >>> userspace, which makes any changes to dma-buf heaps for out of tree >>> code quite difficult) >>> >>>> However, dma-buf usage identification becomes a challenge. A potential >>>> solution could be heap_flags. the use of heap_flags seems ugly and >>>> contrary to the intended design as you said, How aboult extending >>>> dma_heap_allocation_data as follows? >>>> >>>> struct dma_heap_allocation_data { >>>> __u64 len; >>>> __u32 fd; >>>> __u32 fd_flags; >>>> __u64 heap_flags; >>>> __u64 buf_flags: // buf usage >>>> }; >>> >>> This would affect the ABI (forcing a new ioctl number). And it's >>> unclear what flags you envision as buffer specific (rather than heap >>> specific as this patch suggested). >>> >>> I think we need more details about the specific problem you're seeing >>> and trying to resolve. >> This patch mainly focuses on optimization for Android scenarios. Let’s >> discuss it on the issue website. >> Bug: 344501512 > > Ok, we can do that if you need. > > But if this is ever going to go upstream (and it's more and more > important that we minimize out of tree technical debt), conversations > about how to generalize this will need to happen on the list. > We need a more complete design and test results to convince upstream to accept. Thank you again for your suggestion. Brs, Hailong. > thanks > -john
diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 84ae708fafe7..6c78ee6c7a58 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -105,9 +105,6 @@ static long dma_heap_ioctl_allocate(struct file *file, void *data) if (heap_allocation->fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) return -EINVAL; - if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) - return -EINVAL; - fd = dma_heap_buffer_alloc(heap, heap_allocation->len, heap_allocation->fd_flags, heap_allocation->heap_flags); diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 4a63567e93ba..ae4fa974372b 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -288,6 +288,9 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap, int ret = -ENOMEM; pgoff_t pg; + if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) + return ERR_PTR(-EINVAL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 9076d47ed2ef..80858719a819 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -347,6 +347,9 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap, struct page *page, *tmp_page; int i, ret = -ENOMEM; + if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) + return ERR_PTR(-EINVAL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM);