Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp585619lqo; Wed, 8 May 2024 08:45:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHd+CCAHzpCZbUpsLmXFxIWMh8vgllHxHwF+zLriW5DuGgr6IrCeuKwOVz2RvrLrbtztH5k1yAuWx4Oj86jdXt3Q3tY/6V74G05ip/0Q== X-Google-Smtp-Source: AGHT+IHYIRtT7DzIqyaL3d1WkYdp727QXYWT644elsvz8SuvfnaXtIjRHhjeu/lGML/TonPQpLh8 X-Received: by 2002:a17:907:76f4:b0:a59:a85c:a5ca with SMTP id a640c23a62f3a-a5a115bd150mr3350866b.7.1715183101664; Wed, 08 May 2024 08:45:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715183101; cv=pass; d=google.com; s=arc-20160816; b=g6MgHHpLa4njboS1g6P+Y1NoUhRvdsonr2GjUHN2mWp0kUimLhczmBc6RsARVR0VMM Cx/j759nHyXE+1wkkn/A92z5VliVefd2fs7vdyqIrqD0PwY0yiT+Q4LVruub782yRqB8 DQbJHcsWVjJO9Z25H9VD5ZyYnBOI+NIkBKlPh8U7V2zKrYfY+oZzP/hxUJ1PcsrPQJpQ AMWGnaCTmAPnVpo/ENPtOHYlEKxhRS90OO1+KqXnDLOY86WwqcZ7sK1Sb4OKB+ueYsgq AI/fmQvJlCOAu5symRcQ4URboU1vz76lQN3ShTHMY8lNLfiigRTrFDbmVmQjpnc1juIC MqYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=qQJE9gf7KB48yGwLoojwH5ddpfi3k3r9Ytiu480CbPs=; fh=8u7KykwYEWTVUpOrF0HztDiWQ5LwCxAI9me4pq9rjN0=; b=V/JVGUEInzhH0QuWpqb4M5a2W3r9fXX/Hg+0ara0JOETmTMaDVxb0Md3FUmIKs0Yhk DWscMVbh+5cmVD1mq9HIxmD5+iOfYZOCUKs9jOB/RIN/TKU0DHw0UaOIcNvDBxDHX0i9 HyUvwrnVtj7NMGwmZt1yV80L8cB+3vl9Tcyg/1gyHEP5FCjh5ucKersHppTuahp3HQe2 /bNe37J/JNsN5hkkjNfMEuRnLIkhJVT4uoffMZOrnNZ+Utf20Ov0Zv0OzM021OEOTdW2 WCyGsdsQbiJNQt9ydbOIgtgFv44ZDvfAKgxQrSxWjq7E2y6pJEERahl6JpIbkggU0/Hu ECPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D4ZTjST2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f25-20020a170906049900b00a59f55d6bd3si1532309eja.966.2024.05.08.08.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D4ZTjST2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 1B2EB1F2792A for ; Wed, 8 May 2024 15:45:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 702F812AACD; Wed, 8 May 2024 15:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D4ZTjST2" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 88DB712839E; Wed, 8 May 2024 15:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715183069; cv=none; b=pgUf66C8Lf1D7unmWJRCnNDRs2/JOayOWCM8KMXdYKn+Ta85NxYlDfNoKUR0cJMwxN4R5ALEQlwB2ZLKmYWHN3Bj16t5OSaWUlU4YeHBAni3js5UgIk2YLRFSihzkW/KChbjqN+eaXb9CaxbbmN1DHc5CyOij5CGsMRuPtuwslo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715183069; c=relaxed/simple; bh=kYkH3GQ8ASJnV40LkgFncEJhg6ZPhWJ+ixUSgcyTt5M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aOQ93AJoQw6Cs1FmKxHbg9fb7VnwFMaZ9SkbR0MfOEMXNB26OuTgzyIKC3MGa9xejYvn9b7hdbZFb4euMZEsO/hfsJSvU5TBLiV9pPzFzcq5Rw87htCOGcoCaNqM0LlYCpgonsGmTHHAJhJ0lena93W/pFIgTSa73BiVSAQHP9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D4ZTjST2; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-572adaa172cso1944341a12.1; Wed, 08 May 2024 08:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715183066; x=1715787866; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qQJE9gf7KB48yGwLoojwH5ddpfi3k3r9Ytiu480CbPs=; b=D4ZTjST2J0LHRW5zE/BvfGtWzm+6QcrPh2Q+5c8ON1LKBDNlFBzLEk7p8VbOSnIWwR j4Qv4V22IL6WKC+o1s5cfrTDm6B+qYkCupM8OHnyWPlAzqFeE0BHTBXI4obems13Tl0+ JFnWOoC+wPywj6jd4t8RJl2WHtJdLFPkxHY7KtSVi3PwvuuTbU/WWZ2sEnIsIO7o8g0Z w2GfZ2ObTAtHrKLLdrwGE+lvFdM59kLuGjC2Y6l8tvxQA1sGu8Nup/Ww3QNVdKuwGKnR qem+kxllPsvuMWrWHIR0K9OiS6vK85lcOKDWFEXR9wYHSqIKDOjdoQaBrIKJ57edXOvu Ah0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715183066; x=1715787866; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qQJE9gf7KB48yGwLoojwH5ddpfi3k3r9Ytiu480CbPs=; b=xKn9fEzlR7mg8j7NL5k0DvAlPdGSLfDILF4/wBSQ4aacEt/3L0Vy+1iUSnz0mKdJ4l lXhT32coNKjtfdYpTc3r51QFrq+TdNMb8NQQGTZH62mqT6yiL8uUm/Fu0B/M6emSCv8o pW8tG8qZIl/Ihj1PARrgHDHkAjJ8Ck5O/Yv0Kh6qxQTojgdvfVcouuSupSJ0UCA92/cm JV2un8AhGyH+i4QtEOIB61CZm/NW62tiiVKupJUgYNmcmRyAli/G55xhjozogCiMzDEJ NAY5h7+jBBq7ZHdndipQNXOsX04Hx8eBLLePfAqWtog7CuvQ16M16mc4c0+ogPtGoJJl QiQg== X-Forwarded-Encrypted: i=1; AJvYcCXvPfwewo6F8HQGVbxutB28KEooVEHRftnyGoKXD3PO/2xg12tE97L22k5cu+ksL7qPzixRlYBrNpliBWNpZtnSQrlI8rmopL/9ie1FlWNcqwZavg2sgqatuJb5L9rwzrzku05+J8yxeR6EkiIo+d03XdRkj+kYZlXPkPoua9i+MN1LKwMrYT9vJ1tsdlxiDQFV5Y9kjJa1PgOtFgAXwbIVBblCE0/o8W1VQu43jZl/lHXvXszxfrQ+QeeOiGO5lQsrPc90MSzkzpwbKVG1YqgjOBCi4BHN6i2Z6AzukjBTOj4VWY+I6ER9ZmjGnIn2Bmz4SjHn6hpv9Civ6XJ4rp8fXING7NSTVFoAi3MfJWzeGM6X/soIm1qzDYkn8/oWZq4dFimzqPRgxdUlc5RwIaWUlDzd3u0b723Gg/TYBPEVmTbnpbgJ/GY9+WDjM+D7emXJ/72NuxrWL5thCXqQEjzWHHfWLNMCWEfP5M91RFI9pL5w0MKLOVcekuX3fjYyHqZsoKx7+g== X-Gm-Message-State: AOJu0YytoznEv2AR4a6CWvCBsLQ+WYiZmRLhvwAT6ORu9uiEb0ZbGsPY qSJdBfFwDX6fdspT676VHdpBuwZR59diRmkDdmK46XG8Sz4lYJuCEZK2FX6E X-Received: by 2002:a05:6402:1bc6:b0:572:e81d:6e70 with SMTP id 4fb4d7f45d1cf-573328e4e6dmr20330a12.15.1715183065606; Wed, 08 May 2024 08:44:25 -0700 (PDT) Received: from [192.168.42.40] ([163.114.131.193]) by smtp.gmail.com with ESMTPSA id er21-20020a056402449500b005726e5e8765sm7691323edb.3.2024.05.08.08.44.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 May 2024 08:44:25 -0700 (PDT) Message-ID: <6f69694b-4281-45a6-92aa-d9d72b918df2@gmail.com> Date: Wed, 8 May 2024 16:44:32 +0100 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 net-next v8 02/14] net: page_pool: create hooks for custom page providers To: Jason Gunthorpe Cc: Mina Almasry , Christoph Hellwig , 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 References: <20b1c2d9-0b37-414c-b348-89684c0c0998@gmail.com> <20240507161857.GA4718@ziepe.ca> <20240507164838.GG4718@ziepe.ca> <0d5da361-cc7b-46e9-a635-9a7a4c208444@gmail.com> <20240507175644.GJ4718@ziepe.ca> <6a50d01a-b5b9-4699-9d58-94e5f8f81c13@gmail.com> <20240507233247.GK4718@ziepe.ca> <54830914-1ec9-4312-96ad-423ac0aeb233@gmail.com> <20240508142530.GR4718@ziepe.ca> Content-Language: en-US From: Pavel Begunkov In-Reply-To: <20240508142530.GR4718@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/8/24 15:25, Jason Gunthorpe wrote: > On Wed, May 08, 2024 at 12:30:07PM +0100, Pavel Begunkov wrote: > >>> I'm not going to pretend to know about page pool details, but dmabuf >>> is the way to get the bulk of pages into a pool within the net stack's >>> allocator and keep that bulk properly refcounted while.> An object like >>> dmabuf is needed for the general case because there are >>> not going to be per-page references or otherwise available. >> >> They are already pinned, memory is owned by the provider, io_uring >> in this case, and it should not be freed circumventing io_uring, >> and at this stage calling release_pages() is not such a hassle, >> especially comparing to introducing an additional object. > > Something needs to co-ordinate when the net stack's allocator is done > with the bulk of pages and when io_uring and do the final > put_user_page() to free it. DMABUF is not an unreasonable choice for > this. When a page pool dies notifies io_uring via the ->destroy callback. Vise versa, when io_uring wants to terminate zerocopy, it releases the interface queue, which kills the page pool, ending in ->destroy again. >>> topic to me, and honestly hacking into the allocator free function >>> seems a bit weird.. >> >> Do you also think that DMA_BUF_IOCTL_SYNC is a weird hack, because >> it "delays free" by pinning the dmabuf object and letting the user >> read memory instead of copying it? I can find many examples > > It seems to me the flow you want is for the driver to allocate a page, > put it on a rx ring, process it through the netstack, and deliver it > to io_uring. io_uring would then sit on the allocation until userspace > it done and return it back to the netstack allocator. That's right, with a note that "driver allocating a page" is not a alloc_page() but grabbing a user page/frag the user registered beforehand. > Hooking the free of the netstack allocator and then defering it seems FWIW, it's not about page pool's ->release_page, it's a slow path and in an ideal world wouldn't be called outside of tear down. > like a weird and indirect way to get there. Why can't io_uring just be > the entity that does the final free and not mess with the logic > allocator? Then the user has to do a syscall (e.g. via io_uring) to return pages, and there we'd need to care how to put the pages efficiently, i.e. hitting the page pool's fast path, e.g. by hoping napi is scheduled and scheduled for the CPU we're running on, or maybe transferring the pages to the right CPU first. Compare it with userspace putting pages into a ring, and the allocator taking from there when needed without any extra synchronisation and hassle just because it's a sole consumer. -- Pavel Begunkov