Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp55521lqh; Fri, 3 May 2024 13:11:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIZyM8NUuE1w4VjL0hWoaf6TUf+0XtlRYNfrrzaOLtE5ILO8wFen+G/lGuvXNpQ47ARpDcT6TVBFkNJA+zVhjPh97wM009338NSzS0IA== X-Google-Smtp-Source: AGHT+IFUUK9TLoqdd86Yl9UfTyhaMeWvK7mZP4UG0yMiuO9n8smNJJHSV2qzUZmpopuk92vcDfOZ X-Received: by 2002:a25:98c6:0:b0:dd0:c866:ec3a with SMTP id m6-20020a2598c6000000b00dd0c866ec3amr4118772ybo.22.1714767080593; Fri, 03 May 2024 13:11:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714767080; cv=pass; d=google.com; s=arc-20160816; b=x6ki8r1Fzh4hFKG6OqdI/THO7p4iQZ/jElCtYrYAcDwQ9OSNvkDz3n899DEiiJN9yQ LbMH9esyWvhZmPZNRuvgdvWFv3PHZiCzjSgykTl0ThXZMaGv417/1C9TOqfdPLnHNQw0 Otnjbf2lGSJ+8huTBUOIo8WM2Is5q+d1hSFdx/4oFJOjHoWeSQBed+z+MM3gIYmkUA5R Jf3c9u1lLJKqjBUxlX2H/l82HLTGB4qHCGqN4S3BRc8ZqJnm0e2ny6eAmnA5IPafeiaj v2TPmxngFFZTp3Lim/joUfIRtHbqICBoSab5fstDhvV3cyMXD2Yan33aV9JEL3y9ykT2 3HMQ== 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=atCvgdMV0JNn9Qp/m9GZW6Z7D46Y3/r5gcCPjNPxDaY=; fh=hQW06mGXBsFYbrc/nBbMDb3hMcAorbjuVf44hNfixKw=; b=YwpOXv7Ru3BXgVmJLi9w4Jru92m0fhZzq/uJZvJdeiOG6I8kKpZW5dEDeJo5u4lGVq 762MFyxTm+ArWYy6PPkdEWFtGsuWvznP4qmp8FlErAOF3SeujIKEv5rOE5murECqw+vp T7BCtYB/XaueP+cCdq6hj21nE5iJ4bbFf82zME1SPqMtdVInHCNWyUYkOps1i4dSHnBt rUoKwWHjGKM0/0MdxTGjewHzeR1Bv1Z5kIMCnYzYO1Yi5LGHnE9ACz1sODr0nTUUZSwQ SMNbgc1TAosepRy8Do71HaIrmUQKAFJWXjIqXzcqUtdkzWzYfjr8GTL+hO17nIWbYhYY AFSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BXraE1Cg; 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-168164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w5-20020ac857c5000000b0043abddc3687si1619232qta.677.2024.05.03.13.11.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 13:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BXraE1Cg; 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-168164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168164-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4256D1C239DD for ; Fri, 3 May 2024 20:11:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4D50158DB9; Fri, 3 May 2024 20:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BXraE1Cg" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 D17A7158D6C for ; Fri, 3 May 2024 20:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767059; cv=none; b=BGGVjnbgxv175PaP9PLEn6kMiEc4zUbnsCxX59GN7XZ5cSmOIbcw1xUA2CsgZPNBVwA6NuL3PwnR6qSdqbnU7y6HhPDZnEwR/pmCMqE/JnfulyU8tE/EsZQhxV/q45OI2VxAxUoJRE2i7/r9pzAtsTi2h12+FFw1AwypRWSJLpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767059; c=relaxed/simple; bh=atCvgdMV0JNn9Qp/m9GZW6Z7D46Y3/r5gcCPjNPxDaY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=RzTxSOOJHO/vDZHXToUnLzBkIZN7UHgCtWZHCD0fdRia/5XTCAMhI2JUWN3CWn6Da7bpKFfSXoKBeCbRqsVvR1L+MT6MlKXdM+Vo2Dg9b1AZydWLsPRCPc4dgEkdY6ZQjOggBESZ8pKZh/oiavlPqMo1fo5gfymc8lZgy/UjXjY= 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=BXraE1Cg; arc=none smtp.client-ip=209.85.218.50 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-ej1-f50.google.com with SMTP id a640c23a62f3a-a4702457ccbso184366b.3 for ; Fri, 03 May 2024 13:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714767056; x=1715371856; 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=atCvgdMV0JNn9Qp/m9GZW6Z7D46Y3/r5gcCPjNPxDaY=; b=BXraE1Cgqyr5gr4R1yA5bOlellj2XeZR3ELw04tSwgwfVv7Tej6f7AujDIMDuINB9N q2nEFO9qOEOvh7HiQReLkvkWl9rakjWPl9SNFurQZQAs8DOlxuJjeYtxzcy6KEPNqqVf mwGAzmTZDZUQIyusOpqki566NwoJRymeYhZF0faPskN7YR9xUI8DTCq7DVLv/ZuGgRBy VfUrZztINEbwkYEdTK3UD6K5jJ2XqM612KvTehIfS51KV69MgrJejg+oDxSW3IlsJPsO jOH3BSBbOuyK5XYgLAnbMwFMEoHPp/g5j9BgwCfWSYACT8UAkV3w6IWQfdiM9MX4ard4 eLfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714767056; x=1715371856; 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=atCvgdMV0JNn9Qp/m9GZW6Z7D46Y3/r5gcCPjNPxDaY=; b=ml8iHW+qg3NbH4Ng8mTnX6g3hD8Pj/7HjsdHv4fXBZCd9fO3fY7fgdT8bmoyMiNooi i6hFImoAYD4G2dqSJ8O1b+eNZBgsqiwoOIhjLrjHfgyr0QhwUMlZCZyvBfGpLF5tHtmK zmyiFFs5uPXOxQU9yIpMs7kD2oUknpaX9CJBbKDZsibzXKBXTX5B4a8CiNEIVsmZumFG Jl4Nb1OGM9hXOdppElaw9IkwbYFs8zBfoIq8z91qn7hE997k07a9ZDKjtzRjtEFlAFi8 hnJxytlJyzAUW13l0yZO+kAuPLMjPVHzAguZh+WDhA7km/FoIxe1AJUFD20CviYNCLpx u1QQ== X-Forwarded-Encrypted: i=1; AJvYcCUWmOBXhZ68V7mZ7e9CDq6zNuskZLx2fIRyL815RTmLZ1KQeu1ZHHCaK8gyFBkK3XgQqNQOfHve2rfR1y90VCqOLvLRptMdI96i0+sj X-Gm-Message-State: AOJu0YykBPRAgxTiKJ1zLge2x8SOY1sXp7i1hrsDKLolXGtEoRWGPJfe rO8Qpz3jhzVOcCsjGdBavH/qtW2SKoCTlfLdtrqCf+3mK6zA5MPbICFGR8cVAc9ph4FFMQceAFw KQL3fbR/JW1y+CaguXTb+W5H+2k0uHB5iYMxh X-Received: by 2002:a17:906:29d4:b0:a59:165f:87e6 with SMTP id y20-20020a17090629d400b00a59165f87e6mr2459058eje.48.1714767055895; Fri, 03 May 2024 13:10:55 -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> In-Reply-To: From: Mina Almasry Date: Fri, 3 May 2024 13:10:44 -0700 Message-ID: Subject: Re: [RFC PATCH net-next v8 02/14] net: page_pool: create hooks for custom page providers To: Christoph Hellwig Cc: 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 , Pavel Begunkov , David Wei , Jason Gunthorpe , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry for the late reply. On Wed, May 1, 2024 at 12:55=E2=80=AFAM Christoph Hellwig wrote: > > Still NAK to creating a=E2=85=BAbitrary hooks here. Is the concern still that folks may be able to hook proprietary stuff into this like you mentioned before[1]? I don't see how that can be done as currently written. The page_pool grabs the memory_provider_ops from the netdev_rx_queue struct managed by core net stack and not really overridable by external modules. When the netdev creates the page_pool, it gets the core-managed netdev_rx_queue via something like __netif_get_rx_queue() and passes that to page_pool_create(). We could make the memory_provider_ops even more opaque by only allowing the device to only pass in the netdev + queue num to the page_pool_create, and have the page_pool_create query the netdev_rx_queue struct, to make sure we're getting the one managed by core. Long story short is that as currently written I think it's pretty much impossible for someone to plug in a proprietary out-of-tree memory provider using these hooks, and if desired I can change the code slightly to make it even more difficult (but maybe that's pointless, I don't think it's possible even in the current iteration). The only way to get a memory_provider_ops in is to seek to merge it as part of the kernel with community approval. Is there something I'm missing here? > This should be a page or > dmabuf pool and not an indirect call abstraction allowing random > crap to hook into it. > What is the suggested fix here? I do something like: cp net/core/page_pool.c net/core/dmabuf_pool.c and then modify it such that the net stack maintains 2 page_pools? There are a lot of cons to that: 1. Code duplication/maintenance (page_pool.c + dmabuf_pool.c will look very similar). 2. The hooks enable more use cases than dmabuf_pool + standard pages. In addition to those, I'm thinking of (but not working on): a. Limited memory pools. I.e. a page_pool limited to a certain amount of memory (for overcommited VMs). b. dmabuf pools with GPU virtual addresses. Currently we seek to support dmabuf memory where the virtual address is an offset into the dmabuf for CPU access. For GPU memory accessible to the GPU we need dmabuf memory where the virtual address is the GPU virtual address. 3. Support for multiple page_pools is actually more proprietary friendly IMO. Currently the page_pool is internal to core. If we start adding additional pools we need to have some uniform behavior between all the pools so core can operate on memory that originated from any one of them. In that case it becomes actually easier for someone to develop an out of tree pool and use it from their out-of-tree driver and as long as their out of tree page_pool behaves similarly enough to the decided uniform behavior, it may be able to fool core into thinking it's an in-tree pool... [1] https://lore.kernel.org/linux-kernel/ZfegzB341oNc_Ocz@infradead.org/ -- Thanks, Mina