From patchwork Tue Apr 24 15:07:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 903567 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X1tZGnf7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Vmst0rx7z9ryr for ; Wed, 25 Apr 2018 01:08:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751251AbeDXPH7 (ORCPT ); Tue, 24 Apr 2018 11:07:59 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35283 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbeDXPH6 (ORCPT ); Tue, 24 Apr 2018 11:07:58 -0400 Received: by mail-pf0-f193.google.com with SMTP id j5so12503269pfh.2 for ; Tue, 24 Apr 2018 08:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gqLro8svnHGG4RPA61DDC0QBdkT/s87hXKjzKTTChUc=; b=X1tZGnf7Qf0iiCh1XTcMbkI0c/cYEWW5HFTnzGA4RWnwCgInLE4+StCmjkN5ljq2EE +yHtNWPXG1iMuZgAziKK+hMOePexq0Ru+5xXNdlKqBL+gy8wnSVplX2OHfLQ5pTG3VRh 5Txs9Dq/ybWLszhKxocui3vhAVHncDbLgFKROEhO0WmbeRwJ1oKkHyBppv/rPrXCcYhd tumGiA72rYO7K7gYlaW92WzXW5ucnKhc6TOYpqikjoacsL+P1aVEJXeoXBxwD3qjTKFx 4EO82C3+/eoAoOGWlVyXGqZd6ev3F0gQh7IhrbsRAtmw+AEGpIYILK77rJpqa28+6xd8 cr4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gqLro8svnHGG4RPA61DDC0QBdkT/s87hXKjzKTTChUc=; b=UntZt9mw5tk/t39d82vN/q2FE4G6XUE9D9SmaPXh4Py9Zdsah3offBh08tef+mJdcd NiJhAnsiFhIUeKXhmJKVb0vDu2NAUJFzPeaVJDVxxrB1Mvjqtbc21c0xk0bv6//GJ/nB CvpAfYf7+99cKlDsfMlYtJp6q7URAixZbowmF0RmWYB+a0ymli3TvfBalbbAWQ1QZkbY umKIybP6UddB2dQc1dLj+mPlxL282R1P2R9joIKeSY1U8VKmpyJs+XJXEuN191d3aITR x9XDRpzKtqSFY4uVlvBHkjzC6X8nUTBdSXrECmrtE1p3rsyWf6SjhSa/rtimSj6+03Na tTuA== X-Gm-Message-State: ALQs6tD61jqECbzADI9/BWVLj2bswIfX7UkS2BROecKn9I8kmDczXaJR ulcFKEpPCDBQBG6NZINRmpk= X-Google-Smtp-Source: AIpwx49m4sDg2N/gnRlrVrszTe12A8mizM/TOxd/KGTXwA+GPch8kG3xbWIzCbEXRaFTf9mzVv+xtg== X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr25694318pls.192.1524582477551; Tue, 24 Apr 2018 08:07:57 -0700 (PDT) Received: from li1588-6.members.linode.com (li1588-6.members.linode.com. [139.162.104.6]) by smtp.gmail.com with ESMTPSA id i186sm13503347pge.40.2018.04.24.08.07.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 08:07:56 -0700 (PDT) From: Yafang Shao To: eric.dumazet@gmail.com, davem@davemloft.net Cc: netdev@vger.kernel.org, Yafang Shao Subject: [PATCH v2 net-next] Revert "net: init sk_cookie for inet socket" Date: Tue, 24 Apr 2018 23:07:45 +0800 Message-Id: <1524582465-11055-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This reverts commit ("net: init sk_cookie for inet socket") Per discussion with Eric, when update sock_net(sk)->cookie_gen, the whole cache cache line will be invalidated, as this cache line is shared with all cpus, that may cause great performace hit. Bellow is the data form Eric. "Performance is reduced from ~5 Mpps to ~3.8 Mpps with 16 RX queues on my host" when running synflood test. Have to revert it to prevent from cache line false sharing. Signed-off-by: Yafang Shao Reviewed-by: Eric Dumazet --- include/linux/sock_diag.h | 9 --------- net/ipv4/tcp_input.c | 8 +------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h index 5c916e6..15fe980 100644 --- a/include/linux/sock_diag.h +++ b/include/linux/sock_diag.h @@ -25,15 +25,6 @@ struct sock_diag_handler { void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)); void sock_diag_unregister_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)); -static inline -void sock_init_cookie(struct sock *sk) -{ - u64 res; - - res = atomic64_inc_return(&sock_net(sk)->cookie_gen); - atomic64_set(&sk->sk_cookie, res); -} - u64 sock_gen_cookie(struct sock *sk); int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie); void sock_diag_save_cookie(struct sock *sk, __u32 *cookie); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 17b7858..5a17cfc 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -78,7 +78,6 @@ #include #include #include -#include int sysctl_tcp_max_orphans __read_mostly = NR_FILE; @@ -6191,15 +6190,10 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops, #if IS_ENABLED(CONFIG_IPV6) ireq->pktopts = NULL; #endif + atomic64_set(&ireq->ir_cookie, 0); ireq->ireq_state = TCP_NEW_SYN_RECV; write_pnet(&ireq->ireq_net, sock_net(sk_listener)); ireq->ireq_family = sk_listener->sk_family; - - BUILD_BUG_ON(offsetof(struct inet_request_sock, ir_cookie) != - offsetof(struct sock, sk_cookie)); - BUILD_BUG_ON(offsetof(struct inet_request_sock, ireq_net) != - offsetof(struct sock, sk_net)); - sock_init_cookie((struct sock *)ireq); } return req;