mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
skbuff: inline page_frag_alloc_align()
The __alloc_frag_align() is short, and only called by two functions, so inline page_frag_alloc_align() for reduce the overhead of calls. Reported-by: kernel test robot <oliver.sang@intel.com> Signed-off-by: Yajun Deng <yajun.deng@linux.dev> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b9bbc4c1de
commit
32e3573f73
1 changed files with 8 additions and 11 deletions
|
@ -134,34 +134,31 @@ struct napi_alloc_cache {
|
||||||
static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache);
|
static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache);
|
||||||
static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache);
|
static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache);
|
||||||
|
|
||||||
static void *__alloc_frag_align(unsigned int fragsz, gfp_t gfp_mask,
|
void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
|
||||||
unsigned int align_mask)
|
|
||||||
{
|
{
|
||||||
struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
|
struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
|
||||||
|
|
||||||
return page_frag_alloc_align(&nc->page, fragsz, gfp_mask, align_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
|
|
||||||
{
|
|
||||||
fragsz = SKB_DATA_ALIGN(fragsz);
|
fragsz = SKB_DATA_ALIGN(fragsz);
|
||||||
|
|
||||||
return __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask);
|
return page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, align_mask);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__napi_alloc_frag_align);
|
EXPORT_SYMBOL(__napi_alloc_frag_align);
|
||||||
|
|
||||||
void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
|
void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
|
||||||
{
|
{
|
||||||
struct page_frag_cache *nc;
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
fragsz = SKB_DATA_ALIGN(fragsz);
|
fragsz = SKB_DATA_ALIGN(fragsz);
|
||||||
if (in_hardirq() || irqs_disabled()) {
|
if (in_hardirq() || irqs_disabled()) {
|
||||||
nc = this_cpu_ptr(&netdev_alloc_cache);
|
struct page_frag_cache *nc = this_cpu_ptr(&netdev_alloc_cache);
|
||||||
|
|
||||||
data = page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask);
|
data = page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask);
|
||||||
} else {
|
} else {
|
||||||
|
struct napi_alloc_cache *nc;
|
||||||
|
|
||||||
local_bh_disable();
|
local_bh_disable();
|
||||||
data = __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask);
|
nc = this_cpu_ptr(&napi_alloc_cache);
|
||||||
|
data = page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, align_mask);
|
||||||
local_bh_enable();
|
local_bh_enable();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue