From jrife at google.com Tue Oct 1 16:26:58 2024 From: jrife at google.com (Jordan Rife) Date: Tue, 01 Oct 2024 16:26:58 -0000 Subject: [PATCH v2 net-next] wireguard: allowedips: Add WGALLOWEDIP_F_REMOVE_ME flag In-Reply-To: <20240905200551.4099064-1-jrife@google.com> References: <20240905200551.4099064-1-jrife@google.com> Message-ID: Hi Jason, Just reaching out to see if you've had a chance to take a look at this. Thanks! -Jordan From syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com Wed Oct 2 20:19:26 2024 From: syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com (syzbot) Date: Wed, 02 Oct 2024 20:19:26 -0000 Subject: [syzbot] [wireguard?] INFO: task hung in wg_destruct (2) In-Reply-To: <66fa2708.050a0220.aab67.0025.GAE@google.com> Message-ID: <66fdaacc.050a0220.40bef.0023.GAE@google.com> syzbot has found a reproducer for the following issue on: HEAD commit: e32cde8d2bd7 Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1670339f980000 kernel config: https://syzkaller.appspot.com/x/.config?x=286b31f2cf1c36b5 dashboard link: https://syzkaller.appspot.com/bug?extid=7da6c19dc528c2ebc612 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=146ae580580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f7f2dc1bf47b/disk-e32cde8d.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/063e4eafb554/vmlinux-e32cde8d.xz kernel image: https://storage.googleapis.com/syzbot-assets/7ce38bae7b74/bzImage-e32cde8d.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com INFO: task kworker/u8:5:1092 blocked for more than 145 seconds. Not tainted 6.12.0-rc1-syzkaller-00031-ge32cde8d2bd7 #0 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:kworker/u8:5 state:D stack:22072 pid:1092 tgid:1092 ppid:2 flags:0x00004000 Workqueue: netns cleanup_net Call Trace: context_switch kernel/sched/core.c:5315 [inline] __schedule+0x1895/0x4b30 kernel/sched/core.c:6675 __schedule_loop kernel/sched/core.c:6752 [inline] schedule+0x14b/0x320 kernel/sched/core.c:6767 schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:6824 __mutex_lock_common kernel/locking/mutex.c:684 [inline] __mutex_lock+0x6a7/0xd70 kernel/locking/mutex.c:752 wg_destruct+0x25/0x2e0 drivers/net/wireguard/device.c:246 netdev_run_todo+0xe1a/0x1000 net/core/dev.c:10805 default_device_exit_batch+0xa24/0xaa0 net/core/dev.c:11945 ops_exit_list net/core/net_namespace.c:178 [inline] cleanup_net+0x89d/0xcc0 net/core/net_namespace.c:626 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310 worker_thread+0x870/0xd30 kernel/workqueue.c:3391 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 INFO: task dhcpcd:4899 blocked for more than 153 seconds. Not tainted 6.12.0-rc1-syzkaller-00031-ge32cde8d2bd7 #0 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:dhcpcd state:D stack:20352 pid:4899 tgid:4899 ppid:4898 flags:0x00000002 Call Trace: context_switch kernel/sched/core.c:5315 [inline] __schedule+0x1895/0x4b30 kernel/sched/core.c:6675 __schedule_loop kernel/sched/core.c:6752 [inline] schedule+0x14b/0x320 kernel/sched/core.c:6767 schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:6824 __mutex_lock_common kernel/locking/mutex.c:684 [inline] __mutex_lock+0x6a7/0xd70 kernel/locking/mutex.c:752 rtnl_lock net/core/rtnetlink.c:79 [inline] rtnl_dumpit+0x99/0x200 net/core/rtnetlink.c:6505 netlink_dump+0x647/0xd80 net/netlink/af_netlink.c:2325 __netlink_dump_start+0x5a2/0x790 net/netlink/af_netlink.c:2440 netlink_dump_start include/linux/netlink.h:339 [inline] rtnetlink_dump_start net/core/rtnetlink.c:6535 [inline] rtnetlink_rcv_msg+0xb3d/0xcf0 net/core/rtnetlink.c:6602 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1331 [inline] netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1357 netlink_sendmsg+0x8e4/0xcb0 net/netlink/af_netlink.c:1901 sock_sendmsg_nosec net/socket.c:729 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:744 __sys_sendto+0x39b/0x4f0 net/socket.c:2209 __do_sys_sendto net/socket.c:2221 [inline] __se_sys_sendto net/socket.c:2217 [inline] __x64_sys_sendto+0xde/0x100 net/socket.c:2217 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f33cf298ad7 RSP: 002b:00007ffdc403cb38 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00007ffdc403dc60 RCX: 00007f33cf298ad7 RDX: 0000000000000014 RSI: 00007ffdc403db80 RDI: 0000000000000013 RBP: 00007ffdc403dbf0 R08: 00007ffdc403db64 R09: 000000000000000c R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000012 R13: 00007ffdc403db64 R14: 00007ffdc403db80 R15: 0000000000000105 Showing all locks held in the system: 6 locks held by kworker/0:0/8: 1 lock held by khungtaskd/30: #0: ffffffff8e937de0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline] #0: ffffffff8e937de0 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline] #0: ffffffff8e937de0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x55/0x2a0 kernel/locking/lockdep.c:6720 3 locks held by kworker/u8:3/52: 5 locks held by kworker/u9:0/54: #0: ffff888064184948 ((wq_completion)hci2){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3204 [inline] #0: ffff888064184948 ((wq_completion)hci2){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1850 kernel/workqueue.c:3310 #1: ffffc90000bf7d00 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3205 [inline] #1: ffffc90000bf7d00 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1850 kernel/workqueue.c:3310 #2: ffff888028a88d80 (&hdev->req_lock){+.+.}-{3:3}, at: hci_cmd_sync_work+0x1ec/0x400 net/bluetooth/hci_sync.c:327 #3: ffff888028a88078 (&hdev->lock){+.+.}-{3:3}, at: hci_abort_conn_sync+0x1ea/0xde0 net/bluetooth/hci_sync.c:5567 #4: ffffffff8fe3dfa8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_connect_cfm include/net/bluetooth/hci_core.h:1957 [inline] #4: ffffffff8fe3dfa8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_conn_failed+0x15d/0x300 net/bluetooth/hci_conn.c:1262 1 lock held by kswapd0/88: 1 lock held by kswapd1/89: 3 locks held by kworker/1:2/937: #0: ffff88801ac81948 ((wq_completion)events_power_efficient){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3204 [inline] #0: ffff88801ac81948 ((wq_completion)events_power_efficient){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1850 kernel/workqueue.c:3310 #1: ffffc90003907d00 ((reg_check_chans).work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3205 [inline] #1: ffffc90003907d00 ((reg_check_chans).work){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1850 kernel/workqueue.c:3310 #2: ffffffff8fcd1748 (rtnl_mutex){+.+.}-{3:3}, at: reg_check_chans_work+0x99/0xfd0 net/wireless/reg.c:2480 4 locks held by kworker/u8:5/1092: #0: ffff88801baed948 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3204 [inline] #0: ffff88801baed948 ((wq_completion)netns){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1850 kernel/workqueue.c:3310 #1: ffffc90003e07d00 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3205 [inline] #1: ffffc90003e07d00 (net_cleanup_work){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1850 kernel/workqueue.c:3310 #2: ffffffff8fcc4c50 (pernet_ops_rwsem){++++}-{3:3}, at: cleanup_net+0x16a/0xcc0 net/core/net_namespace.c:580 #3: ffffffff8fcd1748 (rtnl_mutex){+.+.}-{3:3}, at: wg_destruct+0x25/0x2e0 drivers/net/wireguard/device.c:246 3 locks held by kworker/u8:6/2919: 3 locks held by kworker/u8:8/3822: #0: ffff88802d6e7148 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3204 [inline] #0: ffff88802d6e7148 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1850 kernel/workqueue.c:3310 #1: ffffc9000bd0fd00 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3205 [inline] #1: ffffc9000bd0fd00 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1850 kernel/workqueue.c:3310 #2: ffffffff8fcd1748 (rtnl_mutex){+.+.}-{3:3}, at: addrconf_dad_work+0xd0/0x16f0 net/ipv6/addrconf.c:4196 2 locks held by syslogd/4667: 1 lock held by klogd/4674: 4 locks held by udevd/4685: 2 locks held by dhcpcd/4899: #0: ffff8880245f86c8 (nlk_cb_mutex-ROUTE){+.+.}-{3:3}, at: __netlink_dump_start+0x119/0x790 net/netlink/af_netlink.c:2404 --- If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. From daniel at iogearbox.net Fri Oct 4 16:55:19 2024 From: daniel at iogearbox.net (Daniel Borkmann) Date: Fri, 04 Oct 2024 16:55:19 -0000 Subject: [PATCH net-next v2] wireguard: Wire-up big tcp support Message-ID: <20241004165518.120567-1-daniel@iogearbox.net> Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. This helps to improve wireguard performance a bit when enabled as it allows wireguard to aggregate larger skbs in wg_packet_consume_data_done() via napi_gro_receive(), but also allows the stack to build larger skbs on xmit where the driver then segments them before encryption inside wg_xmit(). Signed-off-by: Daniel Borkmann Cc: Jason A. Donenfeld Cc: Anton Protopopov Cc: Martynas Pumputis --- v2: fixed up my gitconfig and Cc's now drivers/net/wireguard/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c index 45e9b908dbfb..79be517b2216 100644 --- a/drivers/net/wireguard/device.c +++ b/drivers/net/wireguard/device.c @@ -301,6 +301,7 @@ static void wg_setup(struct net_device *dev) /* We need to keep the dst around in case of icmp replies. */ netif_keep_dst(dev); + netif_set_tso_max_size(dev, GSO_MAX_SIZE); memset(wg, 0, sizeof(*wg)); wg->dev = dev; -- 2.43.0 From Jason at zx2c4.com Mon Oct 7 16:42:48 2024 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Mon, 07 Oct 2024 16:42:48 -0000 Subject: [PATCH net-next v2] wireguard: Wire-up big tcp support In-Reply-To: <20241004165518.120567-1-daniel@iogearbox.net> References: <20241004165518.120567-1-daniel@iogearbox.net> Message-ID: Hi Daniel, On Fri, Oct 04, 2024 at 06:55:18PM +0200, Daniel Borkmann wrote: > Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. > This helps to improve wireguard performance a bit when enabled as it allows > wireguard to aggregate larger skbs in wg_packet_consume_data_done() via > napi_gro_receive(), but also allows the stack to build larger skbs on xmit > where the driver then segments them before encryption inside wg_xmit(). Thanks, I'll queue this up. Do you have any perf numbers on the speedup, btw? Jason From daniel at iogearbox.net Mon Oct 7 17:50:07 2024 From: daniel at iogearbox.net (Daniel Borkmann) Date: Mon, 07 Oct 2024 17:50:07 -0000 Subject: [PATCH net-next v2] wireguard: Wire-up big tcp support In-Reply-To: References: <20241004165518.120567-1-daniel@iogearbox.net> Message-ID: Hi Jason, On 10/7/24 6:42 PM, Jason A. Donenfeld wrote: > On Fri, Oct 04, 2024 at 06:55:18PM +0200, Daniel Borkmann wrote: >> Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. >> This helps to improve wireguard performance a bit when enabled as it allows >> wireguard to aggregate larger skbs in wg_packet_consume_data_done() via >> napi_gro_receive(), but also allows the stack to build larger skbs on xmit >> where the driver then segments them before encryption inside wg_xmit(). > > Thanks, I'll queue this up. Do you have any perf numbers on the speedup, > btw? Awesome, thanks! Few weeks back we had an LPC session with some initial work around wireguard performance (https://lpc.events/event/18/contributions/1968/) including benchmarks. It depends on the specific scenario, but this as well as an L2 GRO implementation (yet to come as patches in the next weeks) we got ~+15% for host-host in case of TCP STREAM. In case of Cilium I haven't done the measurement yet, but I expect that there would be further gains as bigger packets can traverse the stack and thus less processing in upper layers (e.g. our tcx BPF code). Thanks, Daniel From vbabka at suse.cz Tue Oct 8 16:36:13 2024 From: vbabka at suse.cz (Vlastimil Babka) Date: Tue, 08 Oct 2024 16:36:13 -0000 Subject: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Message-ID: <1585a3fc-ade2-4e1e-a016-e04336c0a103@suse.cz> On 6/9/24 10:27, Julia Lawall wrote: > Since SLOB was removed, it is not necessary to use call_rcu > when the callback only performs kmem_cache_free. Use > kfree_rcu() directly. FYI, as of 6.12-rc1 - commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()") it should be possible to restart this effort for the remaining cases which had to be postponed until kmem_cache_destroy() / module unload is sorted out. Thanks, Vlastimil > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. > > // > @r@ > expression e; > local idexpression e2; > identifier cb,f; > position p; > @@ > > ( > call_rcu(...,e2) > | > call_rcu(&e->f,cb at p) > ) > > @r1@ > type T; > identifier x,r.cb; > @@ > > cb(...) { > ( > kmem_cache_free(...); > | > T x = ...; > kmem_cache_free(...,x); > | > T x; > x = ...; > kmem_cache_free(...,x); > ) > } > > @s depends on r1@ > position p != r.p; > identifier r.cb; > @@ > > cb at p > > @script:ocaml@ > cb << r.cb; > p << s.p; > @@ > > Printf.eprintf "Other use of %s at %s:%d\n" > cb (List.hd p).file (List.hd p).line > > @depends on r1 && !s@ > expression e; > identifier r.cb,f; > position r.p; > @@ > > - call_rcu(&e->f,cb at p) > + kfree_rcu(e,f) > > @r1a depends on !s@ > type T; > identifier x,r.cb; > @@ > > - cb(...) { > ( > - kmem_cache_free(...); > | > - T x = ...; > - kmem_cache_free(...,x); > | > - T x; > - x = ...; > - kmem_cache_free(...,x); > ) > - } > // > > Signed-off-by: Julia Lawall > Reviewed-by: Paul E. McKenney > Reviewed-by: Vlastimil Babka > > --- > > arch/powerpc/kvm/book3s_mmu_hpte.c | 8 +------- > block/blk-ioc.c | 9 +-------- > drivers/net/wireguard/allowedips.c | 9 ++------- > fs/ecryptfs/dentry.c | 8 +------- > fs/nfsd/nfs4state.c | 9 +-------- > fs/tracefs/inode.c | 10 +--------- > kernel/time/posix-timers.c | 9 +-------- > kernel/workqueue.c | 8 +------- > net/bridge/br_fdb.c | 9 +-------- > net/can/gw.c | 13 +++---------- > net/ipv4/fib_trie.c | 8 +------- > net/ipv4/inetpeer.c | 9 ++------- > net/ipv6/ip6_fib.c | 9 +-------- > net/ipv6/xfrm6_tunnel.c | 8 +------- > net/kcm/kcmsock.c | 10 +--------- > net/netfilter/nf_conncount.c | 10 +--------- > net/netfilter/nf_conntrack_expect.c | 10 +--------- > net/netfilter/xt_hashlimit.c | 9 +-------- > 18 files changed, 22 insertions(+), 143 deletions(-) From vbabka at suse.cz Tue Oct 8 16:41:14 2024 From: vbabka at suse.cz (Vlastimil Babka) Date: Tue, 08 Oct 2024 16:41:14 -0000 Subject: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: References: <6711935d-20b5-41c1-8864-db3fc7d7823d@suse.cz> <36c60acd-543e-48c5-8bd2-6ed509972d28@suse.cz> <5c8b2883-962f-431f-b2d3-3632755de3b0@paulmck-laptop> <9967fdfa-e649-456d-a0cb-b4c4bf7f9d68@suse.cz> <6dad6e9f-e0ca-4446-be9c-1be25b2536dd@paulmck-laptop> <4cba4a48-902b-4fb6-895c-c8e6b64e0d5f@suse.cz> Message-ID: <37807ec7-d521-4f01-bcfc-a32650d5de25@suse.cz> On 7/24/24 15:53, Paul E. McKenney wrote: > On Mon, Jul 15, 2024 at 10:39:38PM +0200, Vlastimil Babka wrote: >> On 6/21/24 11:32 AM, Uladzislau Rezki wrote: >> > On Wed, Jun 19, 2024 at 11:28:13AM +0200, Vlastimil Babka wrote: >> > One question. Maybe it is already late but it is better to ask rather than not. >> > >> > What do you think if we have a small discussion about it on the LPC 2024 as a >> > topic? It might be it is already late or a schedule is set by now. Or we fix >> > it by a conference time. >> > >> > Just a thought. >> >> Sorry for the late reply. The MM MC turned out to be so packed I didn't even >> propose a slab topic. We could discuss in hallway track or a BOF, but >> hopefully if the current direction taken by my RFC brings no unexpected >> surprise, and the necessary RCU barrier side is also feasible, this will be >> settled by time of plumbers. > > That would be even better! > > Thanx, Paul Hah, so it was close but my hope was fulfilled in the end! commit bdf56c7580d267a123cc71ca0f2459c797b76fde Merge: efdfcd40ad5e ecc4d6af979b Author: Linus Torvalds Date: Wed Sep 18 08:53:53 2024 +0200 Merge tag 'slab-for-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab So that was at 8:53 Vienna time, and Plumbers started at 10:00... From paulmck at kernel.org Tue Oct 8 20:02:32 2024 From: paulmck at kernel.org (Paul E. McKenney) Date: Tue, 08 Oct 2024 20:02:32 -0000 Subject: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <37807ec7-d521-4f01-bcfc-a32650d5de25@suse.cz> References: <36c60acd-543e-48c5-8bd2-6ed509972d28@suse.cz> <5c8b2883-962f-431f-b2d3-3632755de3b0@paulmck-laptop> <9967fdfa-e649-456d-a0cb-b4c4bf7f9d68@suse.cz> <6dad6e9f-e0ca-4446-be9c-1be25b2536dd@paulmck-laptop> <4cba4a48-902b-4fb6-895c-c8e6b64e0d5f@suse.cz> <37807ec7-d521-4f01-bcfc-a32650d5de25@suse.cz> Message-ID: On Tue, Oct 08, 2024 at 06:41:12PM +0200, Vlastimil Babka wrote: > On 7/24/24 15:53, Paul E. McKenney wrote: > > On Mon, Jul 15, 2024 at 10:39:38PM +0200, Vlastimil Babka wrote: > >> On 6/21/24 11:32 AM, Uladzislau Rezki wrote: > >> > On Wed, Jun 19, 2024 at 11:28:13AM +0200, Vlastimil Babka wrote: > >> > One question. Maybe it is already late but it is better to ask rather than not. > >> > > >> > What do you think if we have a small discussion about it on the LPC 2024 as a > >> > topic? It might be it is already late or a schedule is set by now. Or we fix > >> > it by a conference time. > >> > > >> > Just a thought. > >> > >> Sorry for the late reply. The MM MC turned out to be so packed I didn't even > >> propose a slab topic. We could discuss in hallway track or a BOF, but > >> hopefully if the current direction taken by my RFC brings no unexpected > >> surprise, and the necessary RCU barrier side is also feasible, this will be > >> settled by time of plumbers. > > > > That would be even better! > > > > Thanx, Paul > > Hah, so it was close but my hope was fulfilled in the end! Nice, and thank you!!! Thanx, Paul > commit bdf56c7580d267a123cc71ca0f2459c797b76fde > Merge: efdfcd40ad5e ecc4d6af979b > Author: Linus Torvalds > Date: Wed Sep 18 08:53:53 2024 +0200 > > Merge tag 'slab-for-6.12' of > git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab > > So that was at 8:53 Vienna time, and Plumbers started at 10:00... From syzbot+58510c37d7d3c2335e35 at syzkaller.appspotmail.com Wed Oct 9 06:18:26 2024 From: syzbot+58510c37d7d3c2335e35 at syzkaller.appspotmail.com (syzbot) Date: Wed, 09 Oct 2024 06:18:26 -0000 Subject: [syzbot] [wireguard?] WARNING: locking bug in wg_packet_encrypt_worker (2) Message-ID: <67062030.050a0220.3f80e.0025.GAE@google.com> Hello, syzbot found the following issue on: HEAD commit: 27cc6fdf7201 Merge tag 'linux_kselftest-fixes-6.12-rc2' of.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16829bd0580000 kernel config: https://syzkaller.appspot.com/x/.config?x=6248f0ab12f33349 dashboard link: https://syzkaller.appspot.com/bug?extid=58510c37d7d3c2335e35 compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40 Unfortunately, I don't have any reproducer for this issue yet. Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/6977fdc3f229/disk-27cc6fdf.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/e3cb80988930/vmlinux-27cc6fdf.xz kernel image: https://storage.googleapis.com/syzbot-assets/030bdb347b6a/bzImage-27cc6fdf.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+58510c37d7d3c2335e35 at syzkaller.appspotmail.com ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 1 PID: 5276 at kernel/locking/lockdep.c:232 hlock_class kernel/locking/lockdep.c:232 [inline] WARNING: CPU: 1 PID: 5276 at kernel/locking/lockdep.c:232 hlock_class+0xfa/0x130 kernel/locking/lockdep.c:221 Modules linked in: CPU: 1 UID: 0 PID: 5276 Comm: kworker/1:4 Not tainted 6.12.0-rc1-syzkaller-00306-g27cc6fdf7201 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: wg-crypt-wg2 wg_packet_encrypt_worker RIP: 0010:hlock_class kernel/locking/lockdep.c:232 [inline] RIP: 0010:hlock_class+0xfa/0x130 kernel/locking/lockdep.c:221 Code: b6 14 11 38 d0 7c 04 84 d2 75 43 8b 05 73 a9 f5 0e 85 c0 75 19 90 48 c7 c6 40 d5 6c 8b 48 c7 c7 60 cf 6c 8b e8 57 b2 e4 ff 90 <0f> 0b 90 90 90 31 c0 eb 9e e8 78 38 85 00 e9 1c ff ff ff 48 c7 c7 RSP: 0018:ffffc90004437960 EFLAGS: 00010086 RAX: 0000000000000000 RBX: 00000000000012ae RCX: ffffffff814e71a9 RDX: ffff88806302da00 RSI: ffffffff814e71b6 RDI: 0000000000000001 RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 R13: ffff88806302e530 R14: 00000000000012ae R15: ffff88806302da00 FS: 0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020021000 CR3: 000000003167e000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: check_wait_context kernel/locking/lockdep.c:4826 [inline] __lock_acquire+0x415/0x3ce0 kernel/locking/lockdep.c:5152 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline] _raw_spin_lock_bh+0x33/0x40 kernel/locking/spinlock.c:178 spin_lock_bh include/linux/spinlock.h:356 [inline] ptr_ring_consume_bh include/linux/ptr_ring.h:365 [inline] wg_packet_encrypt_worker+0xe4/0xd60 drivers/net/wireguard/send.c:293 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller at googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup From syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com Wed Oct 9 07:44:05 2024 From: syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com (syzbot) Date: Wed, 09 Oct 2024 07:44:05 -0000 Subject: [syzbot] [wireguard?] INFO: task hung in wg_destruct (2) In-Reply-To: <66fa2708.050a0220.aab67.0025.GAE@google.com> Message-ID: <67063443.050a0220.22840d.000f.GAE@google.com> syzbot has bisected this issue to: commit dfa0a574cbc47bfd5f8985f74c8ea003a37fa078 Author: Peter Zijlstra Date: Wed Jun 5 10:09:11 2024 +0000 sched/uclamg: Handle delayed dequeue bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13c2d7d0580000 start commit: e32cde8d2bd7 Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=1022d7d0580000 console output: https://syzkaller.appspot.com/x/log.txt?x=17c2d7d0580000 kernel config: https://syzkaller.appspot.com/x/.config?x=286b31f2cf1c36b5 dashboard link: https://syzkaller.appspot.com/bug?extid=7da6c19dc528c2ebc612 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=146ae580580000 Reported-by: syzbot+7da6c19dc528c2ebc612 at syzkaller.appspotmail.com Fixes: dfa0a574cbc4 ("sched/uclamg: Handle delayed dequeue") For information about bisection process see: https://goo.gl/tpsmEJ#bisection From julia.lawall at inria.fr Wed Oct 9 17:09:00 2024 From: julia.lawall at inria.fr (Julia Lawall) Date: Wed, 09 Oct 2024 17:09:00 -0000 Subject: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: References: <36c60acd-543e-48c5-8bd2-6ed509972d28@suse.cz> <5c8b2883-962f-431f-b2d3-3632755de3b0@paulmck-laptop> <9967fdfa-e649-456d-a0cb-b4c4bf7f9d68@suse.cz> <6dad6e9f-e0ca-4446-be9c-1be25b2536dd@paulmck-laptop> <4cba4a48-902b-4fb6-895c-c8e6b64e0d5f@suse.cz> <37807ec7-d521-4f01-bcfc-a32650d5de25@suse.cz> Message-ID: <2ae9cb0-b16e-58a-693b-7cd927657946@inria.fr> Hello, I have rerun the semantic patch that removes call_rcu calls in cases where the callback function just does some pointer arithmetic and calls kmem_cache_free. Let me know if this looks ok, and if so, I can make a more formal patch submission. This is against: commit 75b607fab38d149f232f01eae5e6392b394dd659 (HEAD -> master, origin/master, origin/HEAD) Merge: 5b7c893ed5ed e0ed52154e86 Author: Linus Torvalds Date: Tue Oct 8 12:54:04 2024 -0700 Merge tag 'sched_ext-for-6.12-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext julia diff -u -p a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c --- a/arch/powerpc/kvm/book3s_mmu_hpte.c +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c @@ -92,12 +92,6 @@ void kvmppc_mmu_hpte_cache_map(struct kv spin_unlock(&vcpu3s->mmu_lock); } -static void free_pte_rcu(struct rcu_head *head) -{ - struct hpte_cache *pte = container_of(head, struct hpte_cache, rcu_head); - kmem_cache_free(hpte_cache, pte); -} - static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) { struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); @@ -126,7 +120,7 @@ static void invalidate_pte(struct kvm_vc spin_unlock(&vcpu3s->mmu_lock); - call_rcu(&pte->rcu_head, free_pte_rcu); + kfree_rcu(pte, rcu_head); } static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu) diff -u -p a/block/blk-ioc.c b/block/blk-ioc.c --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -32,13 +32,6 @@ static void get_io_context(struct io_con atomic_long_inc(&ioc->refcount); } -static void icq_free_icq_rcu(struct rcu_head *head) -{ - struct io_cq *icq = container_of(head, struct io_cq, __rcu_head); - - kmem_cache_free(icq->__rcu_icq_cache, icq); -} - /* * Exit an icq. Called with ioc locked for blk-mq, and with both ioc * and queue locked for legacy. @@ -102,7 +95,7 @@ static void ioc_destroy_icq(struct io_cq */ icq->__rcu_icq_cache = et->icq_cache; icq->flags |= ICQ_DESTROYED; - call_rcu(&icq->__rcu_head, icq_free_icq_rcu); + kfree_rcu(icq, __rcu_head); } /* diff -u -p a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c --- a/drivers/net/wireguard/allowedips.c +++ b/drivers/net/wireguard/allowedips.c @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_n } } -static void node_free_rcu(struct rcu_head *rcu) -{ - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); -} - static void root_free_rcu(struct rcu_head *rcu) { struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = { @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct child = rcu_dereference_protected( parent->bit[!(node->parent_bit_packed & 1)], lockdep_is_held(lock)); - call_rcu(&node->rcu, node_free_rcu); + kfree_rcu(node, rcu); if (!free_parent) continue; if (child) child->parent_bit_packed = parent->parent_bit_packed; *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; - call_rcu(&parent->rcu, node_free_rcu); + kfree_rcu(parent, rcu); } } diff -u -p a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c @@ -51,12 +51,6 @@ static int ecryptfs_d_revalidate(struct struct kmem_cache *ecryptfs_dentry_info_cache; -static void ecryptfs_dentry_free_rcu(struct rcu_head *head) -{ - kmem_cache_free(ecryptfs_dentry_info_cache, - container_of(head, struct ecryptfs_dentry_info, rcu)); -} - /** * ecryptfs_d_release * @dentry: The ecryptfs dentry @@ -68,7 +62,7 @@ static void ecryptfs_d_release(struct de struct ecryptfs_dentry_info *p = dentry->d_fsdata; if (p) { path_put(&p->lower_path); - call_rcu(&p->rcu, ecryptfs_dentry_free_rcu); + kfree_rcu(p, rcu); } } diff -u -p a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -572,13 +572,6 @@ opaque_hashval(const void *ptr, int nbyt return x; } -static void nfsd4_free_file_rcu(struct rcu_head *rcu) -{ - struct nfs4_file *fp = container_of(rcu, struct nfs4_file, fi_rcu); - - kmem_cache_free(file_slab, fp); -} - void put_nfs4_file(struct nfs4_file *fi) { @@ -586,7 +579,7 @@ put_nfs4_file(struct nfs4_file *fi) nfsd4_file_hash_remove(fi); WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); - call_rcu(&fi->fi_rcu, nfsd4_free_file_rcu); + kfree_rcu(fi, fi_rcu); } } diff -u -p a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -413,18 +413,11 @@ static struct k_itimer * alloc_posix_tim return tmr; } -static void k_itimer_rcu_free(struct rcu_head *head) -{ - struct k_itimer *tmr = container_of(head, struct k_itimer, rcu); - - kmem_cache_free(posix_timers_cache, tmr); -} - static void posix_timer_free(struct k_itimer *tmr) { put_pid(tmr->it_pid); sigqueue_free(tmr->sigq); - call_rcu(&tmr->rcu, k_itimer_rcu_free); + kfree_rcu(tmr, rcu); } static void posix_timer_unhash_and_free(struct k_itimer *tmr) diff -u -p a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -408,19 +408,6 @@ static void batadv_tt_global_size_dec(st } /** - * batadv_tt_orig_list_entry_free_rcu() - free the orig_entry - * @rcu: rcu pointer of the orig_entry - */ -static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) -{ - struct batadv_tt_orig_list_entry *orig_entry; - - orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); - - kmem_cache_free(batadv_tt_orig_cache, orig_entry); -} - -/** * batadv_tt_orig_list_entry_release() - release tt orig entry from lists and * queue for free after rcu grace period * @ref: kref pointer of the tt orig entry @@ -433,7 +420,7 @@ static void batadv_tt_orig_list_entry_re refcount); batadv_orig_node_put(orig_entry->orig_node); - call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); + kfree_rcu(orig_entry, rcu); } /** diff -u -p a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -73,13 +73,6 @@ static inline int has_expired(const stru time_before_eq(fdb->updated + hold_time(br), jiffies); } -static void fdb_rcu_free(struct rcu_head *head) -{ - struct net_bridge_fdb_entry *ent - = container_of(head, struct net_bridge_fdb_entry, rcu); - kmem_cache_free(br_fdb_cache, ent); -} - static int fdb_to_nud(const struct net_bridge *br, const struct net_bridge_fdb_entry *fdb) { @@ -329,7 +322,7 @@ static void fdb_delete(struct net_bridge if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &f->flags)) atomic_dec(&br->fdb_n_learned); fdb_notify(br, f, RTM_DELNEIGH, swdev_notify); - call_rcu(&f->rcu, fdb_rcu_free); + kfree_rcu(f, rcu); } /* Delete a local entry if no other port had the same address. diff -u -p a/net/can/gw.c b/net/can/gw.c --- a/net/can/gw.c +++ b/net/can/gw.c @@ -577,13 +577,6 @@ static inline void cgw_unregister_filter gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj); } -static void cgw_job_free_rcu(struct rcu_head *rcu_head) -{ - struct cgw_job *gwj = container_of(rcu_head, struct cgw_job, rcu); - - kmem_cache_free(cgw_cache, gwj); -} - static int cgw_notifier(struct notifier_block *nb, unsigned long msg, void *ptr) { @@ -603,7 +596,7 @@ static int cgw_notifier(struct notifier_ if (gwj->src.dev == dev || gwj->dst.dev == dev) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } } @@ -1168,7 +1161,7 @@ static void cgw_remove_all_jobs(struct n hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } @@ -1236,7 +1229,7 @@ static int cgw_remove_job(struct sk_buff hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); err = 0; break; } diff -u -p a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -292,15 +292,9 @@ static const int inflate_threshold = 50; static const int halve_threshold_root = 15; static const int inflate_threshold_root = 30; -static void __alias_free_mem(struct rcu_head *head) -{ - struct fib_alias *fa = container_of(head, struct fib_alias, rcu); - kmem_cache_free(fn_alias_kmem, fa); -} - static inline void alias_free_mem_rcu(struct fib_alias *fa) { - call_rcu(&fa->rcu, __alias_free_mem); + kfree_rcu(fa, rcu); } #define TNODE_VMALLOC_MAX \ diff -u -p a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c @@ -128,11 +128,6 @@ static struct inet_peer *lookup(const st return NULL; } -static void inetpeer_free_rcu(struct rcu_head *head) -{ - kmem_cache_free(peer_cachep, container_of(head, struct inet_peer, rcu)); -} - /* perform garbage collect on all items stacked during a lookup */ static void inet_peer_gc(struct inet_peer_base *base, struct inet_peer *gc_stack[], @@ -168,7 +163,7 @@ static void inet_peer_gc(struct inet_pee if (p) { rb_erase(&p->rb_node, &base->rb_root); base->total--; - call_rcu(&p->rcu, inetpeer_free_rcu); + kfree_rcu(p, rcu); } } } @@ -242,7 +237,7 @@ void inet_putpeer(struct inet_peer *p) WRITE_ONCE(p->dtime, (__u32)jiffies); if (refcount_dec_and_test(&p->refcnt)) - call_rcu(&p->rcu, inetpeer_free_rcu); + kfree_rcu(p, rcu); } EXPORT_SYMBOL_GPL(inet_putpeer); diff -u -p a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -198,16 +198,9 @@ static void node_free_immediate(struct n net->ipv6.rt6_stats->fib_nodes--; } -static void node_free_rcu(struct rcu_head *head) -{ - struct fib6_node *fn = container_of(head, struct fib6_node, rcu); - - kmem_cache_free(fib6_node_kmem, fn); -} - static void node_free(struct net *net, struct fib6_node *fn) { - call_rcu(&fn->rcu, node_free_rcu); + kfree_rcu(fn, rcu); net->ipv6.rt6_stats->fib_nodes--; } diff -u -p a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c @@ -178,12 +178,6 @@ __be32 xfrm6_tunnel_alloc_spi(struct net } EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); -static void x6spi_destroy_rcu(struct rcu_head *head) -{ - kmem_cache_free(xfrm6_tunnel_spi_kmem, - container_of(head, struct xfrm6_tunnel_spi, rcu_head)); -} - static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) { struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); @@ -200,7 +194,7 @@ static void xfrm6_tunnel_free_spi(struct if (refcount_dec_and_test(&x6spi->refcnt)) { hlist_del_rcu(&x6spi->list_byaddr); hlist_del_rcu(&x6spi->list_byspi); - call_rcu(&x6spi->rcu_head, x6spi_destroy_rcu); + kfree_rcu(x6spi, rcu_head); break; } } diff -u -p a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1584,14 +1584,6 @@ static int kcm_ioctl(struct socket *sock return err; } -static void free_mux(struct rcu_head *rcu) -{ - struct kcm_mux *mux = container_of(rcu, - struct kcm_mux, rcu); - - kmem_cache_free(kcm_muxp, mux); -} - static void release_mux(struct kcm_mux *mux) { struct kcm_net *knet = mux->knet; @@ -1619,7 +1611,7 @@ static void release_mux(struct kcm_mux * knet->count--; mutex_unlock(&knet->mutex); - call_rcu(&mux->rcu, free_mux); + kfree_rcu(mux, rcu); } static void kcm_done(struct kcm_sock *kcm) diff -u -p a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c --- a/net/netfilter/nf_conncount.c +++ b/net/netfilter/nf_conncount.c @@ -275,14 +275,6 @@ bool nf_conncount_gc_list(struct net *ne } EXPORT_SYMBOL_GPL(nf_conncount_gc_list); -static void __tree_nodes_free(struct rcu_head *h) -{ - struct nf_conncount_rb *rbconn; - - rbconn = container_of(h, struct nf_conncount_rb, rcu_head); - kmem_cache_free(conncount_rb_cachep, rbconn); -} - /* caller must hold tree nf_conncount_locks[] lock */ static void tree_nodes_free(struct rb_root *root, struct nf_conncount_rb *gc_nodes[], @@ -295,7 +287,7 @@ static void tree_nodes_free(struct rb_ro spin_lock(&rbconn->list.list_lock); if (!rbconn->list.count) { rb_erase(&rbconn->node, root); - call_rcu(&rbconn->rcu_head, __tree_nodes_free); + kfree_rcu(rbconn, rcu_head); } spin_unlock(&rbconn->list.list_lock); } diff -u -p a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c @@ -367,18 +367,10 @@ void nf_ct_expect_init(struct nf_conntra } EXPORT_SYMBOL_GPL(nf_ct_expect_init); -static void nf_ct_expect_free_rcu(struct rcu_head *head) -{ - struct nf_conntrack_expect *exp; - - exp = container_of(head, struct nf_conntrack_expect, rcu); - kmem_cache_free(nf_ct_expect_cachep, exp); -} - void nf_ct_expect_put(struct nf_conntrack_expect *exp) { if (refcount_dec_and_test(&exp->use)) - call_rcu(&exp->rcu, nf_ct_expect_free_rcu); + kfree_rcu(exp, rcu); } EXPORT_SYMBOL_GPL(nf_ct_expect_put); diff -u -p a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -256,18 +256,11 @@ dsthash_alloc_init(struct xt_hashlimit_h return ent; } -static void dsthash_free_rcu(struct rcu_head *head) -{ - struct dsthash_ent *ent = container_of(head, struct dsthash_ent, rcu); - - kmem_cache_free(hashlimit_cachep, ent); -} - static inline void dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent) { hlist_del_rcu(&ent->node); - call_rcu(&ent->rcu, dsthash_free_rcu); + kfree_rcu(ent, rcu); ht->count--; } static void htable_gc(struct work_struct *work); From paulmck at kernel.org Wed Oct 9 21:02:13 2024 From: paulmck at kernel.org (Paul E. McKenney) Date: Wed, 09 Oct 2024 21:02:13 -0000 Subject: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <2ae9cb0-b16e-58a-693b-7cd927657946@inria.fr> References: <5c8b2883-962f-431f-b2d3-3632755de3b0@paulmck-laptop> <9967fdfa-e649-456d-a0cb-b4c4bf7f9d68@suse.cz> <6dad6e9f-e0ca-4446-be9c-1be25b2536dd@paulmck-laptop> <4cba4a48-902b-4fb6-895c-c8e6b64e0d5f@suse.cz> <37807ec7-d521-4f01-bcfc-a32650d5de25@suse.cz> <2ae9cb0-b16e-58a-693b-7cd927657946@inria.fr> Message-ID: <07880643-7181-44b8-8e19-e111cb44a081@paulmck-laptop> On Wed, Oct 09, 2024 at 07:08:58PM +0200, Julia Lawall wrote: > Hello, > > I have rerun the semantic patch that removes call_rcu calls in cases where > the callback function just does some pointer arithmetic and calls > kmem_cache_free. Let me know if this looks ok, and if so, I can make a > more formal patch submission. They look good to me, thank you! Thanx, Paul > This is against: > > commit 75b607fab38d149f232f01eae5e6392b394dd659 (HEAD -> master, origin/master, origin/HEAD) > Merge: 5b7c893ed5ed e0ed52154e86 > Author: Linus Torvalds > Date: Tue Oct 8 12:54:04 2024 -0700 > > Merge tag 'sched_ext-for-6.12-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext > > > julia > > diff -u -p a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c > --- a/arch/powerpc/kvm/book3s_mmu_hpte.c > +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c > @@ -92,12 +92,6 @@ void kvmppc_mmu_hpte_cache_map(struct kv > spin_unlock(&vcpu3s->mmu_lock); > } > > -static void free_pte_rcu(struct rcu_head *head) > -{ > - struct hpte_cache *pte = container_of(head, struct hpte_cache, rcu_head); > - kmem_cache_free(hpte_cache, pte); > -} > - > static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) > { > struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); > @@ -126,7 +120,7 @@ static void invalidate_pte(struct kvm_vc > > spin_unlock(&vcpu3s->mmu_lock); > > - call_rcu(&pte->rcu_head, free_pte_rcu); > + kfree_rcu(pte, rcu_head); > } > > static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu) > diff -u -p a/block/blk-ioc.c b/block/blk-ioc.c > --- a/block/blk-ioc.c > +++ b/block/blk-ioc.c > @@ -32,13 +32,6 @@ static void get_io_context(struct io_con > atomic_long_inc(&ioc->refcount); > } > > -static void icq_free_icq_rcu(struct rcu_head *head) > -{ > - struct io_cq *icq = container_of(head, struct io_cq, __rcu_head); > - > - kmem_cache_free(icq->__rcu_icq_cache, icq); > -} > - > /* > * Exit an icq. Called with ioc locked for blk-mq, and with both ioc > * and queue locked for legacy. > @@ -102,7 +95,7 @@ static void ioc_destroy_icq(struct io_cq > */ > icq->__rcu_icq_cache = et->icq_cache; > icq->flags |= ICQ_DESTROYED; > - call_rcu(&icq->__rcu_head, icq_free_icq_rcu); > + kfree_rcu(icq, __rcu_head); > } > > /* > diff -u -p a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c > --- a/drivers/net/wireguard/allowedips.c > +++ b/drivers/net/wireguard/allowedips.c > @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_n > } > } > > -static void node_free_rcu(struct rcu_head *rcu) > -{ > - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); > -} > - > static void root_free_rcu(struct rcu_head *rcu) > { > struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = { > @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct > child = rcu_dereference_protected( > parent->bit[!(node->parent_bit_packed & 1)], > lockdep_is_held(lock)); > - call_rcu(&node->rcu, node_free_rcu); > + kfree_rcu(node, rcu); > if (!free_parent) > continue; > if (child) > child->parent_bit_packed = parent->parent_bit_packed; > *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; > - call_rcu(&parent->rcu, node_free_rcu); > + kfree_rcu(parent, rcu); > } > } > > diff -u -p a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c > --- a/fs/ecryptfs/dentry.c > +++ b/fs/ecryptfs/dentry.c > @@ -51,12 +51,6 @@ static int ecryptfs_d_revalidate(struct > > struct kmem_cache *ecryptfs_dentry_info_cache; > > -static void ecryptfs_dentry_free_rcu(struct rcu_head *head) > -{ > - kmem_cache_free(ecryptfs_dentry_info_cache, > - container_of(head, struct ecryptfs_dentry_info, rcu)); > -} > - > /** > * ecryptfs_d_release > * @dentry: The ecryptfs dentry > @@ -68,7 +62,7 @@ static void ecryptfs_d_release(struct de > struct ecryptfs_dentry_info *p = dentry->d_fsdata; > if (p) { > path_put(&p->lower_path); > - call_rcu(&p->rcu, ecryptfs_dentry_free_rcu); > + kfree_rcu(p, rcu); > } > } > > diff -u -p a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -572,13 +572,6 @@ opaque_hashval(const void *ptr, int nbyt > return x; > } > > -static void nfsd4_free_file_rcu(struct rcu_head *rcu) > -{ > - struct nfs4_file *fp = container_of(rcu, struct nfs4_file, fi_rcu); > - > - kmem_cache_free(file_slab, fp); > -} > - > void > put_nfs4_file(struct nfs4_file *fi) > { > @@ -586,7 +579,7 @@ put_nfs4_file(struct nfs4_file *fi) > nfsd4_file_hash_remove(fi); > WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); > WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); > - call_rcu(&fi->fi_rcu, nfsd4_free_file_rcu); > + kfree_rcu(fi, fi_rcu); > } > } > > diff -u -p a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c > --- a/kernel/time/posix-timers.c > +++ b/kernel/time/posix-timers.c > @@ -413,18 +413,11 @@ static struct k_itimer * alloc_posix_tim > return tmr; > } > > -static void k_itimer_rcu_free(struct rcu_head *head) > -{ > - struct k_itimer *tmr = container_of(head, struct k_itimer, rcu); > - > - kmem_cache_free(posix_timers_cache, tmr); > -} > - > static void posix_timer_free(struct k_itimer *tmr) > { > put_pid(tmr->it_pid); > sigqueue_free(tmr->sigq); > - call_rcu(&tmr->rcu, k_itimer_rcu_free); > + kfree_rcu(tmr, rcu); > } > > static void posix_timer_unhash_and_free(struct k_itimer *tmr) > diff -u -p a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c > --- a/net/batman-adv/translation-table.c > +++ b/net/batman-adv/translation-table.c > @@ -408,19 +408,6 @@ static void batadv_tt_global_size_dec(st > } > > /** > - * batadv_tt_orig_list_entry_free_rcu() - free the orig_entry > - * @rcu: rcu pointer of the orig_entry > - */ > -static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) > -{ > - struct batadv_tt_orig_list_entry *orig_entry; > - > - orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); > - > - kmem_cache_free(batadv_tt_orig_cache, orig_entry); > -} > - > -/** > * batadv_tt_orig_list_entry_release() - release tt orig entry from lists and > * queue for free after rcu grace period > * @ref: kref pointer of the tt orig entry > @@ -433,7 +420,7 @@ static void batadv_tt_orig_list_entry_re > refcount); > > batadv_orig_node_put(orig_entry->orig_node); > - call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); > + kfree_rcu(orig_entry, rcu); > } > > /** > diff -u -p a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c > --- a/net/bridge/br_fdb.c > +++ b/net/bridge/br_fdb.c > @@ -73,13 +73,6 @@ static inline int has_expired(const stru > time_before_eq(fdb->updated + hold_time(br), jiffies); > } > > -static void fdb_rcu_free(struct rcu_head *head) > -{ > - struct net_bridge_fdb_entry *ent > - = container_of(head, struct net_bridge_fdb_entry, rcu); > - kmem_cache_free(br_fdb_cache, ent); > -} > - > static int fdb_to_nud(const struct net_bridge *br, > const struct net_bridge_fdb_entry *fdb) > { > @@ -329,7 +322,7 @@ static void fdb_delete(struct net_bridge > if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &f->flags)) > atomic_dec(&br->fdb_n_learned); > fdb_notify(br, f, RTM_DELNEIGH, swdev_notify); > - call_rcu(&f->rcu, fdb_rcu_free); > + kfree_rcu(f, rcu); > } > > /* Delete a local entry if no other port had the same address. > diff -u -p a/net/can/gw.c b/net/can/gw.c > --- a/net/can/gw.c > +++ b/net/can/gw.c > @@ -577,13 +577,6 @@ static inline void cgw_unregister_filter > gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj); > } > > -static void cgw_job_free_rcu(struct rcu_head *rcu_head) > -{ > - struct cgw_job *gwj = container_of(rcu_head, struct cgw_job, rcu); > - > - kmem_cache_free(cgw_cache, gwj); > -} > - > static int cgw_notifier(struct notifier_block *nb, > unsigned long msg, void *ptr) > { > @@ -603,7 +596,7 @@ static int cgw_notifier(struct notifier_ > if (gwj->src.dev == dev || gwj->dst.dev == dev) { > hlist_del(&gwj->list); > cgw_unregister_filter(net, gwj); > - call_rcu(&gwj->rcu, cgw_job_free_rcu); > + kfree_rcu(gwj, rcu); > } > } > } > @@ -1168,7 +1161,7 @@ static void cgw_remove_all_jobs(struct n > hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) { > hlist_del(&gwj->list); > cgw_unregister_filter(net, gwj); > - call_rcu(&gwj->rcu, cgw_job_free_rcu); > + kfree_rcu(gwj, rcu); > } > } > > @@ -1236,7 +1229,7 @@ static int cgw_remove_job(struct sk_buff > > hlist_del(&gwj->list); > cgw_unregister_filter(net, gwj); > - call_rcu(&gwj->rcu, cgw_job_free_rcu); > + kfree_rcu(gwj, rcu); > err = 0; > break; > } > diff -u -p a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c > --- a/net/ipv4/fib_trie.c > +++ b/net/ipv4/fib_trie.c > @@ -292,15 +292,9 @@ static const int inflate_threshold = 50; > static const int halve_threshold_root = 15; > static const int inflate_threshold_root = 30; > > -static void __alias_free_mem(struct rcu_head *head) > -{ > - struct fib_alias *fa = container_of(head, struct fib_alias, rcu); > - kmem_cache_free(fn_alias_kmem, fa); > -} > - > static inline void alias_free_mem_rcu(struct fib_alias *fa) > { > - call_rcu(&fa->rcu, __alias_free_mem); > + kfree_rcu(fa, rcu); > } > > #define TNODE_VMALLOC_MAX \ > diff -u -p a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c > --- a/net/ipv4/inetpeer.c > +++ b/net/ipv4/inetpeer.c > @@ -128,11 +128,6 @@ static struct inet_peer *lookup(const st > return NULL; > } > > -static void inetpeer_free_rcu(struct rcu_head *head) > -{ > - kmem_cache_free(peer_cachep, container_of(head, struct inet_peer, rcu)); > -} > - > /* perform garbage collect on all items stacked during a lookup */ > static void inet_peer_gc(struct inet_peer_base *base, > struct inet_peer *gc_stack[], > @@ -168,7 +163,7 @@ static void inet_peer_gc(struct inet_pee > if (p) { > rb_erase(&p->rb_node, &base->rb_root); > base->total--; > - call_rcu(&p->rcu, inetpeer_free_rcu); > + kfree_rcu(p, rcu); > } > } > } > @@ -242,7 +237,7 @@ void inet_putpeer(struct inet_peer *p) > WRITE_ONCE(p->dtime, (__u32)jiffies); > > if (refcount_dec_and_test(&p->refcnt)) > - call_rcu(&p->rcu, inetpeer_free_rcu); > + kfree_rcu(p, rcu); > } > EXPORT_SYMBOL_GPL(inet_putpeer); > > diff -u -p a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c > --- a/net/ipv6/ip6_fib.c > +++ b/net/ipv6/ip6_fib.c > @@ -198,16 +198,9 @@ static void node_free_immediate(struct n > net->ipv6.rt6_stats->fib_nodes--; > } > > -static void node_free_rcu(struct rcu_head *head) > -{ > - struct fib6_node *fn = container_of(head, struct fib6_node, rcu); > - > - kmem_cache_free(fib6_node_kmem, fn); > -} > - > static void node_free(struct net *net, struct fib6_node *fn) > { > - call_rcu(&fn->rcu, node_free_rcu); > + kfree_rcu(fn, rcu); > net->ipv6.rt6_stats->fib_nodes--; > } > > diff -u -p a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c > --- a/net/ipv6/xfrm6_tunnel.c > +++ b/net/ipv6/xfrm6_tunnel.c > @@ -178,12 +178,6 @@ __be32 xfrm6_tunnel_alloc_spi(struct net > } > EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); > > -static void x6spi_destroy_rcu(struct rcu_head *head) > -{ > - kmem_cache_free(xfrm6_tunnel_spi_kmem, > - container_of(head, struct xfrm6_tunnel_spi, rcu_head)); > -} > - > static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) > { > struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); > @@ -200,7 +194,7 @@ static void xfrm6_tunnel_free_spi(struct > if (refcount_dec_and_test(&x6spi->refcnt)) { > hlist_del_rcu(&x6spi->list_byaddr); > hlist_del_rcu(&x6spi->list_byspi); > - call_rcu(&x6spi->rcu_head, x6spi_destroy_rcu); > + kfree_rcu(x6spi, rcu_head); > break; > } > } > diff -u -p a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c > --- a/net/kcm/kcmsock.c > +++ b/net/kcm/kcmsock.c > @@ -1584,14 +1584,6 @@ static int kcm_ioctl(struct socket *sock > return err; > } > > -static void free_mux(struct rcu_head *rcu) > -{ > - struct kcm_mux *mux = container_of(rcu, > - struct kcm_mux, rcu); > - > - kmem_cache_free(kcm_muxp, mux); > -} > - > static void release_mux(struct kcm_mux *mux) > { > struct kcm_net *knet = mux->knet; > @@ -1619,7 +1611,7 @@ static void release_mux(struct kcm_mux * > knet->count--; > mutex_unlock(&knet->mutex); > > - call_rcu(&mux->rcu, free_mux); > + kfree_rcu(mux, rcu); > } > > static void kcm_done(struct kcm_sock *kcm) > diff -u -p a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c > --- a/net/netfilter/nf_conncount.c > +++ b/net/netfilter/nf_conncount.c > @@ -275,14 +275,6 @@ bool nf_conncount_gc_list(struct net *ne > } > EXPORT_SYMBOL_GPL(nf_conncount_gc_list); > > -static void __tree_nodes_free(struct rcu_head *h) > -{ > - struct nf_conncount_rb *rbconn; > - > - rbconn = container_of(h, struct nf_conncount_rb, rcu_head); > - kmem_cache_free(conncount_rb_cachep, rbconn); > -} > - > /* caller must hold tree nf_conncount_locks[] lock */ > static void tree_nodes_free(struct rb_root *root, > struct nf_conncount_rb *gc_nodes[], > @@ -295,7 +287,7 @@ static void tree_nodes_free(struct rb_ro > spin_lock(&rbconn->list.list_lock); > if (!rbconn->list.count) { > rb_erase(&rbconn->node, root); > - call_rcu(&rbconn->rcu_head, __tree_nodes_free); > + kfree_rcu(rbconn, rcu_head); > } > spin_unlock(&rbconn->list.list_lock); > } > diff -u -p a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c > --- a/net/netfilter/nf_conntrack_expect.c > +++ b/net/netfilter/nf_conntrack_expect.c > @@ -367,18 +367,10 @@ void nf_ct_expect_init(struct nf_conntra > } > EXPORT_SYMBOL_GPL(nf_ct_expect_init); > > -static void nf_ct_expect_free_rcu(struct rcu_head *head) > -{ > - struct nf_conntrack_expect *exp; > - > - exp = container_of(head, struct nf_conntrack_expect, rcu); > - kmem_cache_free(nf_ct_expect_cachep, exp); > -} > - > void nf_ct_expect_put(struct nf_conntrack_expect *exp) > { > if (refcount_dec_and_test(&exp->use)) > - call_rcu(&exp->rcu, nf_ct_expect_free_rcu); > + kfree_rcu(exp, rcu); > } > EXPORT_SYMBOL_GPL(nf_ct_expect_put); > > diff -u -p a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c > --- a/net/netfilter/xt_hashlimit.c > +++ b/net/netfilter/xt_hashlimit.c > @@ -256,18 +256,11 @@ dsthash_alloc_init(struct xt_hashlimit_h > return ent; > } > > -static void dsthash_free_rcu(struct rcu_head *head) > -{ > - struct dsthash_ent *ent = container_of(head, struct dsthash_ent, rcu); > - > - kmem_cache_free(hashlimit_cachep, ent); > -} > - > static inline void > dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent) > { > hlist_del_rcu(&ent->node); > - call_rcu(&ent->rcu, dsthash_free_rcu); > + kfree_rcu(ent, rcu); > ht->count--; > } > static void htable_gc(struct work_struct *work); From Julia.Lawall at inria.fr Sun Oct 13 20:17:58 2024 From: Julia.Lawall at inria.fr (Julia Lawall) Date: Sun, 13 Oct 2024 20:17:58 -0000 Subject: [PATCH 01/17] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <20241013201704.49576-2-Julia.Lawall@inria.fr> Since SLOB was removed and since commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were made using Coccinelle. Signed-off-by: Julia Lawall --- drivers/net/wireguard/allowedips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c index 4b8528206cc8..175b1ca4f66f 100644 --- a/drivers/net/wireguard/allowedips.c +++ b/drivers/net/wireguard/allowedips.c @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack, } } -static void node_free_rcu(struct rcu_head *rcu) -{ - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); -} - static void root_free_rcu(struct rcu_head *rcu) { struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = { @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct allowedips *table, child = rcu_dereference_protected( parent->bit[!(node->parent_bit_packed & 1)], lockdep_is_held(lock)); - call_rcu(&node->rcu, node_free_rcu); + kfree_rcu(node, rcu); if (!free_parent) continue; if (child) child->parent_bit_packed = parent->parent_bit_packed; *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; - call_rcu(&parent->rcu, node_free_rcu); + kfree_rcu(parent, rcu); } } From Julia.Lawall at inria.fr Sun Oct 13 20:17:58 2024 From: Julia.Lawall at inria.fr (Julia Lawall) Date: Sun, 13 Oct 2024 20:17:58 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback Message-ID: <20241013201704.49576-1-Julia.Lawall@inria.fr> Since SLOB was removed and since commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // #spatch --all-includes --include-headers @r@ expression e; local idexpression e2; identifier cb,f,g; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb at p) | call_rcu(&e->f.g,cb at p) ) @r1@ type T,T1; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x = ...; kmem_cache_free(...,(T1)x); | T x; x = ...; kmem_cache_free(...,(T1)x); ) } @s depends on r1@ position p != r.p; identifier r.cb; @@ cb at p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f,g; position r.p; @@ ( - call_rcu(&e->f,cb at p) + kfree_rcu(e,f) | - call_rcu(&e->f.g,cb at p) + kfree_rcu(e,f.g) ) @r1a depends on !s@ type T,T1; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x = ...; - kmem_cache_free(...,(T1)x); | - T x; - x = ...; - kmem_cache_free(...,(T1)x); ) - } @r2 depends on !r1@ identifier r.cb; @@ cb(...) { ... } @script:ocaml depends on !r1 && !r2@ cb << r.cb; @@ Printf.eprintf "need definition for %s\n" cb // --- arch/powerpc/kvm/book3s_mmu_hpte.c | 8 ------ block/blk-ioc.c | 9 ------ drivers/net/wireguard/allowedips.c | 9 +----- fs/ecryptfs/dentry.c | 8 ------ fs/nfsd/nfs4state.c | 9 ------ kernel/time/posix-timers.c | 9 ------ net/batman-adv/translation-table.c | 47 ++---------------------------------- net/bridge/br_fdb.c | 9 ------ net/can/gw.c | 13 ++------- net/ipv4/fib_trie.c | 8 ------ net/ipv4/inetpeer.c | 9 +----- net/ipv6/ip6_fib.c | 9 ------ net/ipv6/xfrm6_tunnel.c | 8 ------ net/kcm/kcmsock.c | 10 ------- net/netfilter/nf_conncount.c | 10 ------- net/netfilter/nf_conntrack_expect.c | 10 ------- net/netfilter/xt_hashlimit.c | 9 ------ 17 files changed, 23 insertions(+), 171 deletions(-) From paulmck at kernel.org Mon Oct 14 00:31:32 2024 From: paulmck at kernel.org (Paul E. McKenney) Date: Mon, 14 Oct 2024 00:31:32 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <47a98e77-8bbf-48d7-bb52-50e85a5336a0@paulmck-laptop> On Sun, Oct 13, 2024 at 10:16:47PM +0200, Julia Lawall wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. For the series: Acked-by: Paul E. McKenney > // > #spatch --all-includes --include-headers > > @r@ > expression e; > local idexpression e2; > identifier cb,f,g; > position p; > @@ > > ( > call_rcu(...,e2) > | > call_rcu(&e->f,cb at p) > | > call_rcu(&e->f.g,cb at p) > ) > > @r1@ > type T,T1; > identifier x,r.cb; > @@ > > cb(...) { > ( > kmem_cache_free(...); > | > T x = ...; > kmem_cache_free(...,(T1)x); > | > T x; > x = ...; > kmem_cache_free(...,(T1)x); > ) > } > > @s depends on r1@ > position p != r.p; > identifier r.cb; > @@ > > cb at p > > @script:ocaml@ > cb << r.cb; > p << s.p; > @@ > > Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line > > @depends on r1 && !s@ > expression e; > identifier r.cb,f,g; > position r.p; > @@ > > ( > - call_rcu(&e->f,cb at p) > + kfree_rcu(e,f) > | > - call_rcu(&e->f.g,cb at p) > + kfree_rcu(e,f.g) > ) > > @r1a depends on !s@ > type T,T1; > identifier x,r.cb; > @@ > > - cb(...) { > ( > - kmem_cache_free(...); > | > - T x = ...; > - kmem_cache_free(...,(T1)x); > | > - T x; > - x = ...; > - kmem_cache_free(...,(T1)x); > ) > - } > > @r2 depends on !r1@ > identifier r.cb; > @@ > > cb(...) { > ... > } > > @script:ocaml depends on !r1 && !r2@ > cb << r.cb; > @@ > > Printf.eprintf "need definition for %s\n" cb > // > > --- > > arch/powerpc/kvm/book3s_mmu_hpte.c | 8 ------ > block/blk-ioc.c | 9 ------ > drivers/net/wireguard/allowedips.c | 9 +----- > fs/ecryptfs/dentry.c | 8 ------ > fs/nfsd/nfs4state.c | 9 ------ > kernel/time/posix-timers.c | 9 ------ > net/batman-adv/translation-table.c | 47 ++---------------------------------- > net/bridge/br_fdb.c | 9 ------ > net/can/gw.c | 13 ++------- > net/ipv4/fib_trie.c | 8 ------ > net/ipv4/inetpeer.c | 9 +----- > net/ipv6/ip6_fib.c | 9 ------ > net/ipv6/xfrm6_tunnel.c | 8 ------ > net/kcm/kcmsock.c | 10 ------- > net/netfilter/nf_conncount.c | 10 ------- > net/netfilter/nf_conntrack_expect.c | 10 ------- > net/netfilter/xt_hashlimit.c | 9 ------ > 17 files changed, 23 insertions(+), 171 deletions(-) From vbabka at suse.cz Mon Oct 14 07:23:44 2024 From: vbabka at suse.cz (Vlastimil Babka) Date: Mon, 14 Oct 2024 07:23:44 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <9312d41b-9d84-4ff1-a33c-e4c2b496bd10@suse.cz> On 10/13/24 22:16, Julia Lawall wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. Thanks, LGTM! For the series: Acked-by: Vlastimil Babka From pablo at netfilter.org Mon Oct 14 11:26:06 2024 From: pablo at netfilter.org (Pablo Neira Ayuso) Date: Mon, 14 Oct 2024 11:26:06 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: On Sun, Oct 13, 2024 at 10:16:47PM +0200, Julia Lawall wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. Applied and squashed into single patch for netfilter these patches: [17/17] netfilter: xt_hashlimit: replace call_rcu by kfree_rcu for simple kmem_cache_free callback [16/17] netfilter: expect: replace call_rcu by kfree_rcu for simple kmem_cache_free callback [15/17] netfilter: nf_conncount: replace call_rcu by kfree_rcu for simple kmem_cache_free callback this update is now flying to net-next. Thanks From patchwork-bot+netdevbpf at kernel.org Tue Oct 15 13:40:29 2024 From: patchwork-bot+netdevbpf at kernel.org (patchwork-bot+netdevbpf at kernel.org) Date: Tue, 15 Oct 2024 13:40:29 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <172899963173.1165800.13282848624565322990.git-patchwork-notify@kernel.org> Hello: This series was applied to netdev/net-next.git (main) by Simon Wunderlich : On Sun, 13 Oct 2024 22:16:47 +0200 you wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. > > [...] Here is the summary with links: - [01/17] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [02/17] ipv4: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [03/17] inetpeer: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [04/17] ipv6: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [05/17] xfrm6_tunnel: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [06/17] batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/356c81b6c494 - [08/17] net: bridge: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [10/17] can: gw: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [14/17] kcm: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [15/17] netfilter: nf_conncount: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [16/17] netfilter: expect: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [17/17] netfilter: xt_hashlimit: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html From patchwork-bot+netdevbpf at kernel.org Tue Oct 15 18:00:37 2024 From: patchwork-bot+netdevbpf at kernel.org (patchwork-bot+netdevbpf at kernel.org) Date: Tue, 15 Oct 2024 18:00:37 -0000 Subject: [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <172901524099.1243233.14809044192149107515.git-patchwork-notify@kernel.org> Hello: This series was applied to netdev/net-next.git (main) by Jakub Kicinski : On Sun, 13 Oct 2024 22:16:47 +0200 you wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. > > [...] Here is the summary with links: - [01/17] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [02/17] ipv4: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/497e17d80759 - [03/17] inetpeer: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/bb5810d4236b - [04/17] ipv6: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/85e48bcf294c - [05/17] xfrm6_tunnel: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [06/17] batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [08/17] net: bridge: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/4ac64e570c33 - [10/17] can: gw: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [14/17] kcm: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/7bb3ecbc2b6b - [15/17] netfilter: nf_conncount: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [16/17] netfilter: expect: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) - [17/17] netfilter: xt_hashlimit: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (no matching commit) You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html From urezki at gmail.com Wed Oct 16 11:04:43 2024 From: urezki at gmail.com (Uladzislau Rezki) Date: Wed, 16 Oct 2024 11:04:43 -0000 Subject: [PATCH 01/17] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-2-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> <20241013201704.49576-2-Julia.Lawall@inria.fr> Message-ID: On Sun, Oct 13, 2024 at 10:16:48PM +0200, Julia Lawall wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were made using Coccinelle. > > Signed-off-by: Julia Lawall > > --- > drivers/net/wireguard/allowedips.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c > index 4b8528206cc8..175b1ca4f66f 100644 > --- a/drivers/net/wireguard/allowedips.c > +++ b/drivers/net/wireguard/allowedips.c > @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack, > } > } > > -static void node_free_rcu(struct rcu_head *rcu) > -{ > - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); > -} > - > static void root_free_rcu(struct rcu_head *rcu) > { > struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = { > @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct allowedips *table, > child = rcu_dereference_protected( > parent->bit[!(node->parent_bit_packed & 1)], > lockdep_is_held(lock)); > - call_rcu(&node->rcu, node_free_rcu); > + kfree_rcu(node, rcu); > if (!free_parent) > continue; > if (child) > child->parent_bit_packed = parent->parent_bit_packed; > *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; > - call_rcu(&parent->rcu, node_free_rcu); > + kfree_rcu(parent, rcu); > } > } > > > Reviewed-by: Uladzislau Rezki (Sony) -- Uladzislau Rezki From ameir at ameir.net Fri Oct 4 20:16:02 2024 From: ameir at ameir.net (Ameir Abdeldayem) Date: Fri, 04 Oct 2024 20:16:02 -0000 Subject: wireguard-go - sendmmsg: function not implemented In-Reply-To: References: Message-ID: Hello, I am trying to run wireguard-go on a router running FreshTomato, which uses uclibc as its libc. When running wireguard-go, I get several of these messages: DEBUG: (wg) 2024/10/04 13:48:25 peer(oXlL?hrHI) - Sending handshake initiation ERROR: (wg) 2024/10/04 13:48:25 peer(oXlL?hrHI) - Failed to send handshake initiation: write udp 0.0.0.0:36895: sendmmsg: function not implemented I believe there may be a compatibility issue between the sendmmsg syscall and my version of uclibc. Do you know if there's a way to build a compatible wireguard-go? Are there build flags, for example, that would cause wireguard-go to use alternative syscalls, like sendmsg, instead (even if there's a performance hit)? I thought that with CGO_ENABLED=0 I wouldn't hit this issue, but it might be that the syscalls are being called directly in code. Thanks, Ameir From axboe at kernel.dk Sun Oct 13 20:53:34 2024 From: axboe at kernel.dk (Jens Axboe) Date: Sun, 13 Oct 2024 20:53:34 -0000 Subject: (subset) [PATCH 00/17] replace call_rcu by kfree_rcu for simple kmem_cache_free callback In-Reply-To: <20241013201704.49576-1-Julia.Lawall@inria.fr> References: <20241013201704.49576-1-Julia.Lawall@inria.fr> Message-ID: <172885281086.338120.2063739137198887833.b4-ty@kernel.dk> On Sun, 13 Oct 2024 22:16:47 +0200, Julia Lawall wrote: > Since SLOB was removed and since > commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), > it is not necessary to use call_rcu when the callback only performs > kmem_cache_free. Use kfree_rcu() directly. > > The changes were done using the following Coccinelle semantic patch. > This semantic patch is designed to ignore cases where the callback > function is used in another way. > > [...] Applied, thanks! [09/17] block: replace call_rcu by kfree_rcu for simple kmem_cache_free callback commit: 7a9b197adbafa9d6d1a79a0633607b78b1adef82 Best regards, -- Jens Axboe