Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 319ABC4332F for ; Thu, 9 Nov 2023 14:23:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CDDD10E216; Thu, 9 Nov 2023 14:23:45 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2040.outbound.protection.outlook.com [40.107.100.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id E537410E216 for ; Thu, 9 Nov 2023 14:23:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S9eFdoXs+yWhxMBkRp4OyNVom1Snq2g2rq7UUqavj7u3d+Q3gS4txzSESU4hkOujDiz44W41NCSOjtwqEDpPxoMvz0TNtxk1z9atJ8m1NKJkoiF7FmYnnS8x1UqhVRj2LXKuVk14djyd1ZKeUDYmiQ7xnA+bIirEsMeIDepJw2/nyy0CCDj2TEg80AkGGsqOALQwM4fq4SISv1U+S+0Gv8UcBOfeNoKQNjja0NKYkrMe8WXL5Zxu7xsBByN8s9CumqPYcOTh2R/+Zr+fYpW0rohcRoKm3Wxv44OT1sTEuf4K2fFG5UHYO7/spxDMxap9b0dcQURD7ZrIdLJz3I06ag== 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=Yd7GqgkW9g2QZtivsRIPbdCLlmliLK+ExO9JA766v/U=; b=NHrzyUTnPvXyNkcWJ789TAH68Az/m8zL2ieEWq2bhR0hNoHPjRHeEobIDRYkVDYEA7IUg7HxSKeQD0sIvkM9F4wdj6okECQLvgsYtkq3yGQLGQ70cJ63H62ooDfFYUG8qVzw52K76Qq8gUHkFU5mdOT9p3hDBJA3HXgZ0O7vFytUy7iaGQTu751xeKvKp+906dHGJYzpC2NqPkUkpv1A0ixgsl7m552Fnbu6hb2mDmOcChfBIvUEQbBXsx0+c9Bn2BR+qFmwJEARxpi6Pugn2BMkwmjKQRSeNxsS2K7t8nkSahhInKw34ME34f2R/5WZoIKq1AJ5M7AEOXoeREUKkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yd7GqgkW9g2QZtivsRIPbdCLlmliLK+ExO9JA766v/U=; b=X1+hlDkHfEOhYblH+nox/WMKCsaR7M3OPZ3RTHXBm13jva5s9Z8hS8svANAYyFEPzBtlEY3z6Y3hrdRF4ZHLJQHsOXcsILiKuR1Q/7spNOC6mhubnB4RGDOVmmzcoRMn/0g4EYFXDERclreG9CzuLllFJrmuwH5sgMECR5EGNps= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by DM4PR12MB6037.namprd12.prod.outlook.com (2603:10b6:8:b0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.18; Thu, 9 Nov 2023 14:23:30 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::ca80:8f1c:c11:ded3]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::ca80:8f1c:c11:ded3%6]) with mapi id 15.20.6954.029; Thu, 9 Nov 2023 14:23:29 +0000 Content-Type: multipart/alternative; boundary="------------CzxCxWr413MoY3saxMAVf8Iw" Message-ID: Date: Thu, 9 Nov 2023 15:23:19 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v3 07/12] page-pool: device memory support Content-Language: en-US To: Mina Almasry , Yunsheng Lin References: <20231106024413.2801438-1-almasrymina@google.com> <20231106024413.2801438-8-almasrymina@google.com> <4a0e9d53-324d-e19b-2a30-ba86f9e5569e@huawei.com> From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: X-ClientProxiedBy: FR4P281CA0173.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b7::16) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|DM4PR12MB6037:EE_ X-MS-Office365-Filtering-Correlation-Id: 12264cc1-52ac-4fe6-ca76-08dbe12f71ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jd4eYb4QVgfjno0MNZPdOOCfSq6lNGHb09TFzdlubP/5qRBOy5kL4B6wKJ+l12U8gpV4YJbxJlTk4L9CEnI5kanC5Usi2SJBU1YpHxp7gOqsrU4HqmW774szY1wocZqlehHkBMewePY2J/2oK9Jqetb/O5VVZj/A1UTPKrfZ5RejljxH82nReZVER+OGUbpClWa4MkVIUrGuXl72zVvQdztyPYDbyienZ8Q4mxGa4vg5k6sPacSWhgZ4Xn2sVe1EJ8OG/YufUGmPQB4FKHJ+SgVKSTeW0yILDEThY0djCsrcu5GiyvFFdnmfcpw0LHm+tzf6kGlUcyIbxMfdvebyKKLUCKxCNqavabQpslklLrQubYRsStmCzu/rabb1aVcYyiAvtvaYA5kErY63Vx52vqHlHaiHqN0bGSYXbyXnDqMlU5PBX5Qhoz48ZOCKYHtlc4Qr+1+sdNAKbmD91iH4CDoSRLq6/1qOymEN4ldoWR3dyX243m+VrJ67Y4x/l47XTuC/FN7kC/54inAL8n7hJBODg32lP76sBMikKc6U8bprRrbnpinrntkDxd5mTQziMMoIQYam9D3g8qFcJ0ReoqGmwo/bWjO2xQkEZ8EHKY5VOf9MEC6G3ZSanjbzePey6sk0axsmxZv22dKD1DpzlA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR12MB3587.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(366004)(346002)(376002)(136003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(110136005)(83380400001)(6666004)(41300700001)(31696002)(6506007)(86362001)(6512007)(33964004)(2906002)(36756003)(6486002)(478600001)(7416002)(38100700002)(26005)(2616005)(5660300002)(8936002)(8676002)(4326008)(31686004)(316002)(66556008)(66476007)(66946007)(54906003)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?b1AyNThuWHRMdHBQZUFpNGRqME1tUmp2RVdjOFNjazhNNTVYRHdRWDErRGxS?= =?utf-8?B?Sm8rVFNqcjlUbmo2WHlxRzJLcU03NmhGUUdCSlNlZ2xVeHl4cU1XWi9wYU92?= =?utf-8?B?VGRYZ0NvM2tiVkFIbElwOTM3MTFnLzdoY3BPUzJQajhjVHpyeTlrQnJKSS9a?= =?utf-8?B?c2JTR2FxZWxvZDUyOVR5d2lKZm4ra0RZOWZzS3kzM2E3WnhxY3J5QWgwU3Fi?= =?utf-8?B?MGhZVnJYckpNNnlpT1F4Q1JQN2gvSWhMWHlSRlZ6VU9aRHIrTTFYNnlmOXRF?= =?utf-8?B?Q0p2WHE0SEdvSzFoVGUzbmpOQ3JiMVBOOTByR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?P5/U=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12264cc1-52ac-4fe6-ca76-08dbe12f71ec X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2023 14:23:29.6196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IVzvzH6etZ7ji3pbJabVP/k92pLatu1icxxQR+svRhXfENxrZgws1cEpxlM3XJi7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6037 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Willem de Bruijn , Jeroen de Borst , Jesper Dangaard Brouer , Arnd Bergmann , netdev@vger.kernel.org, David Ahern , Ilias Apalodimas , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sumit Semwal , linaro-mm-sig@lists.linaro.org, Eric Dumazet , Shakeel Butt , linux-kselftest@vger.kernel.org, Praveen Kaligineedi , Jakub Kicinski , Paolo Abeni , Shuah Khan , "David S. Miller" , linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --------------CzxCxWr413MoY3saxMAVf8Iw Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Am 09.11.23 um 04:20 schrieb Mina Almasry: > [SNIP] >> But we might be able to do something as folio is doing now, mm subsystem >> is still seeing 'struct folio/page', but other subsystem like slab is using >> 'struct slab', and there is still some common fields shared between >> 'struct folio' and 'struct slab'. >> > In my eyes this is almost exactly what I suggested in RFC v1 and got > immediately nacked with no room to negotiate. What we did for v1 is to > allocate struct pages for dma-buf to make dma-bufs look like struct > page to mm subsystem. Almost exactly what you're describing above. > It's a no-go. I don't think renaming struct page to netmem is going to > move the needle (it also re-introduces code-churn). What I feel like I > learnt is that dma-bufs are not struct pages and can't be made to look > like one, I think. Yeah, that pretty much hits the nail on the head. What was not mentioned yet and you could potentially try to do is to go the other way around. In other words instead of importing a DMA-buf file descriptor into the page-pool, you take some netdev page-pool pages and export them as DMA-buf handle. All you then need to do is to implement the necessary DMA-buf interface, e.g. wait for DMA-fences before accessing stuff, when you have an async operation install a DMA-fence so that other can wait for your operation to finish etc.. etc.. This still doesn't gives you peer 2 peer over for example the PCIe bus, but it would give you zero copy in the sense that a GPU or other acceleration device directly writes stuff into memory a network device can work with. We already have some similar functionality for at least Intel and AMD hw where an userptr mechanism is used to make malloced memory (backed by normal struct pages) available to the GPU. The problem with this approach is that most GPUs currently can't do good recoverable page faults which in turn makes the whole MMU notifier based approach just horrible inefficient. Just giving a few more pointers you might want to look into... Cheers, Christian. --------------CzxCxWr413MoY3saxMAVf8Iw Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Am 09.11.23 um 04:20 schrieb Mina Almasry:
[SNIP]

      
But we might be able to do something as folio is doing now, mm subsystem
is still seeing 'struct folio/page', but other subsystem like slab is using
'struct slab', and there is still some common fields shared between
'struct folio' and 'struct slab'.

In my eyes this is almost exactly what I suggested in RFC v1 and got
immediately nacked with no room to negotiate. What we did for v1 is to
allocate struct pages for dma-buf to make dma-bufs look like struct
page to mm subsystem. Almost exactly what you're describing above.
It's a no-go. I don't think renaming struct page to netmem is going to
move the needle (it also re-introduces code-churn). What I feel like I
learnt is that dma-bufs are not struct pages and can't be made to look
like one, I think.

Yeah, that pretty much hits the nail on the head. What was not mentioned yet and you could potentially try to do is to go the other way around.

In other words instead of importing a DMA-buf file descriptor into the page-pool, you take some netdev page-pool pages and export them as DMA-buf handle.

All you then need to do is to implement the necessary DMA-buf interface, e.g. wait for DMA-fences before accessing stuff, when you have an async operation install a DMA-fence so that other can wait for your operation to finish etc.. etc..

This still doesn't gives you peer 2 peer over for example the PCIe bus, but it would give you zero copy in the sense that a GPU or other acceleration device directly writes stuff into memory a network device can work with.

We already have some similar functionality for at least Intel and AMD hw where an userptr mechanism is used to make malloced memory (backed by normal struct pages) available to the GPU. The problem with this approach is that most GPUs currently can't do good recoverable page faults which in turn makes the whole MMU notifier based approach just horrible inefficient.

Just giving a few more pointers you might want to look into...

Cheers,
Christian.
--------------CzxCxWr413MoY3saxMAVf8Iw--