Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp834095lqs; Tue, 5 Mar 2024 19:49:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbfQgq/BSQ+Ud77l4dyHJP62g4uQOVDoLvu3/tkhrE0E/pa+zS55WkySMYWQRhuzT+EBIXAR2SBN6+QP34gqkeu7q2Qx1gNELiP8JIlw== X-Google-Smtp-Source: AGHT+IF1UpVg2f8YS3Csl19GnU58mCR2bH4hNWs/AMUaY/4UIWaL8ogdGgCIEYpDbGAY9QDoKYKd X-Received: by 2002:a17:902:a9c1:b0:1db:be98:e9a with SMTP id b1-20020a170902a9c100b001dbbe980e9amr4157399plr.26.1709696981556; Tue, 05 Mar 2024 19:49:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709696981; cv=pass; d=google.com; s=arc-20160816; b=LQOjJPLAraDimnCZnxKpPoNSppviQJfi+GkC36HiSg8RyjWdXD7IM1cKWPFryEsgMF XFY4XzAbt/6NX7HS01vXjU1rKkLp+I2b9t8g+nd7ddaMpKVgfm3HufyQgH+pb7s92443 ohnMB8a9lzjhQSCvFT6NgKcehxg8wFnhkZOSL7kti58dNlixwnG3SICOOFdBGPEfmo/O Sd2rqNK+IXxhveseTw4fygR18nuyRlueYBqwg4Zu2VYpUu8Pa/pfvBgHtUm0qg+I9+PJ hINGUZMC+VPkN4XyWdMKyaSfxvFO2poFo/YYh+QkxkNG4Y3tJV8aZTm6L5m0YvfaUmKs ZvoQ== 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:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=W/AZhM1ardFsAGX29qTgbwwqhyfXbQstP0cTfps3sJk=; fh=6vacEKAL/3hmaGvkDiVAI/YaLjHxLh0UFbkjQzdjPNQ=; b=F+Q/EgAhqR72pC1z24xvaydDlvkk7zIrOs6Amf06FBWCMzz23BTN+rJIW8dGBo26aU 3dRr9OsXeRtuXZHX+BVETQeMquZfyoKUdGMnI3YJJNCx8JfPdEnrCO1g9Bbt6SMNhciY kqHVMXsc4Le1rHgd9CYGmb3YY3pIpzKLUjPDTdjKri8jkttFUXNfUatYCXpn9vKDPu3z 5mnLzRAtNu5wEBvLeJJlolEDs656jlf5XahLSxNGtiyKyd2xoEWtxMeohuQjyagaAgUt MbmSPW16sMGZMHp1BQVWeSDbEV2FtUcMfdjzbfPTB+vF0R21QHWdHlzARkRlpz+HYx1t f7Vw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@davidwei-uk.20230601.gappssmtp.com header.s=20230601 header.b=RH95CX61; arc=pass (i=1 dkim=pass dkdomain=davidwei-uk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-93249-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93249-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y9-20020a17090264c900b001dcdf7eb233si10070652pli.45.2024.03.05.19.49.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 19:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93249-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=@davidwei-uk.20230601.gappssmtp.com header.s=20230601 header.b=RH95CX61; arc=pass (i=1 dkim=pass dkdomain=davidwei-uk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-93249-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93249-linux.lists.archive=gmail.com@vger.kernel.org" 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 A2F93B24AA8 for ; Wed, 6 Mar 2024 02:47:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12ED6DDA9; Wed, 6 Mar 2024 02:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="RH95CX61" Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 13FD9D53F for ; Wed, 6 Mar 2024 02:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709693221; cv=none; b=Yy8ObFeqrai/yt+jRcUx+LJNfucPlZMLBL2EwI82n/NjgUaBikL+wiaWPiFQRqcJujOGqTwl7DJw83D4RbVV6FnIDVfm2db5ku2uoyxIfFxTC8Ir9Ynktfe4VQr7Y6iSqjV58IcrcXmvkHXpS5MeY7SKDvjO9aIRGRQVfDpW6mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709693221; c=relaxed/simple; bh=vgsULBah38khq6izlM1CG5mUxG895JBR5VzGpBHy3FY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kGLNgDhtgiWUycI/QBrWWD2Y4KSgX79CiRVfyRUe3O2M33dCarM5nSOwQrWLhObxvJ4DiFMQdxxbAi9W8QrZKv60+DFtrJKyi3PCw/I77F08RCSPc0Lb2gU+142qFrBtho3q/MnxM+4InOQ6CaehC0tNg1hvVARHyOE5M62fTXQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk; spf=none smtp.mailfrom=davidwei.uk; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b=RH95CX61; arc=none smtp.client-ip=209.85.160.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-21fa6e04835so2371769fac.1 for ; Tue, 05 Mar 2024 18:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1709693217; x=1710298017; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=W/AZhM1ardFsAGX29qTgbwwqhyfXbQstP0cTfps3sJk=; b=RH95CX612YwxRLTNIu4v3zLtCu3aw3P0O5Xg9O0RfH8Z/hp9seSg/nGkaua/Aec2mt qGI9bRFbbTxabTtQi3xGtF90fQzVxSqwH1lS2Rg2WmjU6EpO/A8STxSid0/vLmD7Apwu hMOkSWTa8K6z8RDyvx1Vdz/l2gw3EHdLT4pYT/IQt7zxAH3pm4HvAmu1DK0YccC2v7fX pAqLegabU1gggT7hI+WjI4Fp5Lrw9hf97XcshLS3mEKtKOeLo6DVidu5BryVC3v3u7BU 925rceimbjXK/QAEgca22Ma6vB9fB9+1j7ehWInrT4/BpX2fVfaPN5B9GQxtvuXasfbO Bp+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709693217; x=1710298017; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W/AZhM1ardFsAGX29qTgbwwqhyfXbQstP0cTfps3sJk=; b=qEHbYSwhfju4QdUN52phZWDHvUNZW2l4su4sFAHiOzeeeCZojZrdBK9eF+S0TShPfF m2h6bhSzVl4vivut+dlqtpqpR8RuhIN8Qorp6uWsfTxcwbhhx+aHxBeek29ECpbKfzQP mAhc0lI5QsgLeOUCoxLX8JUjOXB/BbS8POZKvNxVhziALLOXim+FW5hXx5SeZ33W8ovc A0tHaIS2DnJWX5OwZRR0VdGdWvNIwGSfVkErI298yd+lqXFTZiq0riuW40RK6r1Vviy8 8jATLE7xroPu78lZ/oL7zAtZxnc40mEks1K7udqCfGumZOtRt4wugkWxyU65OKTko5xc cV9A== X-Forwarded-Encrypted: i=1; AJvYcCVcGmmya7HMj31pRkGRvaeh2wk1lZ1sMvhIB42g63UqhflCIK2oN/gnIHfPABjRSBfeBgc0GS5SVAFV05SZSRApZetjfjOJ1p9Mcr0P X-Gm-Message-State: AOJu0YxzR6ojadl2PpJkLD4IUCPdiCuB39oR8us5XLD+FR7vKSXqz1rx tDP1W9Ku90AWbDncNnfr6YZjind78FKrkxQ15xlKp8/YhEAdi+I7a/9MU7qDcwOFHBoQ1FvKUdg UHQ8= X-Received: by 2002:a05:6870:461b:b0:21e:4a2a:f060 with SMTP id z27-20020a056870461b00b0021e4a2af060mr4180063oao.13.1709693216865; Tue, 05 Mar 2024 18:46:56 -0800 (PST) Received: from [192.168.1.24] (71-212-18-124.tukw.qwest.net. [71.212.18.124]) by smtp.gmail.com with ESMTPSA id r16-20020a62e410000000b006e46047fe04sm9667498pfh.204.2024.03.05.18.46.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Mar 2024 18:46:56 -0800 (PST) Message-ID: <6562b8b0-6cc0-4652-b746-75549801c002@davidwei.uk> Date: Tue, 5 Mar 2024 18:46:55 -0800 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 v6 09/15] memory-provider: dmabuf devmem memory provider Content-Language: en-GB To: Mina Almasry 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 , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Pavel Begunkov , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang References: <20240305020153.2787423-1-almasrymina@google.com> <20240305020153.2787423-10-almasrymina@google.com> <383c4870-167f-4123-bbf3-928db1463e01@davidwei.uk> From: David Wei In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024-03-05 18:42, Mina Almasry wrote: > On Tue, Mar 5, 2024 at 6:28 PM David Wei wrote: >> >> On 2024-03-04 18:01, Mina Almasry wrote: >>> + if (pool->p.queue) >>> + binding = READ_ONCE(pool->p.queue->binding); >>> + >>> + if (binding) { >>> + pool->mp_ops = &dmabuf_devmem_ops; >>> + pool->mp_priv = binding; >>> + } >> >> This is specific to TCP devmem. For ZC Rx we will need something more >> generic to let us pass our own memory provider backend down to the page >> pool. >> >> What about storing ops and priv void ptr in struct netdev_rx_queue >> instead? Then we can both use it. > > Yes, this is dmabuf specific, I was thinking you'd define your own > member of netdev_rx_queue, and then add something like this to > page_pool_init: > > + if (pool->p.queue) > + io_uring_metadata = READ_ONCE(pool->p.queue->io_uring_metadata); > + > + /* We don't support rx-queues that are configured for both > io_uring & dmabuf binding */ > + BUG_ON(io_uring_metadata && binding); > + > + if (io_uring_metadata) { > + pool->mp_ops = &io_uring_ops; > + pool->mp_priv = io_uring_metadata; > + } > > I.e., we share the pool->mp_ops and the pool->mp_priv but we don't > really need to share the same netdev_rx_queue member. For me it's a > dma-buf specific data structure (netdev_dmabuf_binding) and for you > it's something else. This adds size to struct netdev_rx_queue and requires checks on whether both are set. There can be thousands of these structs at any one time so if we don't need to add size unnecessarily then that would be best. We can disambiguate by comparing &mp_ops and then cast the void ptr to our impl specific objects. What do you not like about this approach? > > page_pool_init() probably needs to validate that the queue is > configured for dma-buf or io_uring but not both. If it's configured > for both then the user is doing something funky we shouldn't support. > > Perhaps I can make the intention clearer by renaming 'binding' to > something more specific to dma-buf like queue->dmabuf_binding, to make > it clear that this is the dma-buf binding and not some other binding > like io_uring? >