All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 5/6] Btrfs: use flags instead of the bool variants in delayed node
Date: Tue, 07 Jan 2014 11:59:18 +0800	[thread overview]
Message-ID: <52CB7B96.2020701@cn.fujitsu.com> (raw)
In-Reply-To: <20140103183610.GU6498@twin.jikos.cz>

On Fri, 3 Jan 2014 19:36:10 +0100, David Sterba wrote:
> On Fri, Jan 03, 2014 at 05:27:51PM +0800, Miao Xie wrote:
>> On Thu, 2 Jan 2014 18:49:55 +0100, David Sterba wrote:
>>> On Thu, Dec 26, 2013 at 01:07:05PM +0800, Miao Xie wrote:
>>>> +#define BTRFS_DELAYED_NODE_IN_LIST	0
>>>> +#define BTRFS_DELAYED_NODE_INODE_DIRTY	1
>>>> +
>>>>  struct btrfs_delayed_node {
>>>>  	u64 inode_id;
>>>>  	u64 bytes_reserved;
>>>> @@ -65,8 +68,7 @@ struct btrfs_delayed_node {
>>>>  	struct btrfs_inode_item inode_item;
>>>>  	atomic_t refs;
>>>>  	u64 index_cnt;
>>>> -	bool in_list;
>>>> -	bool inode_dirty;
>>>> +	unsigned long flags;
>>>>  	int count;
>>>>  };
>>>
>>> What's the reason to do that? Replacing 2 bools with a bitfield
>>> does not seem justified, not from saving memory, nor from a performance
>>> gain side.  Also some of the bit operations imply the lock instruction
>>> prefix so this affects the surrounding items as well.
>>>
>>> I don't think this is needed, unless you have further plans with the
>>> flags item.
>>
>> Yes, I introduced a flag in the next patch.
> 
> That's still 3 bool flags that are quite independent and consume less
> than the unsigned long anyway. Also the bool flags are something that
> compiler understands and can use during optimizations unlike the
> obfuscated bit access.

I made a mistake at the beginning, I though the size of boolean data type
in the kernel was 4 bytes because I saw it was implemented by the enumeration
type several years ago. But it has been changed for many years. So you are right.

But I read a discuss about the use of boolean type, some developers suggested
us to use bitfields instead of bool, because the bitfields can work better,
and they are more flexible, less misuse than bool.
  https://lkml.org/lkml/2013/9/1/154

Furthermore, we may introduce more flags in the future though I have no plan now.
So this patch makes sense I think.

Thanks
Miao

> I don't mind using bitfields, but it imo starts to make sense to use
> them when there are more than a few, like BTRFS_INODE_* or
> EXTENT_BUFFER_*. The point of my objections is to establish good coding
> patterns to follow.
> 
> david
> 


  reply	other threads:[~2014-01-07  3:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26  5:07 [PATCH v2 1/6] Btrfs: remove residual code in delayed inode async helper Miao Xie
2013-12-26  5:07 ` [PATCH v2 2/6] Btrfs: don't run delayed nodes again after all nodes flush Miao Xie
2013-12-26  5:07 ` [PATCH v2 3/6] Btrfs: cleanup code of btrfs_balance_delayed_items() Miao Xie
2013-12-26  5:07 ` [PATCH v2 4/6] Btrfs: remove btrfs_end_transaction_dmeta() Miao Xie
2013-12-26  5:07 ` [PATCH v2 5/6] Btrfs: use flags instead of the bool variants in delayed node Miao Xie
2014-01-02 17:49   ` David Sterba
2014-01-03  9:27     ` Miao Xie
2014-01-03 18:36       ` David Sterba
2014-01-07  3:59         ` Miao Xie [this message]
2014-01-07 21:11           ` David Sterba
2013-12-26  5:07 ` [PATCH v2 6/6] Btrfs: introduce the delayed inode ref deletion for the single link inode Miao Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CB7B96.2020701@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.