net/core/page_pool.c
Source file repositories/reference/linux-study-clean/net/core/page_pool.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/page_pool.c- Extension
.c- Size
- 37241 bytes
- Lines
- 1353
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/error-injection.hlinux/types.hlinux/kernel.hlinux/slab.hlinux/device.hnet/netdev_lock.hnet/netdev_rx_queue.hnet/page_pool/helpers.hnet/page_pool/memory_provider.hnet/xdp.hlinux/dma-direction.hlinux/dma-mapping.hlinux/page-flags.hlinux/mm.hlinux/poison.hlinux/ethtool.hlinux/netdevice.htrace/events/page_pool.hdev.hmp_dmabuf_devmem.hnetmem_priv.hpage_pool_priv.h
Detected Declarations
function page_pool_get_statsfunction for_each_possible_cpufunction page_pool_ethtool_stats_get_countfunction page_pool_producer_lockfunction page_pool_producer_unlockfunction page_pool_struct_checkfunction page_pool_initfunction page_pool_uninitfunction page_pool_create_percpufunction page_pool_createfunction page_pool_refill_alloc_cachefunction __page_pool_get_cachedfunction __page_pool_dma_sync_for_devicefunction page_pool_dma_sync_for_devicefunction page_pool_register_dma_indexfunction page_pool_release_dma_indexfunction page_pool_dma_mapfunction __page_pool_alloc_netmems_slowfunction page_pool_alloc_netmemsfunction page_pool_inflightfunction page_pool_set_pp_infofunction page_pool_clear_pp_infofunction __page_pool_release_netmem_dmafunction pagefunction __page_cache_releasefunction page_pool_recycle_in_cachefunction __page_pool_page_can_be_recycledfunction minfunction page_pool_napi_localfunction page_pool_put_unrefed_netmemfunction page_pool_put_unrefed_pagefunction page_pool_recycle_ring_bulkfunction page_pool_put_netmem_bulkfunction page_pool_drain_fragfunction page_pool_free_fragfunction page_pool_alloc_frag_netmemfunction page_pool_empty_ringfunction __page_pool_destroyfunction page_pool_empty_alloc_cache_oncefunction page_pool_scrubfunction page_pool_releasefunction page_pool_release_retryfunction page_pool_use_xdp_memfunction page_pool_enable_direct_recyclingfunction page_pool_disable_direct_recyclingfunction page_pool_destroyfunction page_pool_update_nidfunction net_mp_niov_set_dma_addr
Annotated Snippet
if (!pool->dma_map || !pool->dma_sync) {
err = -EOPNOTSUPP;
goto free_ptr_ring;
}
if (WARN_ON(!is_kernel_rodata((unsigned long)pool->mp_ops))) {
err = -EFAULT;
goto free_ptr_ring;
}
err = pool->mp_ops->init(pool);
if (err) {
pr_warn("%s() mem-provider init failed %d\n", __func__,
err);
goto free_ptr_ring;
}
static_branch_inc(&page_pool_mem_providers);
} else if (pool->p.order > MAX_PAGE_ORDER) {
err = -EINVAL;
goto free_ptr_ring;
}
return 0;
free_ptr_ring:
ptr_ring_cleanup(&pool->ring, NULL);
xa_destroy(&pool->dma_mapped);
#ifdef CONFIG_PAGE_POOL_STATS
if (!pool->system)
free_percpu(pool->recycle_stats);
#endif
return err;
}
static void page_pool_uninit(struct page_pool *pool)
{
ptr_ring_cleanup(&pool->ring, NULL);
xa_destroy(&pool->dma_mapped);
#ifdef CONFIG_PAGE_POOL_STATS
if (!pool->system)
free_percpu(pool->recycle_stats);
#endif
if (pool->mp_ops) {
pool->mp_ops->destroy(pool);
static_branch_dec(&page_pool_mem_providers);
}
}
/**
* page_pool_create_percpu() - create a page pool for a given cpu.
* @params: parameters, see struct page_pool_params
* @cpuid: cpu identifier
*/
struct page_pool *
page_pool_create_percpu(const struct page_pool_params *params, int cpuid)
{
struct page_pool *pool;
int err;
pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, params->nid);
if (!pool)
return ERR_PTR(-ENOMEM);
err = page_pool_init(pool, params, cpuid);
if (err < 0)
goto err_free;
err = page_pool_list(pool);
if (err)
goto err_uninit;
return pool;
err_uninit:
page_pool_uninit(pool);
err_free:
pr_warn("%s() gave up with errno %d\n", __func__, err);
kfree(pool);
return ERR_PTR(err);
}
EXPORT_SYMBOL(page_pool_create_percpu);
/**
* page_pool_create() - create a page pool
* @params: parameters, see struct page_pool_params
*/
struct page_pool *page_pool_create(const struct page_pool_params *params)
Annotation
- Immediate include surface: `linux/error-injection.h`, `linux/types.h`, `linux/kernel.h`, `linux/slab.h`, `linux/device.h`, `net/netdev_lock.h`, `net/netdev_rx_queue.h`, `net/page_pool/helpers.h`.
- Detected declarations: `function page_pool_get_stats`, `function for_each_possible_cpu`, `function page_pool_ethtool_stats_get_count`, `function page_pool_producer_lock`, `function page_pool_producer_unlock`, `function page_pool_struct_check`, `function page_pool_init`, `function page_pool_uninit`, `function page_pool_create_percpu`, `function page_pool_create`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.