lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 9 Oct 2018 08:47:44 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Heiner Kallweit' <hkallweit1@...il.com>,
        David Miller <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH net-next] net: core: change bool members of struct
 net_device to bitfield members

From: Heiner Kallweit
> Sent: 08 October 2018 21:01
> 
> bool is good as parameter type or function return type, but if used
> for struct members it consumes more memory than needed.

Actually it can generate extra code when used as a parameter or
return type - but DM doesn't seem to worry about that,

> Changing the bool members of struct net_device to bitfield members
> allows to decrease the memory footprint of this struct.

On archs where bool is 8 bit does this actually make any difference?
Especially since the structure is probably malloced.

> Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
> ---
>  include/linux/netdevice.h | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 76603ee13..3d7b8df2e 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
...
> @@ -1879,7 +1882,6 @@ struct net_device {
>  	unsigned short          dev_port;
>  	spinlock_t		addr_list_lock;
>  	unsigned char		name_assign_type;
> -	bool			uc_promisc;

You've a great big hole here.
I suspect there is one after dev_port as well.

>  	struct netdev_hw_addr_list	uc;
>  	struct netdev_hw_addr_list	mc;
>  	struct netdev_hw_addr_list	dev_addrs;
> @@ -1986,14 +1988,11 @@ struct net_device {
>  	       NETREG_DUMMY,		/* dummy device for NAPI poll */
>  	} reg_state:8;
> 
> -	bool dismantle;
> -
>  	enum {
>  		RTNL_LINK_INITIALIZED,
>  		RTNL_LINK_INITIALIZING,
>  	} rtnl_link_state:16;
> 
> -	bool needs_free_netdev;

This one might remove some padding.
But it could be moved into one of the holes.

>  	void (*priv_destructor)(struct net_device *dev);
> 
>  #ifdef CONFIG_NETPOLL
> @@ -2046,7 +2045,10 @@ struct net_device {
>  	struct sfp_bus		*sfp_bus;
>  	struct lock_class_key	*qdisc_tx_busylock;
>  	struct lock_class_key	*qdisc_running_key;
> -	bool			proto_down;
> +	unsigned		uc_promisc:1;
> +	unsigned		dismantle:1;
> +	unsigned		needs_free_netdev:1;
> +	unsigned		proto_down:1;
>  	unsigned		wol_enabled:1;
>  };
>  #define to_net_dev(d) container_of(d, struct net_device, dev)
> --
> 2.19.1

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