Re: [bpf-next V5 PATCH 11/15] page_pool: refurbish version of page_pool code

Eric Dumazet
2018-03-23T13:37:33Z

On 03/23/2018 05:18 AM, Jesper Dangaard Brouer wrote:

> +#define PP_ALLOC_CACHE_SIZE 128
> +#define PP_ALLOC_CACHE_REFILL 64
> +struct pp_alloc_cache {
> + u32 count ____cacheline_aligned_in_smp;
> + void *cache[PP_ALLOC_CACHE_SIZE];
> +};
> +
> +struct page_pool_params {
...
> +};
> +#define PAGE_POOL_PARAMS_SIZE offsetof(struct page_pool_params, end_marker)
> +
> +struct page_pool {
> + struct page_pool_params p;
> +
> + struct pp_alloc_cache alloc;
> +
>...
> + struct ptr_ring ring;
> +
> + struct rcu_head rcu;
> +};
> +

The placement of ____cacheline_aligned_in_smp in pp_alloc_cache is odd.

I would rather put it in struct page_pool as in :

+struct page_pool {
+ struct page_pool_params p;

+ struct pp_alloc_cache alloc ____cacheline_aligned_in_smp;;

To make clear the intent here (let the page_pool_params being in a read only cache line)

Also you probably can move the struct rcu_head between p and pp_alloc_cache_alloc to fill a hole.

(assuming allowing variable sized params is no longer needed)