Re: [PATCH net-next v19 03/13] netdev: support binding dma-buf to netdevice

2024-08-21 Thread Taehee Yoo
On Thu, Aug 22, 2024 at 12:36 AM Mina Almasry wrote: > > On Wed, Aug 21, 2024 at 5:15 AM Taehee Yoo wrote: > > > > On Tue, Aug 20, 2024 at 1:01 PM Mina Almasry wrote: > > > > > > On Mon, Aug 19, 2024 at 6:53 PM Jakub Kicinski wrote: > > > > >

Re: [PATCH net-next v19 03/13] netdev: support binding dma-buf to netdevice

2024-08-21 Thread Taehee Yoo
On Tue, Aug 20, 2024 at 1:01 PM Mina Almasry wrote: > > On Mon, Aug 19, 2024 at 6:53 PM Jakub Kicinski wrote: > > > > On Mon, 19 Aug 2024 00:44:27 +0900 Taehee Yoo wrote: > > > > @@ -9537,6 +9540,10 @@ static int dev_xdp_attach(struct net_device > > >

Re: [PATCH net-next v19 03/13] netdev: support binding dma-buf to netdevice

2024-08-18 Thread Taehee Yoo
On Wed, Aug 14, 2024 at 6:13 AM Mina Almasry wrote: > > Add a netdev_dmabuf_binding struct which represents the > dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to > rx queues on the netdevice. On the binding, the dma_buf_attach > & dma_buf_map_attachment will occur. The entri

Re: [PATCH net-next v19 09/13] tcp: RX path for devmem TCP

2024-08-17 Thread Taehee Yoo
On Sun, Aug 18, 2024 at 12:13 AM Mina Almasry wrote: > > On Sat, Aug 17, 2024 at 9:58 AM Taehee Yoo wrote: > > > > On Wed, Aug 14, 2024 at 6:13 AM Mina Almasry wrote: > > > > > > > Hi Mina, > > > > > In tcp_recvmsg_locked(), detect if the sk

Re: [PATCH net-next v19 09/13] tcp: RX path for devmem TCP

2024-08-17 Thread Taehee Yoo
frags); > + > trace_tcp_destroy_sock(sk); > > tcp_clear_xmit_timers(sk); > diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c > index a19a9dbd3409..9ab87a41255d 100644 > --- a/net/ipv4/tcp_minisocks.c > +++ b/net/ipv4/tcp_minisocks.c > @@ -625,6 +625,8 @@ struct sock *tcp_create_openreq_child(const struct sock > *sk, > > __TCP_INC_STATS(sock_net(sk), TCP_MIB_PASSIVEOPENS); > > + xa_init_flags(&newsk->sk_user_frags, XA_FLAGS_ALLOC1); > + > return newsk; > } > EXPORT_SYMBOL(tcp_create_openreq_child); > -- > 2.46.0.76.ge559c4bf1a-goog > I have been testing with modified code like below, it has been working correctly for 24+ hours. This modification is only for simple testing. So, could you please look into this problem? diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 40e7335dae6e..b9df6ac28477 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2396,9 +2396,11 @@ static int tcp_recvmsg_dmabuf(struct sock *sk, const struct sk_buff *skb, struct dmabuf_cmsg dmabuf_cmsg = { 0 }; struct tcp_xa_pool tcp_xa_pool; unsigned int start; + int skip = offset; int i, copy, n; int sent = 0; int err = 0; + int end = 0; tcp_xa_pool.max = 0; tcp_xa_pool.idx = 0; @@ -2452,7 +2454,6 @@ static int tcp_recvmsg_dmabuf(struct sock *sk, const struct sk_buff *skb, skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; struct net_iov *niov; u64 frag_offset; - int end; /* !skb_frags_readable() should indicate that ALL the * frags in this skb are dmabuf net_iovs. We're checking @@ -2522,7 +2523,14 @@ static int tcp_recvmsg_dmabuf(struct sock *sk, const struct sk_buff *skb, */ skb = skb_shinfo(skb)->frag_list ?: skb->next; - offset = 0; + if (skip > 0) { + skip -= end; + offset = skip; + } + if (skip <= 0) { + offset = 0; + skip = 0; + } } while (skb); if (remaining_len) { Thanks a lot! Taehee Yoo

Re: [PATCH net-next v15 03/14] netdev: support binding dma-buf to netdevice

2024-07-24 Thread Taehee Yoo
On Wed, Jul 24, 2024 at 6:49 AM Mina Almasry wrote: > > On Tue, Jul 9, 2024 at 8:37 AM Taehee Yoo wrote: > ... > > Reproducer: > > ./ncdevmem -f -l -p 5201 -v 7 -t 0 -q 2 & > > sleep 10 > > modprobe -rv bnxt_en > > killall ncdevmem > > > >

Re: [PATCH net-next v15 03/14] netdev: support binding dma-buf to netdevice

2024-07-09 Thread Taehee Yoo
On Tue, Jul 9, 2024 at 5:08 AM Mina Almasry wrote: > Hi Mina, Thanks a lot for your reply! > On Thu, Jul 4, 2024 at 10:57 AM Taehee Yoo wrote: > > > > I found several locking warnings while testing. > > > > Thanks for Testing Taehee! And sorry for the late repl

Re: [PATCH net-next v15 03/14] netdev: support binding dma-buf to netdevice

2024-07-04 Thread Taehee Yoo
x10 [ 1136.450823] ? mark_held_locks+0xa5/0xf0 [ 1136.455490] ? __local_bh_enable_ip+0xa5/0x120 [ 1136.460790] ? __pfx_genl_release+0x10/0x10 [ 1136.465703] netlink_release+0x839/0x18f0 [ 1135.709313] WARNING: CPU: 3 PID: 1644 at net/core/netdev_rx_queue.c:18 netdev_rx_queue_restart+0x3f4/0x5a0 [ 1135.719686] Modules linked in: 8021q garp mrp xt_nat xt_tcpudp veth xt_conntrack nft_chain_nat xt_MASQUERADE nf_nat nf _conntrack_netlink nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xfrm_user xt_addrtype nft_compat nf_tables br_netfilter bri dge stp llc qrtr crct10dif_pclmul overlay crc32_generic crc32_pclmul crc32c_intel ghash_clmulni_intel sha512_ssse3 sha256 _ssse3 sha1_ssse3 xts amdgpu cts wmi_bmof aesni_intel amdxcp i2c_algo_bit crypto_simd drm_ttm_helper cryptd ttm drm_exec bnxt_en ionic gpu_sched drm_suballoc_helper drm_buddy ptp video drm_display_helper drm_kms_helper wmi cfg80211 drm drm_pa nel_orientation_quirks backlight nfnetlink bpf_preload ip_tables x_tables [ 1135.779526] CPU: 3 PID: 1644 Comm: ncdevmem Tainted: G W 6.10.0-rc5+ #43 6e089cf25edb5a71cabb8ab97c9df bf7e96b1a3a [ 1135.791882] Hardware name: ASUS System Product Name/PRIME Z690-P D4, BIOS 0603 11/01/2021 [ 1135.800781] RIP: 0010:netdev_rx_queue_restart+0x3f4/0x5a0 [ 1135.806905] Code: d0 0f 1f 00 48 89 df e8 9a ce a9 fe 4c 89 f7 e8 92 ce a9 fe 48 83 c4 08 44 89 e0 5b 5d 41 5c 41 5d 4 1 5e 41 5f c3 cc cc cc cc <0f> 0b e9 05 fd ff ff 44 89 fe 48 c7 c7 80 70 fc 86 e8 46 7c 38 fe [ 1135.826382] RSP: 0018:888224c2fbb0 EFLAGS: 00010246 [ 1135.832339] RAX: RBX: c0bb5c80 RCX: 842d81c3 [ 1135.840185] RDX: 11e6fc44 RSI: 0008 RDI: 8f37e220 [ 1135.848028] RBP: 88814b864000 R08: R09: fbfff1e6fc44 [ 1135.855875] R10: 8f37e227 R11: R12: 888224c2fc28 [ 1135.863716] R13: 88814b864be0 R14: ed102265e337 R15: 0001 [ 1135.871560] FS: 7fe9b77b4740() GS:1ba0() knlGS: [ 1135.880364] CS: 0010 DS: ES: CR0: 80050033 [ 1135.886824] CR2: 7f5f22a21f50 CR3: 0001094a CR4: 007506f0 [ 1135.894670] PKRU: 5554 [ 1135.898090] Call Trace: [ 1135.901255] [ 1135.904073] ? __warn+0xc8/0x2f0 [ 1135.908020] ? netdev_rx_queue_restart+0x3f4/0x5a0 [ 1135.913524] ? report_bug+0x326/0x3c0 [ 1135.917908] ? handle_bug+0x3c/0x70 [ 1135.922112] ? exc_invalid_op+0x14/0x50 [ 1135.926671] ? asm_exc_invalid_op+0x16/0x20 [ 1135.931591] ? mutex_is_locked+0x13/0x50 [ 1135.936238] ? netdev_rx_queue_restart+0x3f4/0x5a0 [ 1135.941748] net_devmem_unbind_dmabuf+0x2a3/0x440 [ 1135.947179] ? __pfx_lock_release+0x10/0x10 [ 1135.952081] ? __pfx_net_devmem_unbind_dmabuf+0x10/0x10 [ 1135.958040] netdev_nl_sock_priv_destroy+0x72/0xc0 [ 1135.963561] genl_release+0xed/0x190 [ 1135.967851] ? __pfx_genl_release+0x10/0x10 [ 1135.972755] ? mark_held_locks+0xa5/0xf0 [ 1135.977392] ? __local_bh_enable_ip+0xa5/0x120 [ 1135.982561] ? __pfx_genl_release+0x10/0x10 [ 1135.987464] netlink_release+0x839/0x18f0 Thanks! Taehee Yoo

Re: [PATCH net-next v15 03/14] netdev: support binding dma-buf to netdevice

2024-07-04 Thread Taehee Yoo
nl_info_net(info), ifindex); > + if (!netdev) { > + err = -ENODEV; > + goto err_unlock; > + } > + > + err = net_devmem_bind_dmabuf(netdev, dmabuf_fd, &out_binding); > + if (err) > + goto err_unlock; > + > + nla_for_each_attr(attr, genlmsg_data(info->genlhdr), > + genlmsg_len(info->genlhdr), rem) { > + if (nla_type(attr) != NETDEV_A_BIND_DMABUF_QUEUES) > + continue; > + > + err = nla_parse_nested( > + tb, ARRAY_SIZE(netdev_queue_dmabuf_nl_policy) - 1, > attr, > + netdev_queue_dmabuf_nl_policy, info->extack); > + if (err < 0) > + goto err_unbind; > + > + rxq_idx = nla_get_u32(tb[NETDEV_A_QUEUE_DMABUF_IDX]); > + > + err = net_devmem_bind_dmabuf_to_queue(netdev, rxq_idx, > + out_binding); > + if (err) > + goto err_unbind; > + } > + > + sock_binding_list = genl_sk_priv_get(&netdev_nl_family, > +NETLINK_CB(skb).sk); > + if (IS_ERR(sock_binding_list)) { > + err = PTR_ERR(sock_binding_list); > + goto err_unbind; > + } > + > + list_add(&out_binding->list, sock_binding_list); > + > + rsp = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL); > + if (!rsp) { > + err = -ENOMEM; > + goto err_unbind; > + } > + > + hdr = genlmsg_iput(rsp, info); > + if (!hdr) { > + err = -EMSGSIZE; > + goto err_genlmsg_free; > + } > + > + nla_put_u32(rsp, NETDEV_A_BIND_DMABUF_DMABUF_ID, out_binding->id); > + genlmsg_end(rsp, hdr); > + > + rtnl_unlock(); > + > + return genlmsg_reply(rsp, info); > + > +err_genlmsg_free: > + nlmsg_free(rsp); > +err_unbind: > + net_devmem_unbind_dmabuf(out_binding); > +err_unlock: > + rtnl_unlock(); > + return err; > } > > static int netdev_genl_netdevice_event(struct notifier_block *nb, > @@ -771,3 +854,17 @@ static int __init netdev_genl_init(void) > } > > subsys_initcall(netdev_genl_init); > + > +void netdev_nl_sock_priv_init(struct list_head *priv) > +{ > + INIT_LIST_HEAD(priv); > +} > + > +void netdev_nl_sock_priv_destroy(struct list_head *priv) > +{ > + struct net_devmem_dmabuf_binding *binding; > + struct net_devmem_dmabuf_binding *temp; > + > + list_for_each_entry_safe(binding, temp, priv, list) > + net_devmem_unbind_dmabuf(binding); > +} > -- > 2.45.2.803.g4e1b14247a-goog > > Thanks a lot! Taehee Yoo

