Message ID | 33dfdf2119c86e35062f783d405bedec2fde2b4c.1651071843.git.asml.silence@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | UDP/IPv6 refactoring | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/apply | fail | Patch does not apply to net-next |
On Thu, 2022-04-28 at 11:56 +0100, Pavel Begunkov wrote: > Don't save a IS_UDPLITE() result in advance but do when it's really > needed, so it doesn't store/load it from the stack. Same for resolving > the getfrag callback pointer. It's quite unclear to me if this change brings really any performance benefit. The end results will depend a lot on the optimization performed by the compiler, and IMHO the code looks better before this modifications. Paolo
On 4/28/22 15:09, Paolo Abeni wrote: > On Thu, 2022-04-28 at 11:56 +0100, Pavel Begunkov wrote: >> Don't save a IS_UDPLITE() result in advance but do when it's really >> needed, so it doesn't store/load it from the stack. Same for resolving >> the getfrag callback pointer. > > It's quite unclear to me if this change brings really any performance > benefit. The end results will depend a lot on the optimization > performed by the compiler, and IMHO the code looks better before this > modifications. There is a lot of code and function calls between IS_UDPLITE() and use sites, because of alias analysis the compiler will be forced to call it early in the function and store something on stack. I don't believe it will be able to keep in a register. But it's not a problem to drop it
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index de8382930910..705eea080f5e 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1310,7 +1310,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) int ulen = len; int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE; int err; - int is_udplite = IS_UDPLITE(sk); int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); ipcm6_init_sk(&ipc6, np); @@ -1371,7 +1370,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (len > INT_MAX - sizeof(struct udphdr)) return -EMSGSIZE; - getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag; if (up->pending) { if (up->pending == AF_INET) return udp_sendmsg(sk, msg, len); @@ -1538,6 +1536,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (!corkreq) { struct sk_buff *skb; + getfrag = IS_UDPLITE(sk) ? udplite_getfrag : ip_generic_getfrag; skb = ip6_make_skb(sk, getfrag, msg, ulen, sizeof(struct udphdr), &ipc6, (struct rt6_info *)dst, @@ -1564,6 +1563,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) do_append_data: up->len += ulen; + getfrag = IS_UDPLITE(sk) ? udplite_getfrag : ip_generic_getfrag; err = ip6_append_data(sk, getfrag, msg, ulen, sizeof(struct udphdr), &ipc6, fl6, (struct rt6_info *)dst, corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); @@ -1594,7 +1594,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) */ if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { UDP6_INC_STATS(sock_net(sk), - UDP_MIB_SNDBUFERRORS, is_udplite); + UDP_MIB_SNDBUFERRORS, IS_UDPLITE(sk)); } return err;
Don't save a IS_UDPLITE() result in advance but do when it's really needed, so it doesn't store/load it from the stack. Same for resolving the getfrag callback pointer. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- net/ipv6/udp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)