mirror of
https://github.com/AuxXxilium/synology-igc.git
synced 2024-11-23 23:11:07 +07:00
fix page refcount not decrease when free page
Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
parent
2eae66c0fa
commit
8cb8c8ae0e
19
backport.h
19
backport.h
@ -201,3 +201,22 @@ static inline bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
|
||||
*legacy_u32 = src[0];
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline int page_ref_sub_and_test(struct page *page, int nr)
|
||||
{
|
||||
int ret = atomic_sub_and_test(nr, &page->_count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void __page_frag_cache_drain(struct page *page, unsigned int count)
|
||||
{
|
||||
if (page_ref_sub_and_test(page, count)) {
|
||||
unsigned int order = compound_order(page);
|
||||
|
||||
// TODO optimize with free_unref_page
|
||||
// if (order == 0)
|
||||
// free_unref_page(page);
|
||||
// else
|
||||
__free_pages(page, order);
|
||||
}
|
||||
}
|
@ -374,7 +374,7 @@ static void igc_clean_rx_ring(struct igc_ring *rx_ring)
|
||||
buffer_info->dma,
|
||||
igc_rx_pg_size(rx_ring),
|
||||
DMA_FROM_DEVICE);
|
||||
__free_pages(buffer_info->page, igc_rx_pg_order(rx_ring));
|
||||
__page_frag_cache_drain(buffer_info->page, buffer_info->pagecnt_bias);
|
||||
|
||||
i++;
|
||||
if (i == rx_ring->count)
|
||||
@ -1763,7 +1763,7 @@ static void igc_put_rx_buffer(struct igc_ring *rx_ring,
|
||||
dma_unmap_page(rx_ring->dev, rx_buffer->dma,
|
||||
igc_rx_pg_size(rx_ring),
|
||||
DMA_FROM_DEVICE);
|
||||
__free_pages(rx_buffer->page, igc_rx_pg_order(rx_ring));
|
||||
__page_frag_cache_drain(rx_buffer->page, rx_buffer->pagecnt_bias);
|
||||
}
|
||||
|
||||
/* clear contents of rx_buffer */
|
||||
|
Loading…
Reference in New Issue
Block a user