From: Liu Bo <bo.li.liu@oracle.com>
To: David Sterba <dave@jikos.cz>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/5] Btrfs: fix trans block rsv regression
Date: Fri, 14 Sep 2012 20:16:14 +0800 [thread overview]
Message-ID: <5053200E.3010702@oracle.com> (raw)
In-Reply-To: <20120914120711.GI17430@twin.jikos.cz>
On 09/14/2012 08:07 PM, David Sterba wrote:
> On Fri, Sep 14, 2012 at 07:25:45PM +0800, Liu Bo wrote:
>> On 09/14/2012 07:15 PM, David Sterba wrote:
>>> On Fri, Sep 14, 2012 at 04:58:04PM +0800, Liu Bo wrote:
>>>> --- a/fs/btrfs/transaction.c
>>>> +++ b/fs/btrfs/transaction.c
>>>> @@ -306,9 +306,17 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
>>>> WARN_ON(type != TRANS_JOIN && type != TRANS_JOIN_NOLOCK &&
>>>> type != TRANS_JOIN_ONLY);
>>>> h = current->journal_info;
>>>> - h->use_count++;
>>>> - h->orig_rsv = h->block_rsv;
>>>> + if (h->block_rsv) {
>>>> + struct btrfs_trans_rsv_item *item;
>>>> + item = kmalloc(sizeof(*item), GFP_NOFS);
>>>
>>> I'd rather avoid the kmalloc here and add a list hook into
>>> btrfs_block_rsv itself (used only for this purpose).
>>>
>>> It also does not increase the failure surface and we don't have to
>>> handle error conditions from deep callchains.
>>>
>>
>> Actually I placed a list hook at first, but I found the same block_rsv could be inserted into
>> the list chain twice, which will cause list_head's terrible warnings.
>
> Is it expected and correct to add the rsv twice? I know the transaction
> joins and commits are sometimes wildly nested so it does not mean that's
> necessarily a bug. Then it is not possible to embed the list hook, we
> need to keep the full track of the blk_rsv stack.
>
> I'm counting two other similar structs used inside btrfs
> (list_head + 8B value), we could make a shared separate slab for them.
>
> struct delayed_iput {
> struct list_head list; /* 0 16 */
> struct inode * inode; /* 16 8 */
>
> /* size: 24, cachelines: 1, members: 2 */
> /* last cacheline: 24 bytes */
> };
>
> truct seq_list {
> struct list_head list; /* 0 16 */
> u64 seq; /* 16 8 */
>
> /* size: 24, cachelines: 1, members: 2 */
> /* last cacheline: 24 bytes */
> };
>
> seq_list is never allocated, only embedded inside tree_mod_log structures.
>
> delayed_iput is allocated on every add_delayed_iput and freed quite
> frequently (once per-commit at least), so this is a short-lived object
> as well as the proposed btrfs_trans_rsv_item. IMO this justifies using
> the slab. Does this sound good to you?
>
Good, a quick thinking says it will work ;)
btw, do you have any test suit to measure this kind of cacheline efficiency so that
we can get some numbers to see if it really helps?
- liubo
>
> david
>
next prev parent reply other threads:[~2012-09-14 12:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 8:58 [PATCH 1/5] Btrfs: fix deadlock with freeze and sync Liu Bo
2012-09-14 8:58 ` [PATCH 2/5] Btrfs: fix trans block rsv regression Liu Bo
2012-09-14 11:15 ` David Sterba
2012-09-14 11:25 ` Liu Bo
2012-09-14 12:07 ` David Sterba
2012-09-14 12:16 ` Liu Bo [this message]
2012-09-14 12:41 ` Josef Bacik
2012-09-14 13:01 ` Liu Bo
2012-09-14 13:05 ` Liu Bo
2012-09-23 10:08 ` Miao Xie
2012-09-14 13:26 ` David Sterba
2012-09-14 8:58 ` [PATCH 3/5] Btrfs: cleanup for duplicated code in find_free_extent Liu Bo
2012-09-14 11:36 ` David Sterba
2012-09-14 8:58 ` [PATCH 4/5] Btrfs: cleanup fs_info->hashers Liu Bo
2012-09-14 11:21 ` David Sterba
2012-09-14 8:58 ` [PATCH 5/5] Btrfs: kill obsolete arguments in btrfs_wait_ordered_extents Liu Bo
2012-09-14 12:45 ` Josef Bacik
2012-09-14 12:55 ` Liu Bo
2012-09-14 13:01 ` Josef Bacik
2012-09-14 13:09 ` David Sterba
2012-09-14 10:07 ` [PATCH 1/5] Btrfs: fix deadlock with freeze and sync Miao Xie
2012-09-14 11:30 ` Liu Bo
2012-09-14 12:42 ` Josef Bacik
2012-09-14 13:03 ` Liu Bo
2012-09-14 14:41 ` Josef Bacik
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=5053200E.3010702@oracle.com \
--to=bo.li.liu@oracle.com \
--cc=dave@jikos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).