From mboxrd@z Thu Jan 1 00:00:00 1970 From: Soheil Hassas Yeganeh Subject: [PATCH net-next 1/2] ip: do not set RFS core on error queue reads Date: Wed, 3 Jan 2018 21:47:10 -0500 Message-ID: <20180104024711.257600-1-soheil.kdev@gmail.com> Cc: pjt@google.com, ycheng@google.com, Soheil Hassas Yeganeh , Willem de Bruijn , Eric Dumazet , Neal Cardwell To: davem@davemloft.net, netdev@vger.kernel.org Return-path: Received: from mail-yw0-f193.google.com ([209.85.161.193]:45778 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbeADCsG (ORCPT ); Wed, 3 Jan 2018 21:48:06 -0500 Received: by mail-yw0-f193.google.com with SMTP id y187so122702ywd.12 for ; Wed, 03 Jan 2018 18:48:06 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: From: Soheil Hassas Yeganeh We should only record RPS on normal reads and writes. In single threaded processes, all calls record the same state. In multi-threaded processes where a separate thread processes errors, the RFS table mispredicts. Note that, when CONFIG_RPS is disabled, sock_rps_record_flow is a noop and no branch is added as a result of this patch. Signed-off-by: Soheil Hassas Yeganeh Signed-off-by: Willem de Bruijn Signed-off-by: Eric Dumazet Signed-off-by: Neal Cardwell --- net/ipv4/af_inet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index bab98a4fedad..54cccdd8b1e3 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -790,7 +790,8 @@ int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int addr_len = 0; int err; - sock_rps_record_flow(sk); + if (likely(!(flags & MSG_ERRQUEUE))) + sock_rps_record_flow(sk); err = sk->sk_prot->recvmsg(sk, msg, size, flags & MSG_DONTWAIT, flags & ~MSG_DONTWAIT, &addr_len); -- 2.16.0.rc0.223.g4a4ac83678-goog