From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: davem@davemloft.net, grygorii.strashko@ti.com,
saeedm@mellanox.com, leon@kernel.org, ast@kernel.org,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
ilias.apalodimas@linaro.org, netdev@vger.kernel.org,
daniel@iogearbox.net, jakub.kicinski@netronome.com,
john.fastabend@gmail.com, brouer@redhat.com
Subject: Re: [PATCH v4 net-next 1/4] net: core: page_pool: add user cnt preventing pool deletion
Date: Thu, 27 Jun 2019 21:44:46 +0200 [thread overview]
Message-ID: <20190627214317.237e5926@carbon> (raw)
In-Reply-To: <20190625175948.24771-2-ivan.khoronzhuk@linaro.org>
On Tue, 25 Jun 2019 20:59:45 +0300
Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> wrote:
> Add user counter allowing to delete pool only when no users.
> It doesn't prevent pool from flush, only prevents freeing the
> pool instance. Helps when no need to delete the pool and now
> it's user responsibility to free it by calling page_pool_free()
> while destroying procedure. It also makes to use page_pool_free()
> explicitly, not fully hidden in xdp unreg, which looks more
> correct after page pool "create" routine.
I don't think that "create" and "free" routines paring looks "more
correct" together.
Maybe we can scale back your solution(?), via creating a page_pool_get()
and page_pool_put() API that can be used by your driver, to keep the
page_pool object after a xdp_rxq_info_unreg() call. Then you can use
it for two xdp_rxq_info structs, and call page_pool_put() after you
have unregistered both.
The API would basically be:
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index b366f59885c1..691ddacfb5a6 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -357,6 +357,10 @@ static void __warn_in_flight(struct page_pool *pool)
void __page_pool_free(struct page_pool *pool)
{
WARN(pool->alloc.count, "API usage violation");
+
+ if (atomic_read(&pool->user_cnt) != 0)
+ return;
+
WARN(!ptr_ring_empty(&pool->ring), "ptr_ring is not empty");
/* Can happen due to forced shutdown */
@@ -372,6 +376,19 @@ void __page_pool_free(struct page_pool *pool)
}
EXPORT_SYMBOL(__page_pool_free);
+void page_pool_put(struct page_pool *pool)
+{
+ if (!atomic_dec_and_test(&pool->user_cnt))
+ __page_pool_free(pool);
+}
+EXPORT_SYMBOL(page_pool_put);
+
+void page_pool_get(struct page_pool *pool)
+{
+ atomic_inc(&pool->user_cnt);
+}
+EXPORT_SYMBOL(page_pool_get);
+
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2019-06-27 19:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 17:59 [PATCH v4 net-next 0/4] net: ethernet: ti: cpsw: Add XDP support Ivan Khoronzhuk
2019-06-25 17:59 ` [PATCH v4 net-next 1/4] net: core: page_pool: add user cnt preventing pool deletion Ivan Khoronzhuk
2019-06-26 1:36 ` Willem de Bruijn
2019-06-26 14:01 ` Ivan Khoronzhuk
2019-06-26 10:42 ` Jesper Dangaard Brouer
2019-06-26 10:49 ` Ivan Khoronzhuk
2019-06-26 11:51 ` Jesper Dangaard Brouer
2019-06-26 12:39 ` Ivan Khoronzhuk
2019-06-27 19:44 ` Jesper Dangaard Brouer [this message]
2019-06-27 22:02 ` Ivan Khoronzhuk
2019-06-28 6:35 ` Jesper Dangaard Brouer
2019-06-28 8:53 ` Ivan Khoronzhuk
2019-06-25 17:59 ` [PATCH v4 net-next 2/4] net: ethernet: ti: davinci_cpdma: add dma mapped submit Ivan Khoronzhuk
2019-06-25 17:59 ` [PATCH v4 net-next 3/4] net: ethernet: ti: davinci_cpdma: return handler status Ivan Khoronzhuk
2019-06-26 2:17 ` Willem de Bruijn
2019-06-25 17:59 ` [PATCH v4 net-next 4/4] net: ethernet: ti: cpsw: add XDP support Ivan Khoronzhuk
2019-06-25 20:46 ` [PATCH v4 net-next 0/4] net: ethernet: ti: cpsw: Add " David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190627214317.237e5926@carbon \
--to=brouer@redhat.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ivan.khoronzhuk@linaro.org \
--cc=jakub.kicinski@netronome.com \
--cc=john.fastabend@gmail.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).