From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiner Kallweit Subject: Re: [PATCH net-next] net: core: change bool members of struct net_device to bitfield members Date: Mon, 8 Oct 2018 22:14:58 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "netdev@vger.kernel.org" To: Randy Dunlap , David Miller Return-path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:33937 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeJID2e (ORCPT ); Mon, 8 Oct 2018 23:28:34 -0400 Received: by mail-wr1-f65.google.com with SMTP id z4-v6so22155757wrb.1 for ; Mon, 08 Oct 2018 13:15:04 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 08.10.2018 22:07, Randy Dunlap wrote: > On 10/8/18 1:00 PM, Heiner Kallweit wrote: >> bool is good as parameter type or function return type, but if used >> for struct members it consumes more memory than needed. >> Changing the bool members of struct net_device to bitfield members >> allows to decrease the memory footprint of this struct. >> >> Signed-off-by: Heiner Kallweit >> --- >> 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 >> @@ -1651,10 +1651,6 @@ enum netdev_priv_flags { >> * @dev_port: Used to differentiate devices that share >> * the same function >> * @addr_list_lock: XXX: need comments on this one >> - * @uc_promisc: Counter that indicates promiscuous mode >> - * has been enabled due to the need to listen to >> - * additional unicast addresses in a device that >> - * does not implement ndo_set_rx_mode() >> * @uc: unicast mac addresses >> * @mc: multicast mac addresses >> * @dev_addrs: list of device hw addresses >> @@ -1714,11 +1710,9 @@ enum netdev_priv_flags { >> * @link_watch_list: XXX: need comments on this one >> * >> * @reg_state: Register/unregister state machine >> - * @dismantle: Device is going to be freed >> * @rtnl_link_state: This enum represents the phases of creating >> * a new link >> * >> - * @needs_free_netdev: Should unregister perform free_netdev? >> * @priv_destructor: Called from unregister >> * @npinfo: XXX: need comments on this one >> * @nd_net: Network namespace this network device is inside >> @@ -1758,6 +1752,15 @@ enum netdev_priv_flags { >> * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock >> * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount >> * >> + * @uc_promisc: Counter that indicates promiscuous mode >> + * has been enabled due to the need to listen to >> + * additional unicast addresses in a device that >> + * does not implement ndo_set_rx_mode() > > Hi, > > I see that all you did is copy/paste that text (above), but I wouldn't call > a single bit a [1-bit] Counter. > I stumbled across this comment too. Neither a bool member nor a 1-bit bitfield member should be called a counter. I kept the original comment, but I'm totally fine with changing Counter -> Flag and will provide a v2. > thanks, >