diff mbox series

[net-next,v4,01/10] netdevice: priv_flags extend to 64bit

Message ID 20210413031523.73507-2-xuanzhuo@linux.alibaba.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series virtio-net support xdp socket zero copy xmit | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 5 maintainers not CCed: yhs@fb.com kpsingh@kernel.org andrii@kernel.org kafai@fb.com songliubraving@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 6685 this patch: 6686
netdev/kdoc fail Errors and warnings before: 0 this patch: 64
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 156 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 6898 this patch: 6899
netdev/header_inline success Link

Commit Message

Xuan Zhuo April 13, 2021, 3:15 a.m. UTC
The size of priv_flags is 32 bits, and the number of flags currently
available has reached 32. It is time to expand the size of priv_flags to
64 bits.

Here the priv_flags is modified to 8 bytes, but the size of struct
net_device has not changed, it is still 2176 bytes. It is because _tx is
aligned based on the cache line. But there is a 4-byte hole left here.

Since the fields before and after priv_flags are read mostly, I did not
adjust the order of the fields here.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 include/linux/netdevice.h | 136 ++++++++++++++++++++------------------
 1 file changed, 71 insertions(+), 65 deletions(-)

Comments

kernel test robot April 13, 2021, 5:19 a.m. UTC | #1
Hi Xuan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xuan-Zhuo/virtio-net-support-xdp-socket-zero-copy-xmit/20210413-111831
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2
config: um-allmodconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/32403bd72dd27e9d773cfce22af2e46aeec0a3b1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xuan-Zhuo/virtio-net-support-xdp-socket-zero-copy-xmit/20210413-111831
        git checkout 32403bd72dd27e9d773cfce22af2e46aeec0a3b1
        # save the attached .config to linux build tree
        make W=1 ARCH=um 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   cc1: warning: arch/um/include/uapi: No such file or directory [-Wmissing-include-dirs]
   net/8021q/vlanproc.c: In function 'vlandev_seq_show':
>> net/8021q/vlanproc.c:255:56: warning: format '%hx' expects argument of type 'int', but argument 6 has type 'netdev_priv_flags_t' {aka 'long long unsigned int'} [-Wformat=]
     255 |      "%s  VID: %d  REORDER_HDR: %i  dev->priv_flags: %hx\n",
         |                                                      ~~^
         |                                                        |
         |                                                        int
         |                                                      %llx
     256 |      vlandev->name, vlan->vlan_id,
     257 |      (int)(vlan->flags & 1), vlandev->priv_flags);
         |                              ~~~~~~~~~~~~~~~~~~~        
         |                                     |
         |                                     netdev_priv_flags_t {aka long long unsigned int}


vim +255 net/8021q/vlanproc.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  240  
^1da177e4c3f41 Linus Torvalds  2005-04-16  241  static int vlandev_seq_show(struct seq_file *seq, void *offset)
^1da177e4c3f41 Linus Torvalds  2005-04-16  242  {
^1da177e4c3f41 Linus Torvalds  2005-04-16  243  	struct net_device *vlandev = (struct net_device *) seq->private;
7da82c06ded105 Jiri Pirko      2011-12-08  244  	const struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
28172739f0a276 Eric Dumazet    2010-07-07  245  	struct rtnl_link_stats64 temp;
be1f3c2c027cc5 Ben Hutchings   2010-06-08  246  	const struct rtnl_link_stats64 *stats;
be1f3c2c027cc5 Ben Hutchings   2010-06-08  247  	static const char fmt64[] = "%30s %12llu\n";
^1da177e4c3f41 Linus Torvalds  2005-04-16  248  	int i;
^1da177e4c3f41 Linus Torvalds  2005-04-16  249  
26a25239d7a660 Joonwoo Park    2008-07-08  250  	if (!is_vlan_dev(vlandev))
^1da177e4c3f41 Linus Torvalds  2005-04-16  251  		return 0;
^1da177e4c3f41 Linus Torvalds  2005-04-16  252  
28172739f0a276 Eric Dumazet    2010-07-07  253  	stats = dev_get_stats(vlandev, &temp);
2029cc2c84fb11 Patrick McHardy 2008-01-21  254  	seq_printf(seq,
2029cc2c84fb11 Patrick McHardy 2008-01-21 @255  		   "%s  VID: %d	 REORDER_HDR: %i  dev->priv_flags: %hx\n",

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot April 13, 2021, 6:30 a.m. UTC | #2
Hi Xuan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xuan-Zhuo/virtio-net-support-xdp-socket-zero-copy-xmit/20210413-111831
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2
config: x86_64-randconfig-a014-20210413 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9829f5e6b1bca9b61efc629770d28bb9014dec45)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/32403bd72dd27e9d773cfce22af2e46aeec0a3b1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xuan-Zhuo/virtio-net-support-xdp-socket-zero-copy-xmit/20210413-111831
        git checkout 32403bd72dd27e9d773cfce22af2e46aeec0a3b1
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/8021q/vlanproc.c:257:30: warning: format specifies type 'unsigned short' but the argument has type 'netdev_priv_flags_t' (aka 'unsigned long long') [-Wformat]
                      (int)(vlan->flags & 1), vlandev->priv_flags);
                                              ^~~~~~~~~~~~~~~~~~~
   net/8021q/vlanproc.c:284:22: warning: format specifies type 'unsigned short' but the argument has type 'int' [-Wformat]
                                      mp->priority, ((mp->vlan_qos >> 13) & 0x7));
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2 warnings generated.


