page_pool: add DMA_ATTR_WEAK_ORDERING on all mappings
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 page_pool: add DMA_ATTR_WEAK_ORDERING on all mappings
Commit c519fe9a4f0d ("bnxt: add dma mapping attributes") added DMA_ATTR_WEAK_ORDERING to DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERING only seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.
To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add DMA_ATTR_WEAK_ORDERING on all page pool DMA mappings.
We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
---
CC: [email protected]
CC: [email protected]
--- net/core/page_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/core/page_pool.c +3 -2
@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool *pool, struct page *page)*/ dma =dma_map_page_attrs (pool->p.dev, page,0 , (PAGE_SIZE << pool->p.order), - pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC ); + pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC | +DMA_ATTR_WEAK_ORDERING );if (dma_mapping_error (pool->p.dev, dma))return false;
@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)/* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs (pool->p.dev, dma,PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC ); +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING );page_pool_set_dma_addr (page,0 ); skip_dma_unmap:page_pool_clear_pp_info (page);
Signature · 1 line
2.39.2
This seems sane to me, especially since we use page pool on the Rx path for normal drivers. If anyone has a different opinion please shout\
Quoted 50 lines · Jakub Kicinski
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add
DMA_ATTR_WEAK_ORDERINGon all page pool DMA mappings.We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]--- net/core/page_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/core/page_pool.c +3
-3@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool *pool, struct page *page)*/ dma =dma_map_page_attrs (pool->p.dev, page,0 , (PAGE_SIZE << pool->p.order), - pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC ); + pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC | +DMA_ATTR_WEAK_ORDERING );if (dma_mapping_error (pool->p.dev, dma))return false;@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)/* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs (pool->p.dev, dma,PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC ); +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING );page_pool_set_dma_addr (page,0 ); skip_dma_unmap:page_pool_clear_pp_info (page); --
Quoted 2 lines
2.39.2
Quoted 50 lines · Jakub Kicinski
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add
DMA_ATTR_WEAK_ORDERINGon all page pool DMA mappings.We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]--- net/core/page_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/core/page_pool.c +3
-3@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool *pool, struct page *page)*/ dma =dma_map_page_attrs (pool->p.dev, page,0 , (PAGE_SIZE << pool->p.order), - pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC ); + pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC | +DMA_ATTR_WEAK_ORDERING );if (dma_mapping_error (pool->p.dev, dma))return false;@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)/* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs (pool->p.dev, dma,PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC ); +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING );page_pool_set_dma_addr (page,0 ); skip_dma_unmap:page_pool_clear_pp_info (page); --
Quoted 2 lines
2.39.2
To Hellwig,
Quoted 4 lines · Jakub Kicinski
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
Quoted 9 lines
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add
DMA_ATTR_WEAK_ORDERINGon all page pool DMA mappings.
This sounds reasonable to me, but I don't know the DMA APIs well enough. Thus, I would like to hear if Hellwig thinks this is okay?
Quoted 35 lines
We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]--- net/core/page_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/core/page_pool.c +3
-2@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool *pool, struct page *page)*/ dma =dma_map_page_attrs (pool->p.dev, page,0 , (PAGE_SIZE << pool->p.order), - pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC ); + pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC | +DMA_ATTR_WEAK_ORDERING );if (dma_mapping_error (pool->p.dev, dma))return false;@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)/* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs (pool->p.dev, dma,PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC ); +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING );page_pool_set_dma_addr (page,0 ); skip_dma_unmap:page_pool_clear_pp_info (page);
Jesper Dangaard Brouer
Acked-byQuoted 11 lines · Jesper Dangaard Brouer
To Hellwig,
Quoted 8 lines · Jakub Kicinski
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.
Quoted 8 lines
Quoted 5 lines
To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add
DMA_ATTR_WEAK_ORDERINGon all page pool DMA mappings.This sounds reasonable to me, but I don't know the DMA APIs well enough. Thus, I would like to hear if Hellwig thinks this is okay?
Acking this patch, as we can always revert if Hellwig have objections later.
Quoted 36 lines
Quoted 36 lines
We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
---
net/core/page_pool.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)net/core/page_pool.c +3
-2@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool*pool, struct page *page) */ dma = dma_map_page_attrs(pool->p.dev, page, 0, (PAGE_SIZE << pool->p.order), - pool->p.dma_dir, DMA_ATTR_SKIP_CPU_SYNC); + pool->p.dma_dir, DMA_ATTR_SKIP_CPU_SYNC | + DMA_ATTR_WEAK_ORDERING); if (dma_mapping_error(pool->p.dev, dma)) return false;@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page) /* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs(pool->p.dev, dma, PAGE_SIZE << pool->p.order, pool->p.dma_dir, - DMA_ATTR_SKIP_CPU_SYNC); + DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING); page_pool_set_dma_addr(page, 0);
skip_dma_unmap:
page_pool_clear_pp_info(page);
From: Jakub Kicinski <[email protected]>
Date: Mon, 17 Apr 2023 08:28:05 -0700
Quoted 8 lines
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.
Quoted 8 lines
To make the page pool migration in drivers which set this flag less of a risk (of regressing the precious sparc database workloads or whatever needed this) let's add
DMA_ATTR_WEAK_ORDERINGon all page pool DMA mappings.We could make this a driver opt-in but frankly I don't think it's worth complicating the API. I can't think of a reason why device accesses to packet memory would have to be ordered.
And you do that 2 days before I send this: [0] :D
Just jokin' :p
Unconditional weak ordering seems reasonable to me as well. BTW, I've seen one driver converted to PP already, which manages DMA mappings on its own *solely* because it needs to map stuff with weak ordering =\
It could be switched to PP builtin map handling thanks to this change (-100 locs).
Quoted 24 lines
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]--- net/core/page_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/core/page_pool.c +2
-1@@ -316,7 +316,8 @@ static bool page_pool_dma_map(struct page_pool *pool, struct page *page)*/ dma =dma_map_page_attrs (pool->p.dev, page,0 , (PAGE_SIZE << pool->p.order), - pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC ); + pool->p.dma_dir,DMA_ATTR_SKIP_CPU_SYNC | +DMA_ATTR_WEAK_ORDERING );if (dma_mapping_error (pool->p.dev, dma))return false;
net/core/page_pool.c void page_pool_release_page(struct page_pool *pool, struct page *page) · line 491
Quoted 8 lines
net/core/page_pool.c +1
-1@@ -484,7 +485,7 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)/* When page is unmapped, it cannot be returned to our pool */ dma_unmap_page_attrs (pool->p.dev, dma,PAGE_SIZE << pool->p.order, pool->p.dma_dir, -DMA_ATTR_SKIP_CPU_SYNC ); +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_WEAK_ORDERING );page_pool_set_dma_addr (page,0 ); skip_dma_unmap:page_pool_clear_pp_info (page);
[0]
https://github.com/alobakin/linux/commit/9d3d9ab4e7765d5a4c466c65ad6cf204a3ad1a71
Thanks,
Olek
Jakub Kicinski
maintainerQuoted 2 lines · On Wed, 19 Apr 2023 15:49:17 +0200 Alexander Lobakin wrote:
And you do that 2 days before I send this: [0] :D
Just jokin' :p
Ha! It's karma for not posting the netlink int stuff, yet :P
Quoted 5 lines
Unconditional weak ordering seems reasonable to me as well. BTW, I've seen one driver converted to PP already, which manages DMA mappings on its own *solely* because it needs to map stuff with weak ordering =\
It could be switched to PP builtin map handling thanks to this change (-100 locs).
Neat! I hope it will unblock a number of conversions.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 17 Apr 2023 08:28:05 -0700 you wrote:
Commit
c519fe9a4f0d("bnxt: add dma mapping attributes") addedDMA_ATTR_WEAK_ORDERINGto DMA attrs on bnxt. It has since spread to a few more drivers (possibly as a copy'n'paste).
DMA_ATTR_WEAK_ORDERINGonly seems to matter on Sparc and PowerPC/cell, the rarity of these platforms is likely why we never bothered adding the attribute in the page pool, even though it should be safe to add.[...]
Here is the summary with links:
- [net-next] page_pool: add DMA_ATTR_WEAK_ORDERING on all mappings
https://git.kernel.org/netdev/net-next/c/8e4c62c7d980
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html