* [PATCH v3 net-next 1/5] mm: constify page_is_pfmemalloc() argument
2021-01-31 12:11 [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Alexander Lobakin
@ 2021-01-31 12:11 ` Alexander Lobakin
2021-01-31 12:11 ` [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable() Alexander Lobakin
2021-02-02 1:18 ` [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Jakub Kicinski
2 siblings, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2021-01-31 12:11 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski
Cc: John Hubbard, David Rientjes, Yisen Zhuang, Salil Mehta,
Jesse Brandeburg, Tony Nguyen, Saeed Mahameed, Leon Romanovsky,
Andrew Morton, Jesper Dangaard Brouer, Ilias Apalodimas,
Jonathan Lemon, Willem de Bruijn, Randy Dunlap,
Pablo Neira Ayuso, Dexuan Cui, Jakub Sitnicki, Marco Elver,
Paolo Abeni, Alexander Lobakin, netdev, linux-kernel,
intel-wired-lan, linux-rdma, linux-mm
The function only tests for page->index, so its argument should be
const.
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Acked-by: David Rientjes <rientjes@google.com>
---
include/linux/mm.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ecdf8a8cd6ae..078633d43af9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1584,7 +1584,7 @@ struct address_space *page_mapping_file(struct page *page);
* ALLOC_NO_WATERMARKS and the low watermark was not
* met implying that the system is under some pressure.
*/
-static inline bool page_is_pfmemalloc(struct page *page)
+static inline bool page_is_pfmemalloc(const struct page *page)
{
/*
* Page index cannot be this large so this must be
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable()
2021-01-31 12:11 [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Alexander Lobakin
2021-01-31 12:11 ` [PATCH v3 net-next 1/5] mm: constify page_is_pfmemalloc() argument Alexander Lobakin
@ 2021-01-31 12:11 ` Alexander Lobakin
[not found] ` <20210131122205.GL308988@casper.infradead.org>
2021-02-02 1:18 ` [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Jakub Kicinski
2 siblings, 1 reply; 6+ messages in thread
From: Alexander Lobakin @ 2021-01-31 12:11 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski
Cc: John Hubbard, David Rientjes, Yisen Zhuang, Salil Mehta,
Jesse Brandeburg, Tony Nguyen, Saeed Mahameed, Leon Romanovsky,
Andrew Morton, Jesper Dangaard Brouer, Ilias Apalodimas,
Jonathan Lemon, Willem de Bruijn, Randy Dunlap,
Pablo Neira Ayuso, Dexuan Cui, Jakub Sitnicki, Marco Elver,
Paolo Abeni, Alexander Lobakin, netdev, linux-kernel,
intel-wired-lan, linux-rdma, linux-mm
A bunch of drivers test the page before reusing/recycling for two
common conditions:
- if a page was allocated under memory pressure (pfmemalloc page);
- if a page was allocated at a distant memory node (to exclude
slowdowns).
Introduce a new common inline for doing this, with likely() already
folded inside to make driver code a bit simpler.
Suggested-by: David Rientjes <rientjes@google.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Acked-by: David Rientjes <rientjes@google.com>
---
include/linux/skbuff.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b027526da4f9..0e42c53b8ca9 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2938,6 +2938,22 @@ static inline struct page *dev_alloc_page(void)
return dev_alloc_pages(0);
}
+/**
+ * dev_page_is_reusable - check whether a page can be reused for network Rx
+ * @page: the page to test
+ *
+ * A page shouldn't be considered for reusing/recycling if it was allocated
+ * under memory pressure or at a distant memory node.
+ *
+ * Returns false if this page should be returned to page allocator, true
+ * otherwise.
+ */
+static inline bool dev_page_is_reusable(const struct page *page)
+{
+ return likely(page_to_nid(page) == numa_mem_id() &&
+ !page_is_pfmemalloc(page));
+}
+
/**
* skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page
* @page: The page that was allocated from skb_alloc_page
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage
2021-01-31 12:11 [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Alexander Lobakin
2021-01-31 12:11 ` [PATCH v3 net-next 1/5] mm: constify page_is_pfmemalloc() argument Alexander Lobakin
2021-01-31 12:11 ` [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable() Alexander Lobakin
@ 2021-02-02 1:18 ` Jakub Kicinski
2021-02-02 13:13 ` Alexander Lobakin
2 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2021-02-02 1:18 UTC (permalink / raw)
To: Alexander Lobakin
Cc: David S. Miller, John Hubbard, David Rientjes, Yisen Zhuang,
Salil Mehta, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
Leon Romanovsky, Andrew Morton, Jesper Dangaard Brouer,
Ilias Apalodimas, Jonathan Lemon, Willem de Bruijn, Randy Dunlap,
Pablo Neira Ayuso, Dexuan Cui, Jakub Sitnicki, Marco Elver,
Paolo Abeni, netdev, linux-kernel, intel-wired-lan, linux-rdma,
linux-mm
On Sun, 31 Jan 2021 12:11:16 +0000 Alexander Lobakin wrote:
> page_is_pfmemalloc() is used mostly by networking drivers to test
> if a page can be considered for reusing/recycling.
> It doesn't write anything to the struct page itself, so its sole
> argument can be constified, as well as the first argument of
> skb_propagate_pfmemalloc().
> In Page Pool core code, it can be simply inlined instead.
> Most of the callers from NIC drivers were just doppelgangers of
> the same condition tests. Derive them into a new common function
> do deduplicate the code.
Please resend, this did not get into patchwork :/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage
2021-02-02 1:18 ` [PATCH v3 net-next 0/5] net: consolidate page_is_pfmemalloc() usage Jakub Kicinski
@ 2021-02-02 13:13 ` Alexander Lobakin
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2021-02-02 13:13 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Alexander Lobakin, David S. Miller, John Hubbard, David Rientjes,
Yisen Zhuang, Salil Mehta, Jesse Brandeburg, Tony Nguyen,
Saeed Mahameed, Leon Romanovsky, Andrew Morton,
Jesper Dangaard Brouer, Ilias Apalodimas, Jonathan Lemon,
Willem de Bruijn, Randy Dunlap, Pablo Neira Ayuso, Dexuan Cui,
Jakub Sitnicki, Marco Elver, Paolo Abeni, netdev, linux-kernel,
intel-wired-lan, linux-rdma, linux-mm
From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 1 Feb 2021 17:18:35 -0800
> On Sun, 31 Jan 2021 12:11:16 +0000 Alexander Lobakin wrote:
> > page_is_pfmemalloc() is used mostly by networking drivers to test
> > if a page can be considered for reusing/recycling.
> > It doesn't write anything to the struct page itself, so its sole
> > argument can be constified, as well as the first argument of
> > skb_propagate_pfmemalloc().
> > In Page Pool core code, it can be simply inlined instead.
> > Most of the callers from NIC drivers were just doppelgangers of
> > the same condition tests. Derive them into a new common function
> > do deduplicate the code.
>
> Please resend, this did not get into patchwork :/
I suspected it would be so as I got reports about undelivered mails
due to unavailability of vger.kernel.org for some reasons Will do.
Al
^ permalink raw reply [flat|nested] 6+ messages in thread