From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 4403C2638A3; Thu, 20 Feb 2025 19:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740080055; cv=none; b=T39WJNNkUPZ6Tr5grbKtg6Kkqxo1qBg0W3KKjlKmDWun00+H9+xIWqBttzC8AuUMylV6GPlsNTOwpFKwpfSQJrzg+I5uxYBFbkIAXDqselJh4q3CTwLsWXSgAJy9uDH5wsWBCo6njlWzTVNOw5tpCgOG91eoYZ5wzQsiMA31KV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740080055; c=relaxed/simple; bh=lLvSCfGzR1G+5sP88MJmJoxG3MsULk9EywePmaCSpPA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ixZkP6kjQ9mqY9+gd9kvWRuJiBHYI035rGJpa1Wl4asJbP3fLs7FUygmz89v+yEI+pexAVeJbqhAPMdyDcTyhCrYcBxO00x6D1bHL7jerzTE/RDGFuv9jW68WHgZmxj0XVScjWkC5cgxy7bdjeOKhv/g1UbyQ/8CIjrXC3zFEas= 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=fo8Smy6I; arc=none smtp.client-ip=209.85.216.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fo8Smy6I" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2fc042c9290so2256968a91.0; Thu, 20 Feb 2025 11:34:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740080043; x=1740684843; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZTiSUkoMecG9RlHxgT6mcfjx4A34996Guxh4H1K/phg=; b=fo8Smy6Iuc/abaQfBRgopj6QuLwQ94TnGkjkgZAxZuHqftzKqkuMB028lQquqsCjcc I4Kj4/YceLJ9W564uYkMCwVYDsx7Rrm+bFQe/wplg4r5Bno7YZsDrqcVq4TTloTAPCfN hbOIupyTOUzAA/Lf+WtP7OThLSCbwdVcfKAq/mNGxWE/EC04M087bSCSV7cCEIW1ztIg d3+4FGnmtomfQfefKAs1DxDmVpcYlVMJm2FB6btoKiv6/ofH12YXvAi/Y1sVkHbLozIC wxW1EE2OFrgZ23/Nrq5mPRSTQBXkbVTUHmMpOlX4vkDb3KKJOV9SGGQcWMcxooEO/fsu SVcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740080043; x=1740684843; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZTiSUkoMecG9RlHxgT6mcfjx4A34996Guxh4H1K/phg=; b=IOMOCkxMS3VFBNA+2gyIEvplWeT/S3MAjC4TWW9San1XDMwyYvgG50yY1KHVB98GVG usZ/3zT/1qMMzANBurg4iru9i5YzhEqXbNO+RB73nrdNaTDTDyrYFJ7qQLYKcxnxd6rL DNRi1uRgqk7Pm7m+Rn+hCxVUmOUigRIZoPSP3xlBYdB1M9NXVvr32Ib7zYexVBIVwfid lB9Uen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FYozsg== X-Received: by 2002:a17:90b:35ce:b0:2ee:cded:9ac7 with SMTP id 98e67ed59e1d1-2fce78ad9ddmr594804a91.20.1740080043522; Thu, 20 Feb 2025 11:34:03 -0800 (PST) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-220d53494c0sm124354095ad.6.2025.02.20.11.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 11:34:03 -0800 (PST) Date: Thu, 20 Feb 2025 11:34:02 -0800 From: Stanislav Fomichev To: Mina Almasry Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Donald Hunter , Jonathan Corbet , Andrew Lunn , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Kuniyuki Iwashima , Willem de Bruijn , David Ahern , Neal Cardwell , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Stefan Hajnoczi , Stefano Garzarella , Shuah Khan , sdf@fomichev.me, asml.silence@gmail.com, dw@davidwei.uk, Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , Samiullah Khawaja Subject: Re: [PATCH net-next v4 1/9] net: add get_netmem/put_netmem support Message-ID: References: <20250220020914.895431-1-almasrymina@google.com> <20250220020914.895431-2-almasrymina@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20250220020914.895431-2-almasrymina@google.com> On 02/20, Mina Almasry wrote: > Currently net_iovs support only pp ref counts, and do not support a > page ref equivalent. > > This is fine for the RX path as net_iovs are used exclusively with the > pp and only pp refcounting is needed there. The TX path however does not > use pp ref counts, thus, support for get_page/put_page equivalent is > needed for netmem. > > Support get_netmem/put_netmem. Check the type of the netmem before > passing it to page or net_iov specific code to obtain a page ref > equivalent. > > For dmabuf net_iovs, we obtain a ref on the underlying binding. This > ensures the entire binding doesn't disappear until all the net_iovs have > been put_netmem'ed. We do not need to track the refcount of individual > dmabuf net_iovs as we don't allocate/free them from a pool similar to > what the buddy allocator does for pages. > > This code is written to be extensible by other net_iov implementers. > get_netmem/put_netmem will check the type of the netmem and route it to > the correct helper: > > pages -> [get|put]_page() > dmabuf net_iovs -> net_devmem_[get|put]_net_iov() > new net_iovs -> new helpers > > Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev I remember you wanted to have more fine grained refcnt, but starting with this is good enough for me.