Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1111076lqj; Mon, 3 Jun 2024 10:22:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURnbfZQDLnHBgZ2KCu0lKl6ZZzyJgdZxd3Sn6cPGKBUQaoABT7s9tAjyxTSGP0O00Drx3b4Z+tNZdm75y6Uo5oawUt5PkZMOcpbud2BA== X-Google-Smtp-Source: AGHT+IHmBFYkrWO+g4HwCfE1vtY7u/sm95VRK6RCEZ0KIGGUEtP28D3D2KdfT8Qnyo/h9GIKWu6P X-Received: by 2002:a05:651c:1059:b0:2e6:be3c:9d4d with SMTP id 38308e7fff4ca-2ea9510e113mr87331501fa.12.1717435327351; Mon, 03 Jun 2024 10:22:07 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b8178bsi4211192a12.138.2024.06.03.10.22.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 10:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199503-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=ur2g7t4c; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-199503-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199503-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oppo.com 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 DB2851F233B8 for ; Mon, 3 Jun 2024 17:22:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A730F137743; Mon, 3 Jun 2024 17:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="ur2g7t4c" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2086.outbound.protection.outlook.com [40.107.255.86]) (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 B3D401366; Mon, 3 Jun 2024 17:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.86 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717435315; cv=fail; b=kqoSE+uuoSLs4rUcwNSAnMPXRtalLfSqgLOsoptHRlx3fjT73gy2Uq6SDkVmXi/Wu+YWQZrsWdPOUpejObjCX1kNC/yNRA2kamGEV7I8sKsAeYl22G8aBkzlE92TeHkcibo9I6q1ChGfn2d+vGBqIa5exlI1A5evBMQizOnuXK0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717435315; c=relaxed/simple; bh=M+6B3FJf9LMYJRsNV0UEY98hXGAb7HmQt5g62ixIPsc=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OS4tK7wmx3q/Weyq+sBymZ1pLlujwC2j5F58eeVl4u3Kc50FFzoU4uf97nVX7k/jAsHx8EFZ3pR6+KGZxyjO5iArt7B2mB/pSg3PaQs6cTscMgHZ+W2cwXgAkzh2lTw8Fus1EATYeaKVfPDV6ZVAtKY+qRumSvTAqQ+2KqIZnX4= 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=ur2g7t4c; arc=fail smtp.client-ip=40.107.255.86 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=idvHuX358MpsPkIcOtjmop/fd2jzI2fNNxMhSTx7i1G0BrmigpJG+pYamRQFX5Ly3GI/kEs4J74g0S08vYI0l81G/CrreFKTRaZnF+rCSxvLye+O4xBLroftiFyz9BEF9CmnHHCbE+Bi2c9muL88sVsgm9VGOYnOO2GCMbcwOrXMAl4tzDJWfibHOqFyS+uduftbIsviE/zXmGh6DOZ4priX5KvaNRtHzj91X+mZkwBEETx66XKMgNfDtSb60/Bt+aq2Zpy+Nb7N9a0CLB41KNPOEkJ7cKBhD11V3MftDoPPXvBUoukYW7rVl30KRoyNr++923Eun9QXyiFlK9QZbA== 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=o8IQFPnM4F3yz329uWH6fg+C6coLIJSr27xrEvHGXFk=; b=k8AbVY1yPw1KJVPXhZLWmAnHgDgAV20XlzcERXm1TC6kYPQaWjDDuuxSGBjnYIcewiCGzy9t0BbSqoNMJXa2yoptePWGbHLlF1OQsac/kAKnWf1WesHVsILC5U6kpVsqvgKCtjh2lc72FavjWBHbvyxrVk69ylpFZFJ3uCGpaZiUCVtNjS6GDkeWBBpSdUvIIOIJ3OGIQ+GNiNLdIMoZ4+EwM3shQk0ywMp7NC1KiwRnwzO7UJP1Mbwp9GtDHkFXVvhPeR2EOmLvH5CpH8RnZybbLsQ63O1aKXTlLmQauKQtlxSCYc7hkZLVTDYGkYURyr6mrjETcYVNu3NuCvDnKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=google.com 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=o8IQFPnM4F3yz329uWH6fg+C6coLIJSr27xrEvHGXFk=; b=ur2g7t4cJJocOVVxtVZuXc6wUpk55qZ4UTA5t/hZhBQGmklnO+FoO0mHHUvdFRKdLvMCQMT86dnn8wAXoQfVQOyICBo7/vwUo9NNMey8dWnmlqAWwIbKbWa3rwJ6HPx4AsCm7V5phq/jC1yKXkUZXWpXhGV4LpjZBm9MqOKmt88= Received: from SG2PR01CA0188.apcprd01.prod.exchangelabs.com (2603:1096:4:189::10) by KL1PR02MB6627.apcprd02.prod.outlook.com (2603:1096:820:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Mon, 3 Jun 2024 17:21:50 +0000 Received: from SG1PEPF000082E2.apcprd02.prod.outlook.com (2603:1096:4:189:cafe::83) by SG2PR01CA0188.outlook.office365.com (2603:1096:4:189::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Mon, 3 Jun 2024 17:21:50 +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 SG1PEPF000082E2.mail.protection.outlook.com (10.167.240.5) 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 17:21:49 +0000 Received: from oppo.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; Tue, 4 Jun 2024 01:21:49 +0800 Date: Tue, 4 Jun 2024 01:21:48 +0800 From: Hailong Liu To: John Stultz CC: Sumit Semwal , Benjamin Gaignard , Brian Starkey , "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , <21cnbao@gmail.com>, , , , Subject: Re: [RFC PATCH v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap Message-ID: <20240603172148.gb7txpg2ya43jyxn@oppo.com> References: <20240603114008.16235-1-hailong.liu@oppo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: SG1PEPF000082E2:EE_|KL1PR02MB6627:EE_ X-MS-Office365-Filtering-Correlation-Id: fee480b1-7dfa-449c-3053-08dc83f1a771 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|7416005|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MWRxbStURit3bWU5VDA2MW15Vk1nbGtpYXJ0cEx2ZFIrWDNK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?Nm1yQThTT3hJVmxYUTZ6enprV0g5c1JEZ2drVFFBYTcrSTdnS1k2Y3dhVUxC?= =?utf-8?Q?ThFJOzIK539Vo?= 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)(82310400017)(7416005)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 17:21:49.8244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fee480b1-7dfa-449c-3053-08dc83f1a771 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: SG1PEPF000082E2.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6627 On Mon, 03. Jun 09:01, John Stultz wrote: > On Mon, Jun 3, 2024 at 4:40 AM wrote: > > > > From: "Hailong.Liu" > > > > 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.