Received: by 2002:a05:7208:20d2:b0:82:bbfa:f723 with SMTP id z18csp52606rbz; Tue, 7 May 2024 10:15:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0V4xRrdKwi471hC0hGK9ysuI2+wGH6iiRdHpQLuVneuqCoaqgk23YkiScBNSpZqGUzzQUTTXdeWgxgVqPYC9yoSPhmBPTOCo4NCbzdQ== X-Google-Smtp-Source: AGHT+IG2TN3S8ELHuJnGncV6jCEdI2vREjtT2u5l8wIf2uWlAJpez45Cy9I4kSHd4BcQcMoziWUG X-Received: by 2002:a17:90a:cb12:b0:2ac:2b02:e167 with SMTP id 98e67ed59e1d1-2b6169ddac9mr196163a91.37.1715102146078; Tue, 07 May 2024 10:15:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715102146; cv=pass; d=google.com; s=arc-20160816; b=dAeGoRXE7wT+/9ed0kaocvkkIEvRtp7iP3yNMBCROWZ4IHkJyIooxbeprBgHU+oI7Z lSbKA6IWQvw/mCdrHmGz3RcT1xFuA5KzpNOkbbSttlhqH1VG+d0XFKMMkXMxIH3/W0CB sO6voVZ2tMp3g0qFt8CrKI7JTUB/2p2FmM6xJyBAY9U63QD/2ajHD1q5o6L5B5kPHHzM 1xJ8RSX2btizqz/HVNVQarrtlqcjPy5U7b4vbRy5pOHSuoxMK3nh142jPYhpgBbvJNYD A2JSO6suQMCTHTEJl5uTA3DQWGbYQVZUE8SvQjYgPp9c+DJ72AOL0f+XGR/Y/wfzZAkS 3uIg== 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=wMvfDOvPFL6UptO1Upug97aOGGLmrRd7m4cshxAtOPQ=; fh=13cElqan9o7CVGrMzgqDJco6JqCaRnIX9/6llNRL41U=; b=ulA0qVfocSP1IrVFegmqt0782NEcgG7vAu1JtkKmRYcvb10xx2zhn8Tqa+sed/U607 1ZsA4s+GHU7DFjT6pbedsTQauqXwMo1VnKyQtzqsqGQMsrh1/BmC9lDKEqDI9T2UTvHy BeLR+Y4EX3Wy9YLoj5JVFPghw7LE10oRsMoIwsx/wPaZSekIPokec7odqViKBo7hyTgT XUml/WTwcTETboiVPkJuBPyvS1xUYy7urNSY62eBS6oBTVjq2MVrGdMr0WbWhKRzUTJd oix5X2EqA5vgKBH+d8Ix8/1KCGKsPMhiRCgl7sClb/IrdUe6an9Acq0oQkwZ/8wi3C/e GjOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DHVH+PJS; 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-171900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fs13-20020a17090af28d00b002a2d2103eecsi13304106pjb.81.2024.05.07.10.15.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 10:15:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DHVH+PJS; 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-171900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171900-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AD90D281F0D for ; Tue, 7 May 2024 17:15:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5777616C6A0; Tue, 7 May 2024 17:15:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DHVH+PJS" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 873A615E804 for ; Tue, 7 May 2024 17:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715102125; cv=none; b=S8mHGxXYB/4Tifn9HqTBFD/Hjdk8rckk7T3L2pJ5eNTPvq1k1/4iEIiEthy36/vEiUDaLrwv/xX7mlLnbiXgZs4IoTqckUMNJM6h/yY2oejg6G0AllnNXsNkVeCD5IIdlmWt8QToBnaY1vx1n1uI2n6t/7ohqYGEH/x6PS3S0dw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715102125; c=relaxed/simple; bh=yDxPlO4WrIjeqkPQr1tWVOcKWMzq48rRYXAZ9FQA6wU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oBhzT+gW+T1celJv3yYRyUmZk6XlrPpuH8nMbJWoJ5qem39Z0cZEb9qHOyOlqwm1BUP/rM1XjmK2XZb0WmP72jE1L4yxJ8/dKapphO+Uqv5f7w4jukfElX7OPE8UUnQ4cbRG+VIIwxfgV8yz924fkiKd23pdX7y8K6HoCT2TE1I= 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=DHVH+PJS; arc=none smtp.client-ip=209.85.167.52 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-lf1-f52.google.com with SMTP id 2adb3069b0e04-51ffff16400so4887219e87.2 for ; Tue, 07 May 2024 10:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715102121; x=1715706921; 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=wMvfDOvPFL6UptO1Upug97aOGGLmrRd7m4cshxAtOPQ=; b=DHVH+PJSt+j3Gp/cozTNkkDJnbDqF2r++Ogk1sm40sQX41ebmP3mWEMJRHew18VwPl M1TynCnHRXFkOQBnMQrBTICWB0z1X108PACkFUqFsMuFbcXbIzz24oIBfI6I9kC/Ywjx u13yMmDlBh987AE8fZqQn2AH0d+ze+dODMUnIUuorvjuKc53okGRiXe3dyznQFRBcBA9 dwDf5v8qiOe6LQj6XiRe/Lh5QTy+Ff45pg4OPPNqHlnmYDlC6x/IQVlFhvV72PVhhAMf ElRcfWRZJEWBagn6/qLskFjVUV1MuYX9fXq3KzsvhLtsOzzFiN4IA8ITJs4X3yAJVq0P BMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715102121; x=1715706921; 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=wMvfDOvPFL6UptO1Upug97aOGGLmrRd7m4cshxAtOPQ=; b=Y08wx32feCixy0HcKoDEdLV4ugRrIQhzBAqbw1N99k7QTFs1oQh9tTzO+QxLVhnQZh z/VnINFijPMAwaR81yPYRe/OYTr076Nah0YkxYBl8DHHxkm4DqKsMDcS0lY0fQ3qJSrj pGIv3XY6UlEMkMlkXgyWd6g8v/6YWBd/KPXSXotGyyQwW9kOeSSFzpKoOr4/zWUa0kkp +gQOx0qFPFyBgrwXS9XAHLjMFNLTiU9HXoI/1DOJpKbLoRrpdvwWzxT+QrjueDQb9OyL NJTBwUYuTtRt2pBIODmYiTHui6xX9URNLCrqoJsY1PivlvsHFvHD0MpziWHJ4jk1Eko4 NhbA== X-Forwarded-Encrypted: i=1; AJvYcCWquYFh4HmgmQ7Q9bX/6QEF5VzfODE8ZcKO0lB5PCJnfLqb6Nn5mrUtH6M8PyJQXrqoFWlHU7gev3PR8ZWG9lvJnEzp4zZSnfr4Majg X-Gm-Message-State: AOJu0YysfebVQ8+9hx9pn7wIAn8dMj+d3eJmi7YnoaM6jaDUOJQYO60u 1/mETP/QZIbNrpCuE/I/bw958vD8VClAYsLg8xcj9WYIBs6v1fLPVvzsopv5Jy0Gn4bmm39fWot +oQej3eUmAS9NBJK201QKpWIFbTJzzdSMsxWVTC3h+LA/5h7GGnXo X-Received: by 2002:ac2:5dfb:0:b0:51f:36ed:ee43 with SMTP id 2adb3069b0e04-5217c760288mr120513e87.31.1715102120263; Tue, 07 May 2024 10:15:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240403002053.2376017-1-almasrymina@google.com> <20240403002053.2376017-3-almasrymina@google.com> <20b1c2d9-0b37-414c-b348-89684c0c0998@gmail.com> <20240507161857.GA4718@ziepe.ca> <54b1bf11-0f9a-4e9e-9e5c-7d81e066fc7c@gmail.com> In-Reply-To: <54b1bf11-0f9a-4e9e-9e5c-7d81e066fc7c@gmail.com> From: Mina Almasry Date: Tue, 7 May 2024 10:15:08 -0700 Message-ID: Subject: Re: [RFC PATCH net-next v8 02/14] net: page_pool: create hooks for custom page providers To: Pavel Begunkov Cc: Christoph Hellwig , Jason Gunthorpe , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Amritha Nambiar , Maciej Fijalkowski , Alexander Mikhalitsyn , Kaiyuan Zhang , Christian Brauner , Simon Horman , David Howells , Florian Westphal , Yunsheng Lin , Kuniyuki Iwashima , Jens Axboe , Arseniy Krasnov , Aleksander Lobakin , Michael Lass , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Richard Gobert , Sridhar Samudrala , Xuan Zhuo , Johannes Berg , Abel Wu , Breno Leitao , David Wei , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 7, 2024 at 9:55=E2=80=AFAM Pavel Begunkov wrote: > > On 5/7/24 17:23, Christoph Hellwig wrote: > > On Tue, May 07, 2024 at 01:18:57PM -0300, Jason Gunthorpe wrote: > >> On Tue, May 07, 2024 at 05:05:12PM +0100, Pavel Begunkov wrote: > >>>> even in tree if you give them enough rope, and they should not have > >>>> that rope when the only sensible options are page/folio based kernel > >>>> memory (incuding large/huge folios) and dmabuf. > >>> > >>> I believe there is at least one deep confusion here, considering you > >>> previously mentioned Keith's pre-mapping patches. The "hooks" are not > >>> that about in what format you pass memory, it's arguably the least > >>> interesting part for page pool, more or less it'd circulate whatever > >>> is given. It's more of how to have a better control over buffer lifet= ime > >>> and implement a buffer pool passing data to users and empty buffers > >>> back. > >> > >> Isn't that more or less exactly what dmabuf is? Why do you need > >> another almost dma-buf thing for another project? > > > > That's the exact point I've been making since the last round of > > the series. We don't need to reinvent dmabuf poorly in every > > subsystem, but instead fix the odd parts in it and make it suitable > > for everyone. > > Someone would need to elaborate how dma-buf is like that addition > to page pool infra. I think I understand what Jason is requesting here, and I'll take a shot at elaborating. AFAICT what he's saying is technically feasible and addresses the nack while giving you the uapi you want. It just requires a bit (a lot?) of work on your end unfortunately. CONFIG_UDMABUF takes in a memfd, converts it to a dmabuf, and returns it to userspace. See udmabuf_create(). I think what Jason is saying here, is that you can write similar code to udmabuf_creat() that takes in a io_uring memory region, and converts it to a dmabuf inside the kernel. I haven't looked at your series yet too closely (sorry!), but I assume you currently have a netlink API that binds an io_uring memory region to the NIC rx-queue page_pool, right? That netlink API would need to be changed to: 1. Take in the io_uring memory. 2. Convert it to a dmabuf like udmabuf_create() does. 3. Bind the resulting dmabuf to the rx-queue page_pool. There would be more changes needed vis-a-vis the clean up path and lifetime management, but I think this is the general idea. This would give you the uapi you want, while the page_pool never seen non-dmabuf memory (addresses the nack, I think). --=20 Thanks, Mina