Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp144786rdh; Tue, 13 Feb 2024 12:02:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkKmpqyoB06J3cYQ1HwkP9n2t1jJC+snNcvolXYoIS/xM+RgzudDxWOc+2FFV3pA/bw0hzLmtEinCtWK6YY8OofoKPDn3NMS2pz/sT5Q== X-Google-Smtp-Source: AGHT+IHdn3jlhJkpacV+QjJRkfSmx1zWzQsKa3F+D/AYK0a/BR/kkDDq3RkMGSNbQCiw9rNa5nav X-Received: by 2002:a05:6a20:d80e:b0:19e:a6ea:683a with SMTP id iv14-20020a056a20d80e00b0019ea6ea683amr736288pzb.50.1707854538940; Tue, 13 Feb 2024 12:02:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707854538; cv=pass; d=google.com; s=arc-20160816; b=Rc3XnYiLhL/xcGBO76Dd0M12wu51tDkvtbF6f9lkOUW1ROnlSaxLLm0TV+x/thN+PL g0u1DtkVtSE5dy1PDNTYCT8sjVQU6059gpUEI24C4LGsdaLDlGkmflpG5AQPZY6O+Fze wzf0yGqKazgrycwFFC9xDBtnEVv3Xyi1E7iCe48iWahqNF+9krXfvK2v29h/zdkvyu+U 6SarzHej8JVBg6jCUsQvN6L674gk64KPKSKcpznaI1OryL28ChuExqKhfuRhaDn+VQ3b oJvceQHBxJEcsYiT2wb+mDOsHUiZLdG681JcA4UMeb5LS8wgj5y7tzfBcMyC1oiOEu10 GOFw== 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=aeZw1WsdK0ILhztiGUDCvc9s83gleGWTx/2AVhzfBto=; fh=nF7ehelDSDBP3ojzl1bEdFozLaeuh/LIOSkx67cs1oU=; b=bfEg0wImdpgC3sLLDhXbEU+LYhSehvgZkuAlWua7x51vgp97UzWYgS2pAbsAw/CwhU TIyckuQY78vGwLyoIe/qpi/pSudFsioOcVIh4cOsne01TWubU1z6fOJw4oyuDHFcgTcS dR9r5ZN0jQ0qqbj7QnccRNzV/ncLyM8Njxd3pf5KOu8NmS65jyjuZvD3PGBn26Ei0hKf oHeEjwa0ziWxyfRyB+l34AlMWWhY0ZjiuoobJztqay2RQFZUnRDDK+w8zZ4SfusGlaS5 Y8oCuAo0b0SUII5JfjyuzQXT0nb2355EIAemOh+s9kSxS17X0S0SFacqdQJl1t//eXtx JDwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WPBQthgA; 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-64202-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64202-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUBWYU8IpQ3gBiVqpx33p9ddVqgA+r4zX3RkkYlDEre6aHpXIMYY3IgZ9rbdhKNb+mOvaVa+N0/oQ9j4GQ+rD1yovqLBy+mZXeT6E68Pg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j20-20020a056a00175400b006e086e4c2c9si7151103pfc.22.2024.02.13.12.02.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 12:02:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64202-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=WPBQthgA; 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-64202-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64202-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 61B63282698 for ; Tue, 13 Feb 2024 20:02:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97A5460BB7; Tue, 13 Feb 2024 20:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WPBQthgA" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 64C6260872 for ; Tue, 13 Feb 2024 20:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707854517; cv=none; b=Oea6c+TkNQIUMwSVORSwpINJJgz/488RzagOgdYE41c14OJINJPni4ZUHvpPlZzxiSAmnlQEqkLYCu1Ryl6l7JEXTJwpMgeowJLg+ecVtybMqagkG5i6f8KCCO+yzRpy4J/+q/ng0eWqSueCsMoVStIOMTUp6CNhkMq1gr8/0Us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707854517; c=relaxed/simple; bh=V8RWr3buxdjWtLSDsasgQvCqzQOEr/31YvPitYMfD9M=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=n2MFXETX5xNUt2shnP0/niMvwtN/kDNS/KeuxmzWs8cygIEZTB4OHXOYT3ekczMmDWh1RD2Y+fqnrTFWdO3mrLXRyRz5YWFXSstQ1SQ8dWGOsx/YRdsOk6ScNOZBZegZb5Zxf9lwqRmox51XDDljksZGfueK55V18zuvMgded1E= 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=WPBQthgA; arc=none smtp.client-ip=209.85.218.43 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-f43.google.com with SMTP id a640c23a62f3a-a30e445602cso21248266b.0 for ; Tue, 13 Feb 2024 12:01:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707854514; x=1708459314; 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=aeZw1WsdK0ILhztiGUDCvc9s83gleGWTx/2AVhzfBto=; b=WPBQthgAOycku3bjtIr8wr5K9WkkXBqS3RMi2CMmfA/JK/iM2xslGlJ4FgFCrPGknW s27Am8uuZudDluiIg6pUGym9f6z+KCTCa90ZgJqusRWjdacMKwKCCDriV5/Fr/Gfa/RR p9Fsloiz3r2Zw4HDKdd29w4gxRuQk7zF+e710D4u+llV4yzIH4yZGpbzEOtJWpfpPBea DsbZ6TVLmfih1YwjJK3K4v6b25pYn4z/2V5kJy1aaVF7eS2oJ4r37KDW1qIFGZylZbnI A5HuiMxjEE/K39JjADBKHxu4AjRzKlKvGyKprrOtNYpyQxazACYo/Z3aSBckFB02Muna K24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707854514; x=1708459314; 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=aeZw1WsdK0ILhztiGUDCvc9s83gleGWTx/2AVhzfBto=; b=l43qUr8UvWdIjFNHyFYijPyB75CvRDPo23xO+auijP9KTTMiwVRiHb6ZnCg6VfOh1e shFiIHY0R2UVzI4PrI2mCAT2QYn6PqB5dBOoooqrJdPRHTNMNgnS1LC2/wD9koJaJlYt 4IgKM/xexw1PekjIa/8rN3dYCFeEnqCn9De9ON5a/5zRqN1dzScJe7z+uz6jUc7+ke1K S12Hju3YgurcTeKhTIt8JGz4S0600eunHHTnxxM/u+ays+f8R322qLwaa+z1ON2NpcGW L3j2YXJSzgBp/ePfq4eMv6sPBODOzK4xpD/dG3ELl353UzDqZvPL7oPs/iXt0UVc2hK+ gGtQ== X-Forwarded-Encrypted: i=1; AJvYcCXNxc8/7dfGFiOyJvwjVlGFmDAdoqnq3CpmFmM/J9hPmEAsX+0HpSDpEhRjN2wIm9mzpQtd14t0ZLAY1UWPxm6DELrXt2ssmAx/PnBF X-Gm-Message-State: AOJu0Yy//MM0A7I8aYsAxjJY07pGPxe0abRE2HAqf4+TwAZ0SG0skrPA IqYwX5QMmK3qPkwlmDlBnYZfPhdYgZ91esD2GJ1P15nLrokyYrf2LdH6YkASn09irp3E3tIa/fV LLhuGTN4PhVe2WSG2MVmj+3mn19HCBc4JHT0D X-Received: by 2002:a17:906:6555:b0:a3c:e99f:be1d with SMTP id u21-20020a170906655500b00a3ce99fbe1dmr3141450ejn.18.1707854513537; Tue, 13 Feb 2024 12:01:53 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231218024024.3516870-1-almasrymina@google.com> <20231218024024.3516870-6-almasrymina@google.com> <94ff0733-5987-4bf5-a53c-011e03aa6323@gmail.com> In-Reply-To: <94ff0733-5987-4bf5-a53c-011e03aa6323@gmail.com> From: Mina Almasry Date: Tue, 13 Feb 2024 12:01:38 -0800 Message-ID: Subject: Re: [RFC PATCH net-next v5 05/14] netdev: netdevice devmem allocator To: Pavel Begunkov Cc: Mathieu Desnoyers , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , 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 , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 13, 2024 at 5:24=E2=80=AFAM Pavel Begunkov wrote: > > On 12/18/23 02:40, Mina Almasry wrote: > > Implement netdev devmem allocator. The allocator takes a given struct > > netdev_dmabuf_binding as input and allocates net_iov from that > > binding. > > > > The allocation simply delegates to the binding's genpool for the > > allocation logic and wraps the returned memory region in a net_iov > > struct. > > > > Signed-off-by: Willem de Bruijn > > Signed-off-by: Kaiyuan Zhang > > Signed-off-by: Mina Almasry > > > > --- > > > > v1: > > - Rename devmem -> dmabuf (David). > > > > --- > > include/net/devmem.h | 12 ++++++++++++ > > include/net/netmem.h | 26 ++++++++++++++++++++++++++ > > net/core/dev.c | 38 ++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 76 insertions(+) > > > ... > > diff --git a/include/net/netmem.h b/include/net/netmem.h > > index 45eb42d9990b..7fce2efc8707 100644 > > --- a/include/net/netmem.h > > +++ b/include/net/netmem.h > > @@ -14,8 +14,34 @@ > > > > struct net_iov { > > struct dmabuf_genpool_chunk_owner *owner; > > + unsigned long dma_addr; > > }; > > > > +static inline struct dmabuf_genpool_chunk_owner * > > +net_iov_owner(const struct net_iov *niov) > > +{ > > + return niov->owner; > > +} > > + > > +static inline unsigned int net_iov_idx(const struct net_iov *niov) > > +{ > > + return niov - net_iov_owner(niov)->niovs; > > +} > > + > > +static inline dma_addr_t net_iov_dma_addr(const struct net_iov *niov) > > +{ > > + struct dmabuf_genpool_chunk_owner *owner =3D net_iov_owner(niov); > > + > > + return owner->base_dma_addr + > > + ((dma_addr_t)net_iov_idx(niov) << PAGE_SHIFT); > > Looks like it should have been niov->dma_addr > Yes, indeed. Thanks for catching. > > +} > > + > > +static inline struct netdev_dmabuf_binding * > > +net_iov_binding(const struct net_iov *niov) > > +{ > > + return net_iov_owner(niov)->binding; > > +} > > + > > /* netmem */ > > > > struct netmem { > ... > > -- > Pavel Begunkov --=20 Thanks, Mina