From patchwork Thu Jun 13 20:24:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45PwF85xnPz9sNT; Fri, 14 Jun 2019 06:24:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hbWGW-0002o9-Vz; Thu, 13 Jun 2019 20:24:08 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hbWGU-0002n4-Ku for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 20:24:06 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbWGU-0001hL-AC for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 20:24:06 +0000 Received: by mail-wm1-f72.google.com with SMTP id v15so77270wmh.1 for ; Thu, 13 Jun 2019 13:24:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=suJcyJxsFfU0K0yPoDRvAP7Uf9sQa8ce16pTjgi8Bac=; b=BigDLtK2hZ5hsfO1Aea46UIYUMUQXCq820qghVJryCj05Ijx1nGIGyBTX+C06IphK8 VZeKKTgeiSey5jUqfbZndX4/iAwXnm0fBc/v90Ea1WPIyYKpH1r1lIZOF2jGLN5KRJ4v wNBHCygh+J0f5NHYAaM3OrtHpey7H5dnhd3uprQ3LDd6yNTC+6LW69zTzD6zRvVMuU6Y lD5ngiMD2UqEHocWe8Z5gH/L/KYTwBNXkAs1MFtPmoKijNmOWbbYEIluHA7wg62rfjtV v+51ZdRx5WfvJ0PkT8yboL7Y2Kbx5r0jbjMuBXzn+FBU3YJhqf/0U1jgK/vUNMfgLWeX Fncw== X-Gm-Message-State: APjAAAXHoP+cTQJOC0h3HILadMx/qzfj041Cbc+XrXL1Ayr6/ct4KaIC b3fTozdX2BL2QTBrF2lh+K+DtcMJ/hcsHT6b6JWyvHpr1G3WM/fK/qT39jXzUtSahQsn0T+2puz gcxCaLuwHjRXPW6KZ0uaTp+srs5xNPQC3ScSsekmIEg== X-Received: by 2002:a1c:9696:: with SMTP id y144mr5044439wmd.73.1560457445856; Thu, 13 Jun 2019 13:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBxlsBM+OPWmfPqdAMxLZdX9Ha5pt/MU+ISo3rv0m5uwafD8JLbfBdg3aEjIZSWDdpdVhlSQ== X-Received: by 2002:a1c:9696:: with SMTP id y144mr5044427wmd.73.1560457445650; Thu, 13 Jun 2019 13:24:05 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id l124sm254051wmf.36.2019.06.13.13.24.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 13:24:05 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 2/3] net: convert rps_needed and rfs_needed to new static Date: Thu, 13 Jun 2019 21:24:00 +0100 Message-Id: <20190613202401.1628-3-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613202401.1628-1-ioanna-maria.alifieraki@canonical.com> References: <20190613202401.1628-1-ioanna-maria.alifieraki@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Eric Dumazet BugLink: https://bugs.launchpad.net/bugs/1831254 We prefer static_branch_unlikely() over static_key_false() these days. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Acked-by: Willem de Bruijn Signed-off-by: David S. Miller (backported from commit dc05360fee660a9dbe59824b3f7896534210432b) [hunk 7 in original commit modifies netif_receive_skb_list_internal function which is not present. So remove this hunk.] Signed-off-by: Ioanna Alifieraki --- drivers/net/tun.c | 2 +- include/linux/netdevice.h | 4 ++-- include/net/sock.h | 2 +- net/core/dev.c | 8 ++++---- net/core/net-sysfs.c | 4 ++-- net/core/sysctl_net_core.c | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 694a27da7278..1151f7511c1c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1039,7 +1039,7 @@ static int tun_net_close(struct net_device *dev) static void tun_automq_xmit(struct tun_struct *tun, struct sk_buff *skb) { #ifdef CONFIG_RPS - if (tun->numqueues == 1 && static_key_false(&rps_needed)) { + if (tun->numqueues == 1 && static_branch_unlikely(&rps_needed)) { /* Select queue was not called for the skbuff, so we extract the * RPS hash and save it into the flow_table here. */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3045a5cee0d8..1e652e4f08e6 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -194,8 +194,8 @@ struct net_device_stats { #ifdef CONFIG_RPS #include -extern struct static_key rps_needed; -extern struct static_key rfs_needed; +extern struct static_key_false rps_needed; +extern struct static_key_false rfs_needed; #endif struct neighbour; diff --git a/include/net/sock.h b/include/net/sock.h index 762069bb0d8c..6f550817e5d5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -937,7 +937,7 @@ static inline void sock_rps_record_flow_hash(__u32 hash) static inline void sock_rps_record_flow(const struct sock *sk) { #ifdef CONFIG_RPS - if (static_key_false(&rfs_needed)) { + if (static_branch_unlikely(&rfs_needed)) { /* Reading sk->sk_rxhash might incur an expensive cache line * miss. * diff --git a/net/core/dev.c b/net/core/dev.c index bf669e77f9f3..99f62b724d6e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3702,9 +3702,9 @@ EXPORT_SYMBOL(rps_sock_flow_table); u32 rps_cpu_mask __read_mostly; EXPORT_SYMBOL(rps_cpu_mask); -struct static_key rps_needed __read_mostly; +struct static_key_false rps_needed __read_mostly; EXPORT_SYMBOL(rps_needed); -struct static_key rfs_needed __read_mostly; +struct static_key_false rfs_needed __read_mostly; EXPORT_SYMBOL(rfs_needed); static struct rps_dev_flow * @@ -4216,7 +4216,7 @@ static int netif_rx_internal(struct sk_buff *skb) } #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu; @@ -4775,7 +4775,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb) rcu_read_lock(); #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu = get_rps_cpu(skb->dev, skb, &rflow); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 151e6cd47972..51a2169605f1 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -759,9 +759,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, rcu_assign_pointer(queue->rps_map, map); if (map) - static_key_slow_inc(&rps_needed); + static_branch_inc(&rps_needed); if (old_map) - static_key_slow_dec(&rps_needed); + static_branch_dec(&rps_needed); mutex_unlock(&rps_map_mutex); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index b1a2c5e38530..4f9a939c51e5 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -84,12 +84,12 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, if (sock_table != orig_sock_table) { rcu_assign_pointer(rps_sock_flow_table, sock_table); if (sock_table) { - static_key_slow_inc(&rps_needed); - static_key_slow_inc(&rfs_needed); + static_branch_inc(&rps_needed); + static_branch_inc(&rfs_needed); } if (orig_sock_table) { - static_key_slow_dec(&rps_needed); - static_key_slow_dec(&rfs_needed); + static_branch_dec(&rps_needed); + static_branch_dec(&rfs_needed); synchronize_rcu(); vfree(orig_sock_table); }