vim +257 net/8021q/vlanproc.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  240  
^1da177e4c3f41 Linus Torvalds  2005-04-16  241  static int vlandev_seq_show(struct seq_file *seq, void *offset)
^1da177e4c3f41 Linus Torvalds  2005-04-16  242  {
^1da177e4c3f41 Linus Torvalds  2005-04-16  243  	struct net_device *vlandev = (struct net_device *) seq->private;
7da82c06ded105 Jiri Pirko      2011-12-08  244  	const struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
28172739f0a276 Eric Dumazet    2010-07-07  245  	struct rtnl_link_stats64 temp;
be1f3c2c027cc5 Ben Hutchings   2010-06-08  246  	const struct rtnl_link_stats64 *stats;
be1f3c2c027cc5 Ben Hutchings   2010-06-08  247  	static const char fmt64[] = "%30s %12llu\n";
^1da177e4c3f41 Linus Torvalds  2005-04-16  248  	int i;
^1da177e4c3f41 Linus Torvalds  2005-04-16  249  
26a25239d7a660 Joonwoo Park    2008-07-08  250  	if (!is_vlan_dev(vlandev))
^1da177e4c3f41 Linus Torvalds  2005-04-16  251  		return 0;
^1da177e4c3f41 Linus Torvalds  2005-04-16  252  
28172739f0a276 Eric Dumazet    2010-07-07  253  	stats = dev_get_stats(vlandev, &temp);
2029cc2c84fb11 Patrick McHardy 2008-01-21  254  	seq_printf(seq,
2029cc2c84fb11 Patrick McHardy 2008-01-21  255  		   "%s  VID: %d	 REORDER_HDR: %i  dev->priv_flags: %hx\n",
7da82c06ded105 Jiri Pirko      2011-12-08  256  		   vlandev->name, vlan->vlan_id,
7da82c06ded105 Jiri Pirko      2011-12-08 @257  		   (int)(vlan->flags & 1), vlandev->priv_flags);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Jakub Kicinski April 13, 2021, 6:26 p.m. UTC | #3
On Tue, 13 Apr 2021 11:15:14 +0800 Xuan Zhuo wrote:
> @@ -1598,72 +1600,75 @@ struct net_device_ops {
>   *	skb_headlen(skb) == 0 (data starts from frag0)
>   */
>  enum netdev_priv_flags {
> -	IFF_802_1Q_VLAN			= 1<<0,
> +	IFF_802_1Q_VLAN_BIT,

This breaks kdoc, now the kdoc documents values which don't exist 
in the enum.
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f57b70fc251f..86e4bd08c2f1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1549,6 +1549,8 @@  struct net_device_ops {
                                                          struct net_device_path *path);
 };
 
+typedef u64 netdev_priv_flags_t;
+
 /**
  * enum netdev_priv_flags - &struct net_device priv_flags
  *
@@ -1598,72 +1600,75 @@  struct net_device_ops {
  *	skb_headlen(skb) == 0 (data starts from frag0)
  */
 enum netdev_priv_flags {
-	IFF_802_1Q_VLAN			= 1<<0,
-	IFF_EBRIDGE			= 1<<1,
-	IFF_BONDING			= 1<<2,
-	IFF_ISATAP			= 1<<3,
-	IFF_WAN_HDLC			= 1<<4,
-	IFF_XMIT_DST_RELEASE		= 1<<5,
-	IFF_DONT_BRIDGE			= 1<<6,
-	IFF_DISABLE_NETPOLL		= 1<<7,
-	IFF_MACVLAN_PORT		= 1<<8,
-	IFF_BRIDGE_PORT			= 1<<9,
-	IFF_OVS_DATAPATH		= 1<<10,
-	IFF_TX_SKB_SHARING		= 1<<11,
-	IFF_UNICAST_FLT			= 1<<12,
-	IFF_TEAM_PORT			= 1<<13,
-	IFF_SUPP_NOFCS			= 1<<14,
-	IFF_LIVE_ADDR_CHANGE		= 1<<15,
-	IFF_MACVLAN			= 1<<16,
-	IFF_XMIT_DST_RELEASE_PERM	= 1<<17,
-	IFF_L3MDEV_MASTER		= 1<<18,
-	IFF_NO_QUEUE			= 1<<19,
-	IFF_OPENVSWITCH			= 1<<20,
-	IFF_L3MDEV_SLAVE		= 1<<21,
-	IFF_TEAM			= 1<<22,
-	IFF_RXFH_CONFIGURED		= 1<<23,
-	IFF_PHONY_HEADROOM		= 1<<24,
-	IFF_MACSEC			= 1<<25,
-	IFF_NO_RX_HANDLER		= 1<<26,
-	IFF_FAILOVER			= 1<<27,
-	IFF_FAILOVER_SLAVE		= 1<<28,
-	IFF_L3MDEV_RX_HANDLER		= 1<<29,
-	IFF_LIVE_RENAME_OK		= 1<<30,
-	IFF_TX_SKB_NO_LINEAR		= 1<<31,
+	IFF_802_1Q_VLAN_BIT,
+	IFF_EBRIDGE_BIT,
+	IFF_BONDING_BIT,
+	IFF_ISATAP_BIT,
+	IFF_WAN_HDLC_BIT,
+	IFF_XMIT_DST_RELEASE_BIT,
+	IFF_DONT_BRIDGE_BIT,
+	IFF_DISABLE_NETPOLL_BIT,
+	IFF_MACVLAN_PORT_BIT,
+	IFF_BRIDGE_PORT_BIT,
+	IFF_OVS_DATAPATH_BIT,
+	IFF_TX_SKB_SHARING_BIT,
+	IFF_UNICAST_FLT_BIT,
+	IFF_TEAM_PORT_BIT,
+	IFF_SUPP_NOFCS_BIT,
+	IFF_LIVE_ADDR_CHANGE_BIT,
+	IFF_MACVLAN_BIT,
+	IFF_XMIT_DST_RELEASE_PERM_BIT,
+	IFF_L3MDEV_MASTER_BIT,
+	IFF_NO_QUEUE_BIT,
+	IFF_OPENVSWITCH_BIT,
+	IFF_L3MDEV_SLAVE_BIT,
+	IFF_TEAM_BIT,
+	IFF_RXFH_CONFIGURED_BIT,
+	IFF_PHONY_HEADROOM_BIT,
+	IFF_MACSEC_BIT,
+	IFF_NO_RX_HANDLER_BIT,
+	IFF_FAILOVER_BIT,
+	IFF_FAILOVER_SLAVE_BIT,
+	IFF_L3MDEV_RX_HANDLER_BIT,
+	IFF_LIVE_RENAME_OK_BIT,
+	IFF_TX_SKB_NO_LINEAR_BIT,
 };
 
-#define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
-#define IFF_EBRIDGE			IFF_EBRIDGE
-#define IFF_BONDING			IFF_BONDING
-#define IFF_ISATAP			IFF_ISATAP
-#define IFF_WAN_HDLC			IFF_WAN_HDLC
-#define IFF_XMIT_DST_RELEASE		IFF_XMIT_DST_RELEASE
-#define IFF_DONT_BRIDGE			IFF_DONT_BRIDGE
-#define IFF_DISABLE_NETPOLL		IFF_DISABLE_NETPOLL
-#define IFF_MACVLAN_PORT		IFF_MACVLAN_PORT
-#define IFF_BRIDGE_PORT			IFF_BRIDGE_PORT
-#define IFF_OVS_DATAPATH		IFF_OVS_DATAPATH
-#define IFF_TX_SKB_SHARING		IFF_TX_SKB_SHARING
-#define IFF_UNICAST_FLT			IFF_UNICAST_FLT
-#define IFF_TEAM_PORT			IFF_TEAM_PORT
-#define IFF_SUPP_NOFCS			IFF_SUPP_NOFCS
-#define IFF_LIVE_ADDR_CHANGE		IFF_LIVE_ADDR_CHANGE
-#define IFF_MACVLAN			IFF_MACVLAN
-#define IFF_XMIT_DST_RELEASE_PERM	IFF_XMIT_DST_RELEASE_PERM
-#define IFF_L3MDEV_MASTER		IFF_L3MDEV_MASTER
-#define IFF_NO_QUEUE			IFF_NO_QUEUE
-#define IFF_OPENVSWITCH			IFF_OPENVSWITCH
-#define IFF_L3MDEV_SLAVE		IFF_L3MDEV_SLAVE
-#define IFF_TEAM			IFF_TEAM
-#define IFF_RXFH_CONFIGURED		IFF_RXFH_CONFIGURED
-#define IFF_PHONY_HEADROOM		IFF_PHONY_HEADROOM
-#define IFF_MACSEC			IFF_MACSEC
-#define IFF_NO_RX_HANDLER		IFF_NO_RX_HANDLER
-#define IFF_FAILOVER			IFF_FAILOVER
-#define IFF_FAILOVER_SLAVE		IFF_FAILOVER_SLAVE
-#define IFF_L3MDEV_RX_HANDLER		IFF_L3MDEV_RX_HANDLER
-#define IFF_LIVE_RENAME_OK		IFF_LIVE_RENAME_OK
-#define IFF_TX_SKB_NO_LINEAR		IFF_TX_SKB_NO_LINEAR
+#define __IFF_BIT(bit)		((netdev_priv_flags_t)1 << (bit))
+#define __IFF(name)		__IFF_BIT(IFF_##name##_BIT)
+
+#define IFF_802_1Q_VLAN			__IFF(802_1Q_VLAN)
+#define IFF_EBRIDGE			__IFF(EBRIDGE)
+#define IFF_BONDING			__IFF(BONDING)
+#define IFF_ISATAP			__IFF(ISATAP)
+#define IFF_WAN_HDLC			__IFF(WAN_HDLC)
+#define IFF_XMIT_DST_RELEASE		__IFF(XMIT_DST_RELEASE)
+#define IFF_DONT_BRIDGE			__IFF(DONT_BRIDGE)
+#define IFF_DISABLE_NETPOLL		__IFF(DISABLE_NETPOLL)
+#define IFF_MACVLAN_PORT		__IFF(MACVLAN_PORT)
+#define IFF_BRIDGE_PORT			__IFF(BRIDGE_PORT)
+#define IFF_OVS_DATAPATH		__IFF(OVS_DATAPATH)
+#define IFF_TX_SKB_SHARING		__IFF(TX_SKB_SHARING)
+#define IFF_UNICAST_FLT			__IFF(UNICAST_FLT)
+#define IFF_TEAM_PORT			__IFF(TEAM_PORT)
+#define IFF_SUPP_NOFCS			__IFF(SUPP_NOFCS)
+#define IFF_LIVE_ADDR_CHANGE		__IFF(LIVE_ADDR_CHANGE)
+#define IFF_MACVLAN			__IFF(MACVLAN)
+#define IFF_XMIT_DST_RELEASE_PERM	__IFF(XMIT_DST_RELEASE_PERM)
+#define IFF_L3MDEV_MASTER		__IFF(L3MDEV_MASTER)
+#define IFF_NO_QUEUE			__IFF(NO_QUEUE)
+#define IFF_OPENVSWITCH			__IFF(OPENVSWITCH)
+#define IFF_L3MDEV_SLAVE		__IFF(L3MDEV_SLAVE)
+#define IFF_TEAM			__IFF(TEAM)
+#define IFF_RXFH_CONFIGURED		__IFF(RXFH_CONFIGURED)
+#define IFF_PHONY_HEADROOM		__IFF(PHONY_HEADROOM)
+#define IFF_MACSEC			__IFF(MACSEC)
+#define IFF_NO_RX_HANDLER		__IFF(NO_RX_HANDLER)
+#define IFF_FAILOVER			__IFF(FAILOVER)
+#define IFF_FAILOVER_SLAVE		__IFF(FAILOVER_SLAVE)
+#define IFF_L3MDEV_RX_HANDLER		__IFF(L3MDEV_RX_HANDLER)
+#define IFF_LIVE_RENAME_OK		__IFF(LIVE_RENAME_OK)
+#define IFF_TX_SKB_NO_LINEAR		__IFF(TX_SKB_NO_LINEAR)
 
 /* Specifies the type of the struct net_device::ml_priv pointer */
 enum netdev_ml_priv_type {
@@ -1963,7 +1968,8 @@  struct net_device {
 
 	/* Read-mostly cache-line for fast-path access */
 	unsigned int		flags;
-	unsigned int		priv_flags;
+	/* 4 byte hole */
+	netdev_priv_flags_t	priv_flags;
 	const struct net_device_ops *netdev_ops;
 	int			ifindex;
 	unsigned short		gflags;