From patchwork Sat Apr 27 22:48:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 1092107 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=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="Fcxb5c+D"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44s5hC4dKWz9s7T for ; Sun, 28 Apr 2019 08:49:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbfD0Ws5 (ORCPT ); Sat, 27 Apr 2019 18:48:57 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33649 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfD0Ws5 (ORCPT ); Sat, 27 Apr 2019 18:48:57 -0400 Received: by mail-qt1-f193.google.com with SMTP id g7so8206145qtc.0 for ; Sat, 27 Apr 2019 15:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sEvvEWysgMaJcqFMXU/CvMB5A+a51FkORh8kgk4hLO8=; b=Fcxb5c+Dux+CPUEaGQixgoWAbVtJ3lWYO1ObsHdoVFmXV9qpvxjVbWt5fBXzNOHZoN caLanUs8ox3Ve1ppp1ph1AzsdFircn6Lhqhdjj7Zljldl/eW2WIdu9RtJ05VEIRkSVbJ xvcqdtJL1ZqTBkztzoajjU31eOTF7p/j1U/xw/Sz5WqsEg4CiXZXyHdH9bA/Xa6NlGiI V/nz2lz+aLWch+A1sw4kJuN4ncu7G22lCMHX4PdO4jAoAhsPP8iZMclPdHnC8NqeJPxu Uq0WQgg62Chf7vsGV94nHJ5BTI6mh5beqj246NNJxHPD6Fslwspp2saoG7orIbdfoeJ0 aIaA== 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:mime-version :content-transfer-encoding; bh=sEvvEWysgMaJcqFMXU/CvMB5A+a51FkORh8kgk4hLO8=; b=KpUyF543oUjUiVnOFXYR+A39WXNrsvFkLfvrcJ9h0VhNIEKrvA9w1t0wIL8aWTRC12 PzHzcEY41zA7p/5ZhXJOp6iSd6IQn+RYLxROkoE6jvzBsv+vpFt1AoKHFsSTQEsUNfp9 EN87JE1qW0eRYiLeuD3bEJ/B5atqX5KylmGLUTplTRaEiVzc0kvDaR+VCAErpmtMpL8A yxSsCPGrW2nd5d/Y3ElXifZY/BzvTCyfGnWUfKtIgyLjOEfz8UlwkGzfIlK0GHouA7Lk VkzZ3UOylJcO124XgXATZAqMANmpoSIRDwnMoRQVxh1MGfIc5YBgmgSC0DqfRgXj25jp 7iwg== X-Gm-Message-State: APjAAAUmUPXu5Q7rwh40ssBEhczdallxGLcHuTbuJiDxH1O5OJjwiGg8 HU5JWfSdw5U8goU7/D++S/wqBA== X-Google-Smtp-Source: APXvYqzS3QN26NVjO9guUN00XaegDOuhMBWXzTNfgV1sT9+NZT1xRbxV1dajlv2jNDNBCmDpxCPOgQ== X-Received: by 2002:ad4:5382:: with SMTP id i2mr13418672qvv.233.1556405336164; Sat, 27 Apr 2019 15:48:56 -0700 (PDT) Received: from jkicinski-Precision-T1700.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id t2sm17895429qkd.57.2019.04.27.15.48.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Apr 2019 15:48:55 -0700 (PDT) From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, alexei.starovoitov@gmail.com, oss-drivers@netronome.com, Jakub Kicinski , Simon Horman Subject: [RFC net-next] net/tcp: use deferred jump label for TCP acked data hook Date: Sat, 27 Apr 2019 15:48:43 -0700 Message-Id: <20190427224843.2952-1-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org User space can flip the clean_acked_data_enabled static branch on and off with TLS offload when CONFIG_TLS_DEVICE is enabled. jump_label.h suggests we use the delayed version in this case. Deferred branches now also don't take the branch mutex on decrement, so we avoid potential locking issues. Signed-off-by: Jakub Kicinski Reviewed-by: Simon Horman --- Sending as an RFC, because the pre-requisite jump label patches are in PeterZ's tree. Could this change be considered for applying during the next merge window? include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 16 +++++++++++----- net/tls/tls_device.c | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 7cf1181630a3..985aa5db570c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2198,7 +2198,7 @@ extern struct static_key_false tcp_have_smc; void clean_acked_data_enable(struct inet_connection_sock *icsk, void (*cad)(struct sock *sk, u32 ack_seq)); void clean_acked_data_disable(struct inet_connection_sock *icsk); - +void clean_acked_data_flush(void); #endif #endif /* _TCP_H */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 97671bff597a..8d81eba9f3fc 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -77,7 +77,7 @@ #include #include #include -#include +#include #include int sysctl_tcp_max_orphans __read_mostly = NR_FILE; @@ -113,22 +113,28 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE; #define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ #if IS_ENABLED(CONFIG_TLS_DEVICE) -static DEFINE_STATIC_KEY_FALSE(clean_acked_data_enabled); +static DEFINE_STATIC_KEY_DEFERRED_FALSE(clean_acked_data_enabled, HZ); void clean_acked_data_enable(struct inet_connection_sock *icsk, void (*cad)(struct sock *sk, u32 ack_seq)) { icsk->icsk_clean_acked = cad; - static_branch_inc(&clean_acked_data_enabled); + static_branch_inc(&clean_acked_data_enabled.key); } EXPORT_SYMBOL_GPL(clean_acked_data_enable); void clean_acked_data_disable(struct inet_connection_sock *icsk) { - static_branch_dec(&clean_acked_data_enabled); + static_branch_slow_dec_deferred(&clean_acked_data_enabled); icsk->icsk_clean_acked = NULL; } EXPORT_SYMBOL_GPL(clean_acked_data_disable); + +void clean_acked_data_flush(void) +{ + static_key_deferred_flush(&clean_acked_data_enabled); +} +EXPORT_SYMBOL_GPL(clean_acked_data_flush); #endif static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb, @@ -3598,7 +3604,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) icsk->icsk_retransmits = 0; #if IS_ENABLED(CONFIG_TLS_DEVICE) - if (static_branch_unlikely(&clean_acked_data_enabled)) + if (static_branch_unlikely(&clean_acked_data_enabled.key)) if (icsk->icsk_clean_acked) icsk->icsk_clean_acked(sk, ack); #endif diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index e225c81e6b35..ad1580ac097a 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -1036,4 +1036,5 @@ void __exit tls_device_cleanup(void) { unregister_netdevice_notifier(&tls_dev_notifier); flush_work(&tls_device_gc_work); + clean_acked_data_flush(); }