Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1137162lqj; Mon, 3 Jun 2024 11:10:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1Ef8g+CtYkslL7qvWGGpxey8OYCTfn3ehpTw7Os91TemzR8RvCGsPxarHpG5dab5yUVOtddsSAHJoUUTKVK2OT8O93OuTTKw5uYeGDA== X-Google-Smtp-Source: AGHT+IG16aULYhAQQpiriug1pezZ7dOb5GTlcJarTidvp3LVsV0Vhdqsoayl5f1QVQm3wrOvVrE+ X-Received: by 2002:a17:90a:5984:b0:2ac:5d2d:12ac with SMTP id 98e67ed59e1d1-2c1dc5667f8mr9331852a91.5.1717438248769; Mon, 03 Jun 2024 11:10:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717438248; cv=pass; d=google.com; s=arc-20160816; b=fIuXiS7fBCCMkB+8qB68cGYmuA0xuz1DsjtoLdt8Qe3JYz0IxOUOQIzCoDO+nY5EAP maD0IGidBEY8XHZdZbBvKdQu3HJbtnXiEvFDi31ffZOl4K32wLdC1A9zexAUDdQcdk0w CqgKDhLdltYkiQ744s4mhS/MD0OtDGMK55qYNXqPP2IAszx6lmtRVieF8EJHFKcqkL9X E4f7kz6kCmypa4GZdOQojGAbGJVIjG9b5SqsCp2+iswyKNAK9/muhhy+AmCa75Cn8mCc IeNIuyvLiTUYbd16Qt0TAk/nDUR1Pu5BiqIMt9houmitPogISPD44OSe8v66icNKMFJt 9wdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lxEtH6ksqOT/HFLTQs72uRkOcc2agItJ6FV9YxsG9ic=; fh=QyvKmfu8eU+S0pUZcqtqtkImah6sNpRT2NzMmnAZ2xA=; b=h/qQXVc8tWU7RU21ZshxaNM+A8YOW0OKsrbJBGERJx4cjlwem+QlEs197ad6Qt4gDc e222UwvZgjKgLZ6nGIPcEluQa3rAOuvZIdkVcCpreXoLLW+R/AjjDJN8X3NT4wrdTa2b gMJXMNQarSHGQz6bi7QIH7HyYzMOoeCKa2khQMp+fyhW16DKArsGrkgPApkCh7hnLJiW ROpCjzEnD/IAGTpqiMwIlj3yxNHLmoVDpajMqUYZe5oShQ7TEqXhnGtS3RRrlUy+YIEC IuLuEE+Tgx04VfAvjvSZVTJJDB9CD2VycSS9tGRbzQIcuSlyn2AIgsQNh+7EVJN3MZLx 6QOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zJ6pXOre; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c241345303si1491575a91.41.2024.06.03.11.10.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:10:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zJ6pXOre; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EF680B22C5A for ; Mon, 3 Jun 2024 18:07:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76E7F1386AB; Mon, 3 Jun 2024 18:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zJ6pXOre" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7FE4137C44 for ; Mon, 3 Jun 2024 18:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717438027; cv=none; b=QVZOBApwPgaGBaHScB5cOmmnjYQBwHhxLwOANfI24hsPk9PruIsVER7ABUbXmCpg1xCAbCUSTCdDQfY+d+VcImqDm6Go1ekePGYXqpbAIjdcsuQQrpTmmWbm/ExUucdSAl1gRrrpT2ig2aJlG0sbzDZ7q7DIwNkG7ON0eLdE8R0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717438027; c=relaxed/simple; bh=TaXhlRDjNJLhHW4iws7eb0uy7NSOvaguvsnI7PxZ9U0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ma1eWS3Rmqr8StVLy4Bof8JLynS2w7nHhrQw52tzESb6fxok7+kk0z5DrWaz/sNwE1CP5m8TQvUY42agDorpMyWNaLSUNzp65WFTbYkftAjJ0P2FuRgPQOgwsNnZ+pRly/5UAJbEAYkyXsCB86oxFBpCWiEEANgwzkNwLdPaVXI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zJ6pXOre; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-57a1b122718so890a12.1 for ; Mon, 03 Jun 2024 11:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717438024; x=1718042824; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lxEtH6ksqOT/HFLTQs72uRkOcc2agItJ6FV9YxsG9ic=; b=zJ6pXOreDlBGkhJHkY1qeKJ2L0Liuz3+u0WtJe52qgVVScAUEd+Y0kpFBDVIhz89oY 7CIYEumlPhJBrcL0yi3lm5/Ck9VaVQQiDD6xiVsqWbsg1qS1ef0TJyI0eFFppLF0fjAa wouoNsJCLSa5R7+3wuLM2tMBOSaZNSb+bcrkb47yRJm2QdPRQq0RuFMUmziEnWg3lxG4 XnU8KW4Lfeemp3VHTcQ8A+APMtVYNFIFulprkQQK5vnOSY02YlQ4Av5MnXaYPMbzQ8oi izZe7tY5MI4xnZ9K7xCJOTouXm6aHS1ncKVv21wxXefpRqqESlauuwToBHk4AsfYLZrW Cg+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717438024; x=1718042824; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lxEtH6ksqOT/HFLTQs72uRkOcc2agItJ6FV9YxsG9ic=; b=lCPypMGEzpKk3x/OqTSQs+ydjSP0Hl3TbU/+1gYhunfOmOcpbOGqgxtuMVZnZ+G8+t s/S7iiMFb2twRrOlHAe8nA/qXApUoZoa9C0S0BBKpwSNLiunEl6SeBnaUxaRO3wLz5f7 S3A23XZc0De3Bmp9ZZKH6A0+uqFUq69bQ8pPqTnvrLWcp64XYyYbeVshFEwqy2EI6gtn jxQur7N+Yu3Uq+hQKkTFSHoGybSWE8Hm19S0DNjEewXEGrNRhqfbClnHhoavgPqio63u fw5G0nTMXGrWa2PMrq1A6ULDbGNayzOyC1eupd9ZBfuKjOfCI/GhSZE4U2z1/31Mowpa tsOw== X-Forwarded-Encrypted: i=1; AJvYcCVNtDEFdZdZczY22cESHB7nvwK038w5YXSIgg3zxK5xEGLNNZG+aloaBiqbPNQ73Eo1Zt+JXr/IO7MtNDxy0g16Kj8JrTgiAMwvn1U/ X-Gm-Message-State: AOJu0YzyLlh+fqhZarhKDScDcr2dtP/6zGdlDiBBwe67VaW0i0ux8pIg yiPl3IbD1ZWZkYxW2iHi4km1a0OS9GQ3ZaILiSj57WbayvYlZGV/ygDfmJRui6Q95PzCq7ro2z2 JJN6ESFMR4qg9CpiFGJbgy4tpzi+Lj+d4UUY= X-Received: by 2002:a05:6402:12ca:b0:57a:2276:2a86 with SMTP id 4fb4d7f45d1cf-57a7dad73dbmr6429a12.4.1717438023960; Mon, 03 Jun 2024 11:07:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240603114008.16235-1-hailong.liu@oppo.com> <20240603172148.gb7txpg2ya43jyxn@oppo.com> In-Reply-To: <20240603172148.gb7txpg2ya43jyxn@oppo.com> From: John Stultz Date: Mon, 3 Jun 2024 11:06:51 -0700 Message-ID: Subject: Re: [RFC PATCH v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap To: Hailong Liu Cc: Sumit Semwal , Benjamin Gaignard , Brian Starkey , "T.J. Mercier" , =?UTF-8?Q?Christian_K=C3=B6nig?= , 21cnbao@gmail.com, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 3, 2024 at 10:21=E2=80=AFAM Hailong Liu = wrote: > On Mon, 03. Jun 09:01, John Stultz wrote: > > On Mon, Jun 3, 2024 at 4:40=E2=80=AFAM 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+fz6xrdPW= TyciVXMXQ@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=E2=80=99s 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 instea= d? (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