net/sched: Enable tc skb ext allocation on chain miss only when needed
Subsystems (4)
PATCH 1/1 net/sched: Enable tc skb ext allocation on chain miss only when needed
Tc skb extension is used to send miss info from tc to ovs datapath module, and is currently always allocated even if it will not be used by ovs datapath (as it depends on a requested feature).
Export the static key which is used by openvswitch module to guard this code path as well, so it will be skipped if ovs datapath doesn't need it. Enable this code path once ovs datapath needs it.
--- include/net/pkt_cls.h | 11 ++++++++++ net/openvswitch/datapath.c | 18 +++++++++------- net/openvswitch/datapath.h | 2 -- net/openvswitch/flow.c | 3 ++- net/sched/cls_api.c | 43 ++++++++++++++++++++++++++------------ 5 files changed, 54 insertions(+), 23 deletions(-)
include/net/pkt_cls.h +11 -0
@@ -1028,4 +1028,15 @@ struct tc_fifo_qopt_offload { }; }; +#ifdef CONFIG_NET_CLS_ACT +DECLARE_STATIC_KEY_FALSE (tc_skb_ext_tc_ovs); +void tc_skb_ext_tc_ovs_enable (void ); +void tc_skb_ext_tc_ovs_disable (void ); +#define tc_skb_ext_tc_ovs_enabled () static_branch_unlikely(&tc_skb_ext_tc_ovs) +#else /* CONFIG_NET_CLS_ACT */ +static inline void tc_skb_ext_tc_ovs_enable (void ) { } +static inline void tc_skb_ext_tc_ovs_disable (void ) { } +#define tc_skb_ext_tc_ovs_enabled () false +#endif +#endif
net/openvswitch/datapath.c +11 -7
@@ -37,6 +37,7 @@#include <net/genetlink.h> #include <net/net_namespace.h> #include <net/netns/generic.h> +#include <net/pkt_cls.h> #include "datapath.h" #include "flow.h"
@@ -1601,8 +1602,6 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb, dp->user_features =0 ; } -DEFINE_STATIC_KEY_FALSE (tc_recirc_sharing_support); -static int ovs_dp_set_upcall_portids (struct datapath *dp,const struct nlattr *ids) {
@@ -1657,7 +1656,7 @@ u32 ovs_dp_get_upcall_portid(const struct datapath *dp, uint32_t cpu_id)static int ovs_dp_change (struct datapath *dp,struct nlattr *a[]) { -u32 user_features =0 ; +u32 user_features =0 , old_features = dp->user_features;int err;if (a[OVS_DP_ATTR_USER_FEATURES ]) {
@@ -1696,10 +1695,12 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])return err; } -if (dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) -static_branch_enable (&tc_recirc_sharing_support); -else -static_branch_disable (&tc_recirc_sharing_support); +if ((dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) && + !(old_features &OVS_DP_F_TC_RECIRC_SHARING )) +tc_skb_ext_tc_ovs_enable (); +else if (!(dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) && + (old_features &OVS_DP_F_TC_RECIRC_SHARING )) +tc_skb_ext_tc_ovs_disable ();return 0 ; }
@@ -1839,6 +1840,9 @@ static void __dp_destroy(struct datapath *dp)struct flow_table *table = &dp->table;int i; +if (dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) +tc_skb_ext_tc_ovs_disable (); +for (i =0 ; i <DP_VPORT_HASH_BUCKETS ; i++) {struct vport *vport;struct hlist_node *n;
net/openvswitch/datapath.h +0 -2
@@ -253,8 +253,6 @@ static inline struct datapath *get_dp(struct net *net, int dp_ifindex)extern struct notifier_block ovs_dp_device_notifier;extern struct genl_family dp_vport_genl_family; -DECLARE_STATIC_KEY_FALSE (tc_recirc_sharing_support); -void ovs_dp_process_packet (struct sk_buff *skb,struct sw_flow_key *key);void ovs_dp_detach_port (struct vport *); int ovs_dp_upcall(struct datapath *, struct sk_buff *,
net/openvswitch/flow.c +2 -1
@@ -34,6 +34,7 @@#include <net/mpls.h> #include <net/ndisc.h> #include <net/nsh.h> +#include <net/pkt_cls.h> #include <net/netfilter/nf_conntrack_zones.h> #include "conntrack.h"
@@ -895,7 +896,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, key->mac_proto = res;#if IS_ENABLED (CONFIG_NET_TC_SKB_EXT ) -if (static_branch_unlikely (&tc_recirc_sharing_support)) { +if (tc_skb_ext_tc_ovs_enabled ()) { tc_ext =skb_ext_find (skb,TC_SKB_EXT ); key->recirc_id = tc_ext ? tc_ext->chain :0 ;OVS_CB (skb)->mru = tc_ext ? tc_ext->mru :0 ;
net/sched/cls_api.c +30 -13
55 lines not on this page · raw message
Signature · 1 line
2.30.1
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Paul,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Paul-Blakey/net-sched-Enable-tc-skb-ext-allocation-on-chain-miss-only-when-needed/20220130-203224 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git ff58831fa02deb42fd731f830d8d9ec545573c7c config: csky-randconfig-r026-20220130 (https://download.01.org/0day-ci/archive/20220130/202201302207.vQWCwrx8-lkp(a)intel.com/config) compiler: csky-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/0bc6313c4ce18444ed88c99b19d0cb1682772988
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Paul-Blakey/net-sched-Enable-tc-skb-ext-allocation-on-chain-miss-only-when-needed/20220130-203224 git checkout 0bc6313c4ce18444ed88c99b19d0cb1682772988
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=csky SHELL=/bin/bash net/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> net/sched/cls_api.c:55:6: error: redefinition of 'tc_skb_ext_tc_ovs_enable'
55 | void tc_skb_ext_tc_ovs_enable(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from net/sched/cls_api.c:29:
include/net/pkt_cls.h:1037:20: note: previous definition of 'tc_skb_ext_tc_ovs_enable' with type 'void(void)'
1037 | static inline void tc_skb_ext_tc_ovs_enable(void) { }
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> net/sched/cls_api.c:61:6: error: redefinition of 'tc_skb_ext_tc_ovs_disable'
61 | void tc_skb_ext_tc_ovs_disable(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from net/sched/cls_api.c:29:
include/net/pkt_cls.h:1038:20: note: previous definition of 'tc_skb_ext_tc_ovs_disable' with type 'void(void)'
1038 | static inline void tc_skb_ext_tc_ovs_disable(void) { }
| ^~~~~~~~~~~~~~~~~~~~~~~~~vim +/tc_skb_ext_tc_ovs_enable +55 net/sched/cls_api.c
54
> 55 void tc_skb_ext_tc_ovs_enable(void)
56 {
57 static_branch_inc(&tc_skb_ext_tc_ovs);
58 }
59 EXPORT_SYMBOL(tc_skb_ext_tc_ovs_enable);
60
> 61 void tc_skb_ext_tc_ovs_disable(void)
62 {
63 static_branch_dec(&tc_skb_ext_tc_ovs);
64 }
65 EXPORT_SYMBOL(tc_skb_ext_tc_ovs_disable);
66 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Paul,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Paul-Blakey/net-sched-Enable-tc-skb-ext-allocation-on-chain-miss-only-when-needed/20220130-203224 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git ff58831fa02deb42fd731f830d8d9ec545573c7c config: x86_64-randconfig-a016 (https://download.01.org/0day-ci/archive/20220131/202201310016.Z4iqHnpx-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f1c18acb07aa40f42b87b70462a6d1ab77a4825c)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/0bc6313c4ce18444ed88c99b19d0cb1682772988
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Paul-Blakey/net-sched-Enable-tc-skb-ext-allocation-on-chain-miss-only-when-needed/20220130-203224 git checkout 0bc6313c4ce18444ed88c99b19d0cb1682772988
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> net/sched/cls_api.c:55:6: error: redefinition of 'tc_skb_ext_tc_ovs_enable'
void tc_skb_ext_tc_ovs_enable(void)
^
include/net/pkt_cls.h:1037:20: note: previous definition is here
static inline void tc_skb_ext_tc_ovs_enable(void) { }
^
>> net/sched/cls_api.c:61:6: error: redefinition of 'tc_skb_ext_tc_ovs_disable'
void tc_skb_ext_tc_ovs_disable(void)
^
include/net/pkt_cls.h:1038:20: note: previous definition is here
static inline void tc_skb_ext_tc_ovs_disable(void) { }
^2 errors generated.
vim +/tc_skb_ext_tc_ovs_enable +55 net/sched/cls_api.c
54
> 55 void tc_skb_ext_tc_ovs_enable(void)
56 {
57 static_branch_inc(&tc_skb_ext_tc_ovs);
58 }
59 EXPORT_SYMBOL(tc_skb_ext_tc_ovs_enable);
60
> 61 void tc_skb_ext_tc_ovs_disable(void)
62 {
63 static_branch_dec(&tc_skb_ext_tc_ovs);
64 }
65 EXPORT_SYMBOL(tc_skb_ext_tc_ovs_disable);
66 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org