From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA38C4332F for ; Mon, 6 Nov 2023 21:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbjKFVCq (ORCPT ); Mon, 6 Nov 2023 16:02:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbjKFVCo (ORCPT ); Mon, 6 Nov 2023 16:02:44 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DB9D77 for ; Mon, 6 Nov 2023 13:02:41 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1cc591d8177so32124985ad.3 for ; Mon, 06 Nov 2023 13:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699304560; x=1699909360; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3YVT/6GQJuQ7TjvhzDWajYThozSBRZLd2V3VGmhBHao=; b=Vv8kFQiunIrTYiM6C/oHgHrTapbPb7JHDyQy8sV+NGrJVj1vpNrYPabj6l1M/3k/pe 0KSaaQUhg/ZcT1F6kyHn9rRU9tsCGw6mAcPy1W2Muj+zT0GcbkKhL4D8SwhyL48Uj4UZ rFF1SSEqPu+xI1Kekzu58oyXrQ4wUJNx/0fMnKc1m487QZyiAIBOoj05pUveCBtBrMxk eFetU/y0BG/3cbcuiXHfrCIGHvvDBx7MW7aUUulBj/sRFKx8ycriSAw+tMYWERMHyG1E N4TWBgSpWVRrFhtU7AKB35RgNVw2OAXLY9vuE+BX0uGx/b73D3X4to8/XWfcxOmD2Pvf dqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699304560; x=1699909360; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3YVT/6GQJuQ7TjvhzDWajYThozSBRZLd2V3VGmhBHao=; b=fiVO6PPQvNtAJqzSOjvLQLOpyH9vbLaIjwZwzAUNHMpu7H/pEL+9f5OJb8YCRbKTd4 k0YNOc2O49MnO8nadIsq9Xec9l++/prgGhyBi/kS7JEKsMIAyxgI+OSrkICPO76e9sca d/sHOrJbouCJugwk2JA5WwpuVSI3nMo1CckozaBEtX/jgvdLbr5kZd8KBNEaf+4xod12 wZaF0AT+ef+blpRx7U/JFiLDeJOzPg9md4wX2aGjRM3K5taGg0yn3mNs+VrsP738LvJT n204bOxH9hUMu0xGxRzkev9X8i5iblFiNfVFheMqo1YM4+mPT8Pu5wM+qHYojCu8H+KB LGkg== X-Gm-Message-State: AOJu0YyFxwgjNjGIhgvM1YYhxwd8l3/KBZB4Ew+BGlfiNh/3MQ7EIWM/ UsRrgJBc3v3AVH9aA1OsJJWBe8k= X-Google-Smtp-Source: AGHT+IFMk9K2QPc1yRl8QNToni4u3wTj7lMIW1WMnLhrEu9KTQ1j0Kkg7CJFxK+wf+6qBsS5/cJoFOo= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:ee14:b0:1ca:b952:f5fa with SMTP id z20-20020a170902ee1400b001cab952f5famr509511plb.5.1699304560650; Mon, 06 Nov 2023 13:02:40 -0800 (PST) Date: Mon, 6 Nov 2023 13:02:39 -0800 In-Reply-To: <20231106024413.2801438-7-almasrymina@google.com> Mime-Version: 1.0 References: <20231106024413.2801438-1-almasrymina@google.com> <20231106024413.2801438-7-almasrymina@google.com> Message-ID: Subject: Re: [RFC PATCH v3 06/12] memory-provider: dmabuf devmem memory provider From: Stanislav Fomichev To: Mina Almasry Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Ilias Apalodimas , Arnd Bergmann , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , "Christian =?utf-8?B?S8O2bmln?=" , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Content-Type: text/plain; charset="utf-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/05, Mina Almasry wrote: > Implement a memory provider that allocates dmabuf devmem page_pool_iovs. > > Support of PP_FLAG_DMA_MAP and PP_FLAG_DMA_SYNC_DEV is omitted for > simplicity. > > The provider receives a reference to the struct netdev_dmabuf_binding > via the pool->mp_priv pointer. The driver needs to set this pointer for > the provider in the page_pool_params. > > The provider obtains a reference on the netdev_dmabuf_binding which > guarantees the binding and the underlying mapping remains alive until > the provider is destroyed. > > Signed-off-by: Willem de Bruijn > Signed-off-by: Kaiyuan Zhang > Signed-off-by: Mina Almasry > > --- > include/net/page_pool/helpers.h | 40 +++++++++++++++++ > include/net/page_pool/types.h | 10 +++++ > net/core/page_pool.c | 76 +++++++++++++++++++++++++++++++++ > 3 files changed, 126 insertions(+) > > diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h > index 78cbb040af94..b93243c2a640 100644 > --- a/include/net/page_pool/helpers.h > +++ b/include/net/page_pool/helpers.h > @@ -53,6 +53,7 @@ > #define _NET_PAGE_POOL_HELPERS_H > > #include > +#include > > #ifdef CONFIG_PAGE_POOL_STATS > int page_pool_ethtool_stats_get_count(void); > @@ -111,6 +112,45 @@ page_pool_iov_binding(const struct page_pool_iov *ppiov) > return page_pool_iov_owner(ppiov)->binding; > } > > +static inline int page_pool_iov_refcount(const struct page_pool_iov *ppiov) > +{ > + return refcount_read(&ppiov->refcount); > +} > + > +static inline void page_pool_iov_get_many(struct page_pool_iov *ppiov, > + unsigned int count) > +{ > + refcount_add(count, &ppiov->refcount); > +} > + > +void __page_pool_iov_free(struct page_pool_iov *ppiov); > + > +static inline void page_pool_iov_put_many(struct page_pool_iov *ppiov, > + unsigned int count) > +{ > + if (!refcount_sub_and_test(count, &ppiov->refcount)) > + return; > + > + __page_pool_iov_free(ppiov); > +} > + > +/* page pool mm helpers */ > + > +static inline bool page_is_page_pool_iov(const struct page *page) > +{ > + return (unsigned long)page & PP_DEVMEM; > +} Speaking of bpf: one thing that might be problematic with this PP_DEVMEM bit is that it will make debugging with bpftrace a bit (more) complicated. If somebody were trying to get to that page_pool_iov from the frags, they will have to do the equivalent of page_is_page_pool_iov, but probably not a big deal? (thinking out loud)