Re: [PATCH net-next v15 14/14] selftests: add ncdevmem, netcat for devmem TCP

2024-07-04 Thread Taehee Yoo
t; + error(1, 0, "flow steering error\n"); > + > + printf("total_received=%lu\n", total_received); > + } > + > + fprintf(stdout, "%s: ok\n", TEST_PREFIX); > + > + fprintf(stdout, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", > + page_aligned_frags, non_page_aligned_frags); > + > + fprintf(stdout, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", > + page_aligned_frags, non_page_aligned_frags); > + > +cleanup: > + > + munmap(buf_mem, dmabuf_size); > + close(client_fd); > + close(socket_fd); > + close(buf); > + close(memfd); > + close(devfd); > + ynl_sock_destroy(ys); > + > + return 0; > +} > + > +void run_devmem_tests(void) > +{ > + struct netdev_queue_dmabuf *queues; > + int devfd, memfd, buf; > + struct ynl_sock *ys; > + size_t dmabuf_size; > + size_t i = 0; > + > + dmabuf_size = getpagesize() * NUM_PAGES; > + > + create_udmabuf(&devfd, &memfd, &buf, dmabuf_size); > + > + /* Configure RSS to divert all traffic from our devmem queues */ > + configure_rss(); > + > + sleep(1); > + > + queues = malloc(sizeof(*queues) * num_queues); > + > + for (i = 0; i < num_queues; i++) { > + queues[i]._present.type = 1; > + queues[i]._present.idx = 1; > + queues[i].type = NETDEV_QUEUE_TYPE_RX; > + queues[i].idx = start_queue + i; > + } > + > + if (bind_rx_queue(ifindex, buf, queues, num_queues, &ys)) > + error(1, 0, "Failed to bind\n"); > + > + /* Closing the netlink socket does an implicit unbind */ > + ynl_sock_destroy(ys); > +} > + > +int main(int argc, char *argv[]) > +{ > + int is_server = 0, opt; > + > + while ((opt = getopt(argc, argv, "ls:c:p:v:q:f:n:i:d:")) != -1) { I think 't' option should be added here. > + switch (opt) { > + case 'l': > + is_server = 1; > + break; > + case 's': > + server_ip = optarg; > + break; > + case 'c': > + client_ip = optarg; > + break; > + case 'p': > + port = optarg; > + break; > + case 'v': > + do_validation = atoll(optarg); > + break; > + case 'q': > + num_queues = atoi(optarg); > + break; > + case 't': > + start_queue = atoi(optarg); > + break; > + case 'f': > + ifname = optarg; > + break; > + case 'd': > + ifindex = atoi(optarg); How about using if_nametoindex() instead of 'd' option? > + break; > + case 'i': > + iterations = atoll(optarg); I couldn't find a use of this variable. > + break; > + case '?': > + printf("unknown option: %c\n", optopt); > + break; > + } > + } > + > + for (; optind < argc; optind++) > + printf("extra arguments: %s\n", argv[optind]); > + > + run_devmem_tests(); > + > + if (is_server) > + return do_server(); > + > + return 0; > +} > -- > 2.45.2.803.g4e1b14247a-goog > > Thanks a lot! Taehee Yoo

[PATCH net-next] selftests: net: change shebang to bash in amt.sh

2024-06-20 Thread Taehee Yoo
amt.sh is written in bash, not sh. So, shebang should be bash. Signed-off-by: Taehee Yoo --- tools/testing/selftests/net/amt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/amt.sh b/tools/testing/selftests/net/amt.sh index 7e7ed6c558da

[PATCH net v3] selftests: net: kill smcrouted in the cleanup logic in amt.sh

2024-05-18 Thread Taehee Yoo
ot;) Signed-off-by: Taehee Yoo --- The v1 patch is here: https://lore.kernel.org/netdev/20240508040643.229383-1-ap420...@gmail.com/ v3 - Do not change shebang. v2 - Headline change. - Kill smcrouted process only if amt.pid exists. - Do not remove the return value. - Remove timeout logic

Re: [PATCH net v2] selftests: net: kill smcrouted in the cleanup logic in amt.sh

2024-05-15 Thread Taehee Yoo
On Wed, May 15, 2024 at 6:48 PM Simon Horman wrote: > Hi Simon, Thanks for the review! > On Mon, May 13, 2024 at 06:08:52AM +, Taehee Yoo wrote: > > The amt.sh requires smcrouted for multicasting routing. > > So, it starts smcrouted before forwarding tests. > > It m

[PATCH net v2] selftests: net: kill smcrouted in the cleanup logic in amt.sh

2024-05-12 Thread Taehee Yoo
ot;) Signed-off-by: Taehee Yoo --- The v1 patch is here: https://lore.kernel.org/netdev/20240508040643.229383-1-ap420...@gmail.com/ v2 - Headline change. - Kill smcrouted process only if amt.pid exists. - Do not remove the return value. - Remove timeout logic because it was already fixed by f

Re: [PATCH net] selftests: net: move amt to socat for better compatibility

2024-05-09 Thread Taehee Yoo
exit 0 > else > @@ -236,14 +236,14 @@ send_mcast4() > { > sleep 2 > ip netns exec "${SOURCE}" bash -c \ > - 'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' & > + 'printf "%s %128s" 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' & > } > > send_mcast6() > { > sleep 2 > ip netns exec "${SOURCE}" bash -c \ > - 'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' & > + 'printf "%s %128s" 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' > & > } > > check_features > -- > 2.45.0 > Tested-by: Taehee Yoo

Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Fri, May 10, 2024 at 1:23 AM Jakub Kicinski wrote: > Hi Jakub, Thanks a lot for the review and looking into the bug. > On Wed, 8 May 2024 04:06:43 + Taehee Yoo wrote: > > In the forwarding testcase, it opens a server and a client with the nc. > > The server receives t

Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Thu, May 9, 2024 at 6:36 PM Paolo Abeni wrote: > Hi Paolo, Thank you for the review! > On Wed, 2024-05-08 at 04:06 +, Taehee Yoo wrote: > > > @@ -210,40 +217,52 @@ check_features() > > > > test_ipv4_forward() > > { > > - RESULT4=$(ip netns exec &qu

Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Thu, May 9, 2024 at 5:38 PM Simon Horman wrote: > Hi Simon, Thanks a lot for the review! > On Wed, May 08, 2024 at 04:06:43AM +, Taehee Yoo wrote: > > In the forwarding testcase, it opens a server and a client with the nc. > > The server receives the correct message fro

[PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-07 Thread Taehee Yoo
Fixes: c08e8baea78e ("selftests: add amt interface selftest script") Signed-off-by: Taehee Yoo --- tools/testing/selftests/net/amt.sh | 63 +++--- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/net/amt.sh b/tools/testing/selft