diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2021-02-06 11:57:30 -0800 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2021-02-06 11:57:31 -0800 |
| commit | 9c2865e3fa426bb4501a161c6b33bb509d535435 (patch) | |
| tree | d15cb81d2e5f49a4f783dd94da3d2ad02a9abfdd /mm/page_alloc.c | |
| parent | a455fcd7c77046d576dcfe41c1361928dd8b5eaf (diff) | |
| parent | d0dfbb9912d9477578f41c5200d7eac3da899dce (diff) | |
Merge branch 'net-avoid-the-memory-waste-in-some-ethernet-drivers'
Kevin Hao says:
====================
net: Avoid the memory waste in some Ethernet drivers
In the current implementation of napi_alloc_frag(), it doesn't have any
align guarantee for the returned buffer address. We would have to use
some ugly workarounds to make sure that we can get a align buffer
address for some Ethernet drivers. This patch series tries to introduce
some helper functions to make sure that an align buffer is returned.
Then we can drop the ugly workarounds and avoid the unnecessary memory
waste.
====================
Link: https://lore.kernel.org/r/20210204105638.1584-1-haokexin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'mm/page_alloc.c')
| -rw-r--r-- | mm/page_alloc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 519a60d5b6f7..ef5070fed76b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5137,8 +5137,9 @@ void __page_frag_cache_drain(struct page *page, unsigned int count) } EXPORT_SYMBOL(__page_frag_cache_drain); -void *page_frag_alloc(struct page_frag_cache *nc, - unsigned int fragsz, gfp_t gfp_mask) +void *page_frag_alloc_align(struct page_frag_cache *nc, + unsigned int fragsz, gfp_t gfp_mask, + unsigned int align_mask) { unsigned int size = PAGE_SIZE; struct page *page; @@ -5190,11 +5191,12 @@ refill: } nc->pagecnt_bias--; + offset &= align_mask; nc->offset = offset; return nc->va + offset; } -EXPORT_SYMBOL(page_frag_alloc); +EXPORT_SYMBOL(page_frag_alloc_align); /* * Frees a page fragment allocated out of either a compound or order 0 page. |
