Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1403237lqj; Mon, 3 Jun 2024 23:33:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkWiOPsDCMqDjtIYZVGvj6wh8/uPCZgwFXwAXa6HZnUPFA4QUy/yLBxB+6vxRGzDjly1nwqHNi37WA1TcbL4g5s1T3eEvjoyhEsXYAjA== X-Google-Smtp-Source: AGHT+IEUoE6hnFns/cEJ9x/pYua36jLUSCTyGLi6pHuhLu9n9pXWP3/Cu20wGdE3KCBRy5aghPmH X-Received: by 2002:a50:d757:0:b0:57a:4af6:319d with SMTP id 4fb4d7f45d1cf-57a4af63229mr5838950a12.9.1717482790350; Mon, 03 Jun 2024 23:33:10 -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-57a857dedb7si115660a12.643.2024.06.03.23.33.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 23:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200110-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=eRGmsJZC; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-200110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200110-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 72F151F228ED for ; Tue, 4 Jun 2024 06:33:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9314E13F445; Tue, 4 Jun 2024 06:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="eRGmsJZC" Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2087.outbound.protection.outlook.com [40.107.215.87]) (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 7A0E913791D; Tue, 4 Jun 2024 06:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.87 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717482631; cv=fail; b=ihGBgmwr3+05nHDrHqC/AFoDo+vP6i7zvl38JWWZL24wwEKkEnk2pjLmzXhvbe0OxRaAubc5H8Hz9Mbvionp8D3CuQK23X8npXn/cz16eP7MdgPPZMet+ZjTIRGRm8idMe6YvAYK6ZrrDezZ/XY3plV8PTavAwlvtZVfKXWHWyM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717482631; c=relaxed/simple; bh=owZThAty/ZD0UqkQ7DBB7a55qaKB+slvuq8DvqXa2LQ=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=NVBgl/4k7he8wDxIpsdyLVJjGOG3+HncYcPtB5Rm3bpnHg5yxbijjZtARxaFotD0FCm2lcMBDpFavsZh0g4DrSGNYyMz24YgFN/rqHJe1a6BjR1VMkthCAhJ1za0RzWnlSXlE5i4cqPW9mjYNvU0TmHpndQEcjao9xLPLq6lFGM= 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=eRGmsJZC; arc=fail smtp.client-ip=40.107.215.87 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=DVkkoCryysiGlg6bh5DWIcuFLsJz6eEHrXzNiwElP3FGa5Xg8u0gX9a5Ygpy9UaeKxvlaX2TBNKc8E2OT+FJ99SNUKIx4+t9k08P8Kk76qEhRbq2vUT6aWyzHkb9a1e3sQVey7cIvbEwCCBg2SVQAt5AAmiAbMtpW7DqOi82EXwzZbIDLDC97+sKEtcMmy8rGLKqYVCtummoZpQ7WntcpK/pDKSxM9CHzGCUqy7/xf0OVpNHtDyjDI0j8Hjv+Dfdpsj2hQyD2DlcWBktfC/fPoErHL0gBGn1Q8TQIB3OZ29jylmtbt/CfuEQLcjRQOm9dKpId0dQRBXs4OwU/O05vg== 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=P6mocaiFbUti81GdwyW9uAFSeKItB+OxSg0cMJZvewA=; b=LsR4jdJzkw46jJutB7fuCQvlvJZn9JzP/5LwR4sEhlGQt12kCcFhPDDRisxhFm68X5QZZ/jux2tqwyDdPgmxMotr71/T9A22fCBzrZJ2vi0sIbcV6tQvByZRiiTafOj2GqAQlhlmFvrQsVQWTlRr895D3RQM3Mz9o8J12scbMCBNxmtrglUU7gjhhPattiQU8f/lWyJBzZ9YPSTV4+y/3NMOJWc8kctcxiBiVZa/9dDch72NusoEx1RjZoeL5QeTNbkneijyOg1ox2JSG5VBwoVLSkFkISQk7GWjco3D7EtW9nnMqSXXn/42va68TI4Jsgmy4tDNmhdIoVME4jrfoQ== 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=P6mocaiFbUti81GdwyW9uAFSeKItB+OxSg0cMJZvewA=; b=eRGmsJZCnWn0Do0qSkCkVuvvcefOsUjsattPom5QWMnwS+6FX4ny4GoSA5Jf3CDXeu7bEvf69W6BXxqZxK8hOMCYr7X+6iLpRMJMFmg+jkmadRSv5kIMC26pmqXEWQyb9Hk1fYTOREcPRKOGga1ReKPSpnfOHnc4fOggbEU+sdw= Received: from SG2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::17) by KL1PR02MB7310.apcprd02.prod.outlook.com (2603:1096:820:11e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Tue, 4 Jun 2024 06:30:26 +0000 Received: from HK3PEPF00000221.apcprd03.prod.outlook.com (2603:1096:4:c7:cafe::96) by SG2P153CA0030.outlook.office365.com (2603:1096:4:c7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.5 via Frontend Transport; Tue, 4 Jun 2024 06:30:26 +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 HK3PEPF00000221.mail.protection.outlook.com (10.167.8.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Tue, 4 Jun 2024 06:30:25 +0000 Received: from [127.0.0.1] (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 14:30:24 +0800 Message-ID: Date: Tue, 4 Jun 2024 14:30:24 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap To: John Stultz CC: Sumit Semwal , Benjamin Gaignard , Brian Starkey , "T.J. Mercier" , =?UTF-8?Q?Christian_K=C3=B6nig?= , <21cnbao@gmail.com>, , , , References: <20240603114008.16235-1-hailong.liu@oppo.com> <20240603172148.gb7txpg2ya43jyxn@oppo.com> Content-Language: en-US From: Hailong Liu In-Reply-To: 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: HK3PEPF00000221:EE_|KL1PR02MB7310:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e0853c1-991d-4d2b-5aca-08dc845fd206 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004|7416005; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YjJZWGpla0VCNGZWc3hLb3BxRFVKNURWOWsr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QWRK?= =?utf-8?B?NEpqZjBTYTk4Wk5rcWFPaVFldU5HSnZKaDFhTW1DZm1BSnJORWxjSWp2SHh6?= =?utf-8?Q?6dBXDblZwOSvN?= 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)(1800799015)(376005)(36860700004)(7416005);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 06:30:25.8596 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e0853c1-991d-4d2b-5aca-08dc845fd206 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: HK3PEPF00000221.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB7310 On 6/4/2024 2:06 AM, John Stultz wrote: > On Mon, Jun 3, 2024 at 10:21 AM Hailong Liu wrote: >> 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. > > 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