[PATCH net-next] skbuff: inline page_frag_alloc_align()

Subsystems: networking [general], the rest

STALE1799d

3 messages, 3 authors, 2021-09-07 · open the first message on its own page

[PATCH net-next] skbuff: inline page_frag_alloc_align()

From: Yajun Deng <hidden>
Date: 2021-09-03 02:49:54

The __alloc_frag_align() is short, and only called by __napi_alloc_...
and __netdev_alloc_frag_align(). so inline page_frag_alloc_align()
for reduce the overhead of calls.

Signed-off-by: Yajun Deng <redacted>
---
 net/core/skbuff.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f9311762cc47..1751232f3c97 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -134,34 +134,30 @@ struct napi_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 void *__alloc_frag_align(unsigned int fragsz, gfp_t gfp_mask,
-				unsigned int align_mask)
+void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
 {
 	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);
 
-	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);
 
 void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask)
 {
-	struct page_frag_cache *nc;
 	void *data;
 
 	fragsz = SKB_DATA_ALIGN(fragsz);
 	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);
 	} else {
+		struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
+
 		local_bh_disable();
-		data = __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask);
+		data = page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, align_mask);
 		local_bh_enable();
 	}
 	return data;
-- 
2.32.0

Re: [PATCH net-next] skbuff: inline page_frag_alloc_align()

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-09-03 23:13:51

On Fri,  3 Sep 2021 10:49:26 +0800 Yajun Deng wrote:
The __alloc_frag_align() is short, and only called by __napi_alloc_...
and __netdev_alloc_frag_align(). so inline page_frag_alloc_align()
for reduce the overhead of calls.

Signed-off-by: Yajun Deng <redacted>
# Form letter - net-next is closed

We have already sent the networking pull request for 5.15
and therefore net-next is closed for new drivers, features,
code refactoring and optimizations. We are currently accepting
bug fixes only.

Please repost when net-next reopens after 5.15-rc1 is cut.

Look out for the announcement on the mailing list or check:
http://vger.kernel.org/~davem/net-next.html

RFC patches sent for review only are obviously welcome at any time.

[skbuff] 70189f1d40: BUG:using_smp_processor_id()in_preemptible

From: kernel test robot <hidden>
Date: 2021-09-07 12:45:51


Greeting,

FYI, we noticed the following commit (built with gcc-9):

commit: 70189f1d40b1a9dd7d5c1deabcfa6f135633506e ("[PATCH net-next] skbuff: inline page_frag_alloc_align()")
url: https://github.com/0day-ci/linux/commits/Yajun-Deng/skbuff-inline-page_frag_alloc_align/20210903-105023
base: https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git 29ce8f9701072fc221d9c38ad952de1a9578f95c

in testcase: boot

on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


+--------------------------------------------+------------+------------+
|                                            | 29ce8f9701 | 70189f1d40 |
+--------------------------------------------+------------+------------+
| boot_successes                             | 18         | 0          |
| boot_failures                              | 0          | 21         |
| BUG:using_smp_processor_id()in_preemptible | 0          | 21         |
+--------------------------------------------+------------+------------+


If you fix the issue, kindly add following tag
Reported-by: kernel test robot <redacted>



[   25.854525][    T1] BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
[   25.857967][    T1] caller is __netdev_alloc_frag_align+0x5e/0xc0
[   25.860289][    T1] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc7-01982-g70189f1d40b1 #1
[   25.863303][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
[   25.866158][    T1] Call Trace:
[   25.867383][    T1]  dump_stack_lvl+0x45/0x59
[   25.868894][    T1]  check_preemption_disabled+0xd9/0x100
[   25.870736][    T1]  __netdev_alloc_frag_align+0x5e/0xc0
[   25.872675][    T1]  e1000_alloc_frag+0x21/0x40
[   25.874361][    T1]  e1000_alloc_rx_buffers+0x89/0x380
[   25.876187][    T1]  e1000_configure+0x2bd/0x300
[   25.877721][    T1]  e1000_open+0x8b/0x1c0
[   25.879208][    T1]  __dev_open+0xea/0x180
[   25.880669][    T1]  __dev_change_flags+0x19e/0x200
[   25.882375][    T1]  ? _get_random_bytes+0xf1/0x240
[   25.884179][    T1]  dev_change_flags+0x21/0x80
[   25.885746][    T1]  ip_auto_config+0x2b4/0xb9a
[   25.887337][    T1]  ? lock_is_held_type+0xd5/0x140
[   25.889052][    T1]  ? root_nfs_parse_addr+0xa5/0xa5
[   25.890776][    T1]  ? do_one_initcall+0x5b/0x340
[   25.892409][    T1]  do_one_initcall+0x5b/0x340
[   25.893940][    T1]  ? rcu_read_lock_sched_held+0x52/0x80
[   25.895658][    T1]  kernel_init_freeable+0x28b/0x2f2
[   25.897430][    T1]  ? rest_init+0x280/0x280
[   25.898921][    T1]  kernel_init+0x16/0x140
[   25.900448][    T1]  ret_from_fork+0x22/0x30
[   25.902593][    T1] BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
[   25.914323][    T1] caller is __netdev_alloc_frag_align+0x5e/0xc0
[   25.916499][    T1] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc7-01982-g70189f1d40b1 #1
[   25.919474][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
[   25.922510][    T1] Call Trace:
[   25.923706][    T1]  dump_stack_lvl+0x45/0x59
[   25.925728][    T1]  check_preemption_disabled+0xd9/0x100
[   25.928390][    T1]  __netdev_alloc_frag_align+0x5e/0xc0
[   25.930429][    T1]  e1000_alloc_frag+0x21/0x40
[   25.931940][    T1]  e1000_alloc_rx_buffers+0x89/0x380
[   25.933677][    T1]  e1000_configure+0x2bd/0x300
[   25.935404][    T1]  e1000_open+0x8b/0x1c0
[   25.936909][    T1]  __dev_open+0xea/0x180
[   25.938607][    T1]  __dev_change_flags+0x19e/0x200
[   25.940287][    T1]  ? _get_random_bytes+0xf1/0x240
[   25.941900][    T1]  dev_change_flags+0x21/0x80
[   25.943560][    T1]  ip_auto_config+0x2b4/0xb9a
[   25.945110][    T1]  ? lock_is_held_type+0xd5/0x140
[   25.946921][    T1]  ? root_nfs_parse_addr+0xa5/0xa5
[   25.948601][    T1]  ? do_one_initcall+0x5b/0x340
[   25.950342][    T1]  do_one_initcall+0x5b/0x340
[   25.951799][    T1]  ? rcu_read_lock_sched_held+0x52/0x80
[   25.953494][    T1]  kernel_init_freeable+0x28b/0x2f2
[   25.955277][    T1]  ? rest_init+0x280/0x280
[   25.956772][    T1]  kernel_init+0x16/0x140
[   25.958279][    T1]  ret_from_fork+0x22/0x30



To reproduce:

        # build kernel
	cd linux
	cp config-5.14.0-rc7-01982-g70189f1d40b1 .config
	make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage

        git clone https://github.com/intel/lkp-tests.git
        cd lkp-tests
        bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email



---
0DAY/LKP+ Test Infrastructure                   Open Source Technology Center
https://lists.01.org/hyperkitty/list/lkp@lists.01.org       Intel Corporation

Thanks,
Oliver Sang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help