From 59d5251aece7b7afcd5c671d037cac5f0267c605 Mon Sep 17 00:00:00 2001 From: bluhm Date: Fri, 26 Jul 2024 14:38:20 +0000 Subject: [PATCH] Run UDP input on multiple CPU in parallel. The socket layer of UDP has been made fully MP safe. UDP output is MP safe for a while. mvs@ has fixed the missing pieces in socket splicing recently. This means that complete UDP stack can be processed by multiple threads now. Activate multi processing for udp_input() when called with IPv4 or IPv6 packets. Usually IP processing runs on multiple softnet threads with shared net lock. From there local packets are queued and processed by one thread with exclusive net lock. If the PR_MPINPUT flag is set, protocol input is called directly from IP input on multiple threads, with shared net lock and no additional queueing. tested by Hrvoje Popovski; OK mvs@ --- sys/netinet/in_proto.c | 4 ++-- sys/netinet6/in6_proto.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 5f9a1fbd3d7..579522f6017 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.106 2024/07/13 12:00:11 bluhm Exp $ */ +/* $OpenBSD: in_proto.c,v 1.107 2024/07/26 14:38:20 bluhm Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -185,7 +185,7 @@ const struct protosw inetsw[] = { .pr_type = SOCK_DGRAM, .pr_domain = &inetdomain, .pr_protocol = IPPROTO_UDP, - .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPSOCKET, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPINPUT|PR_MPSOCKET, .pr_input = udp_input, .pr_ctlinput = udp_ctlinput, .pr_ctloutput = ip_ctloutput, diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index ac9f8848186..2d7343a52a3 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.116 2024/07/19 16:58:32 bluhm Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.117 2024/07/26 14:38:20 bluhm Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -136,7 +136,7 @@ const struct protosw inet6sw[] = { .pr_type = SOCK_DGRAM, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_UDP, - .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPSOCKET, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPINPUT|PR_MPSOCKET, .pr_input = udp_input, .pr_ctlinput = udp6_ctlinput, .pr_ctloutput = ip6_ctloutput, -- 2.20.1