One approach to indirect call optimization
by Mat Martineau
I noticed this patch on netdev to avoid an indirect call to md5_lookup,
which was accepted. It is mitigating the cost of an existing indirect call
rather than adding a new one, but shows how the maintainers are looking at
the problem.
--
Mat Martineau
Intel OTC
---------- Forwarded message ----------
Date: Mon, 23 Apr 2018 14:46:25
From: Eric Dumazet <edumazet(a)google.com>
To: David S . Miller <davem(a)davemloft.net>
Cc: netdev <netdev(a)vger.kernel.org>, Eric Dumazet <edumazet(a)google.com>,
Eric Dumazet <eric.dumazet(a)gmail.com>
Subject: [PATCH net-next] tcp: md5: only call tp->af_specific->md5_lookup() for
md5 sockets
RETPOLINE made calls to tp->af_specific->md5_lookup() quite expensive,
given they have no result.
We can omit the calls for sockets that have no md5 keys.
Signed-off-by: Eric Dumazet <edumazet(a)google.com>
---
net/ipv4/tcp_output.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 383cac0ff0ec059ca7dbc1a6304cc7f8183e008d..95feffb6d53f8a9eadfb15a2fffeec498d6e993a 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -585,14 +585,15 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,
unsigned int remaining = MAX_TCP_OPTION_SPACE;
struct tcp_fastopen_request *fastopen = tp->fastopen_req;
+ *md5 = NULL;
#ifdef CONFIG_TCP_MD5SIG
- *md5 = tp->af_specific->md5_lookup(sk, sk);
- if (*md5) {
- opts->options |= OPTION_MD5;
- remaining -= TCPOLEN_MD5SIG_ALIGNED;
+ if (unlikely(rcu_access_pointer(tp->md5sig_info))) {
+ *md5 = tp->af_specific->md5_lookup(sk, sk);
+ if (*md5) {
+ opts->options |= OPTION_MD5;
+ remaining -= TCPOLEN_MD5SIG_ALIGNED;
+ }
}
-#else
- *md5 = NULL;
#endif
/* We always get an MSS option. The option bytes which will be seen in
@@ -720,14 +721,15 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb
opts->options = 0;
+ *md5 = NULL;
#ifdef CONFIG_TCP_MD5SIG
- *md5 = tp->af_specific->md5_lookup(sk, sk);
- if (unlikely(*md5)) {
- opts->options |= OPTION_MD5;
- size += TCPOLEN_MD5SIG_ALIGNED;
+ if (unlikely(rcu_access_pointer(tp->md5sig_info))) {
+ *md5 = tp->af_specific->md5_lookup(sk, sk);
+ if (*md5) {
+ opts->options |= OPTION_MD5;
+ size += TCPOLEN_MD5SIG_ALIGNED;
+ }
}
-#else
- *md5 = NULL;
#endif
if (likely(tp->rx_opt.tstamp_ok)) {
--
2.17.0.484.g0c8726318c-goog
3 years, 5 months
[Weekly meetings] MoM - 20th of August 2018
by Matthieu Baerts
Hello,
We just had our 19th meeting with Mat, (Intel OTC), Christoph (Apple)
and myself (Tessares).
Thanks again for this new good meeting!
Here are the minutes of the meeting:
Design:
- it's moving good (by Mat), now using the err queue
- Cloning skbs before putting in the receive queue still prevents
coalescing
- recvmsg code is now better organized for multiple subflows
- still need to review the code, clean it and wait for Peter to be
back (next week)
- next step: transmit path, sending ADD_ADDR
mptcp_net-next:
- no conflict but buids failure, ongoing work
- still need to add lockless subflows support
Next steps:
- same as last week.
Next meeting:
- We propose to have it on Thursday again, the 6th of September.
Usual time: 9am PDT - 16:00 UTC (9am PDT, 6pm CEST)
- Still open to everyone!
- https://annuel2.framapad.org/p/mptcp_upstreaming_20180906
Feel free to comment on these points and propose new ones for the next
meeting!
Talk to you in two weeks,
Matthieu
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
3 years, 8 months
[PATCH 0/2] Forward-ports from mptcp_trunk
by Christoph Paasch
Two forward-ports coming from mptcp_trunk.
Gregory Detal (1):
mptcp: correct refcnt for sk in tcp_v{4,6}_rcv
Matthieu Baerts (1):
mptcp:minisocks: fix refcnt when adding to backlog
include/net/mptcp.h | 2 ++
net/ipv4/tcp_ipv4.c | 2 +-
net/ipv4/tcp_minisocks.c | 2 +-
net/ipv6/tcp_ipv6.c | 2 +-
net/mptcp/mptcp_ctrl.c | 18 ++++++++++++++++--
5 files changed, 21 insertions(+), 5 deletions(-)
--
2.16.2
3 years, 9 months
[Weekly meetings] MoM - 20th of August 2018 (fwd)
by Mat Martineau
---------- Forwarded message ----------
From: Matthieu Baerts <matthieu.baerts(a)tessares.net>
Hello,
We just had our 18th meeting with Mat, (Intel OTC), Christoph (Apple),
Hoang (UCL) and myself (Tessares).
Thanks again for this new good meeting!
Here are the minutes of the meeting:
New commits on mptcp_trunk:
- surprising we didn't see that before
- (that could have impact when accepting a lot of new connections,
maybe we could act on the wrong sk)
- proposed to mptcp_net-next
LPC:
- not selected
- but without any reason (many people asked to participate)
- but anyway, we should continue working on the patches and send stuff.
- if possible, that could be nice to participate and meet Eric and
David to talk about the new design. (but they will certainly want to see
code)
Design:
- might be good at some points to send RFC for the design, now they
know what we are trying to do.
- but Mat is also close to have a version meeting the design we
agreed last time
Next steps:
- Mat: update prototype
- Peter: working on MP_JOIN stuff + later managing non-DSS options
- Ossama: more debugging on userspace code
- Christoph: bug fixes
- Matth: use recent kernel and maybe mptcp_net-next with our
test-suite. + update netlink code after that.
Next meeting:
- We propose to have it back on Thursday, the 30th of August. Usual
time: 9am PDT - 16:00 UTC (9am PDT, 6pm CEST)
- Still open to everyone!
- https://annuel2.framapad.org/p/mptcp_upstreaming_20180830
Feel free to comment on these points and propose new ones for the next
meeting!
Talk to you in two weeks,
Matthieu
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
3 years, 9 months
[Weekly meetings] MoM - 9th of August 2018
by Matthieu Baerts
Hello,
We just had our 17th meeting with Mat, Ossama, Peter (Intel OTC),
Christoph (Apple) and myself (Tessares).
Thanks again for this new good meeting!
Here are the minutes of the meeting:
New design by Mat:
- https://github.com/multipath-tcp/mptcp_net-next/wiki/Design
- what is at the beginning of the Design page is a bit old → please
check from "Metadata Queuing" → new design is mainly about managing
MPTCP options in TCP header
- Outgoing non-DSS options:
- addition from Mat: if it is urgent, we can still use
tcp_send_ack() right after having added items in this queue
- but there would be corner cases (more than one notification to
send, etc.)
- would add complexity: maintaining the queue, allocating stuff,
etc. and maybe not really needed
- easier to send them directly: allocate an sbk and send (at
least we manage TCP header option space for this packet)
- Outgoing DSS option:
- we hope David Miller will agree with Eric for his proposal but
we have one alternative just in case.
- What's next:
- Mat would like to update the prototype:
- to use the error queue (that should fits well with what is
there already)
- to use Eric's idea (should also be easy with the current
architecture)
- maybe manage later the non-DSS options (by Peter)
tcp-robust-ooo:
-
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=...
- do we need something like that for MPTCP (where we can have more
out-of-order by definition when using multiple subflows):
- we might be vulnerable
- but definitively might be good to do some fuzzing in the MPTCP
stack and detect bugs or see where are the expensive call in this case.
"MPTCP security for 5G" IETF draft:
- not related to MPTCP upstream
- (and doesn't seem related to MPTCP/TCP at all)
Testing recent kernel:
- Matth: work still in progress, switching to more recent kernels!
Linux Plumbers:
- no news nor feedback (but deadline is on the 15th of August)
Next steps:
- Mat: update prototype
- Peter: working on MP_JOIN stuff + later managing non-DSS options
- Christoph: MPTCPv1 (if OK) + bug fixes
- Ossama: more debugging on userspace code
- Matth: use recent kernel and mptcp_net-next with our test-suite. +
update netlink code after that. (+ remove the disclaimer at the end of
my emails on public ML!)
Next meeting:
- We propose to have it **on Monday** the 20th of August. Usual time
9am PDT - 16:00 UTC (9am PDT, 6pm CEST)
- Still open to everyone!
- https://annuel2.framapad.org/p/mptcp_upstreaming_20180820
Feel free to comment on these points and propose new ones for the next
meeting!
Talk to you next week,
Matthieu
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
3 years, 9 months