public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v4 5/6] ext4: improve cr 0 / cr 1 group scanning
Date: Tue, 16 Mar 2021 10:55:30 +0300	[thread overview]
Message-ID: <20210316075530.GS21246@kadam> (raw)
In-Reply-To: <20210315173716.360726-6-harshadshirwadkar@gmail.com>

On Mon, Mar 15, 2021 at 10:37:15AM -0700, Harshad Shirwadkar wrote:
> @@ -744,6 +801,251 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
>  	}
>  }
>  
> +static void ext4_mb_rb_insert(struct rb_root *root, struct rb_node *new,
> +			int (*cmp)(struct rb_node *, struct rb_node *))
> +{
> +	struct rb_node **iter = &root->rb_node, *parent = NULL;
> +
> +	while (*iter) {
> +		parent = *iter;
> +		if (cmp(new, *iter))
> +			iter = &((*iter)->rb_left);
> +		else
> +			iter = &((*iter)->rb_right);
> +	}

This would be neater like so:

	while (*iter) {
		node = *iter;
		if (cmp(new, node))
			iter = &node->rb_left;
		else
			iter = &node->rb_right;
	}

It's unexpected that the cmp() function returns bool instead of -1, 0
1 like other cmp() functions.

> +
> +	rb_link_node(new, parent, iter);
> +	rb_insert_color(new, root);
> +}
> +

[ snip ]

> @@ -2909,6 +3240,22 @@ int ext4_mb_init(struct super_block *sb)
>  		i++;
>  	} while (i < MB_NUM_ORDERS(sb));
>  
> +	sbi->s_mb_avg_fragment_size_root = RB_ROOT;
> +	sbi->s_mb_largest_free_orders =
> +		kmalloc_array(MB_NUM_ORDERS(sb), sizeof(struct list_head),
> +			GFP_KERNEL);
> +	if (!sbi->s_mb_largest_free_orders)
> +		goto out;

Missing error code.  ret = -ENOMEM;

> +	sbi->s_mb_largest_free_orders_locks =
> +		kmalloc_array(MB_NUM_ORDERS(sb), sizeof(rwlock_t),
> +			GFP_KERNEL);
> +	if (!sbi->s_mb_largest_free_orders_locks)
> +		goto out;

ret = -ENOMEM;

> +	for (i = 0; i < MB_NUM_ORDERS(sb); i++) {
> +		INIT_LIST_HEAD(&sbi->s_mb_largest_free_orders[i]);
> +		rwlock_init(&sbi->s_mb_largest_free_orders_locks[i]);
> +	}
> +	rwlock_init(&sbi->s_mb_rb_lock);
>  
>  	spin_lock_init(&sbi->s_md_lock);
>  	sbi->s_mb_free_pending = 0;
> @@ -2961,6 +3308,10 @@ int ext4_mb_init(struct super_block *sb)
>  		spin_lock_init(&lg->lg_prealloc_lock);
>  	}
>  
> +	if (blk_queue_nonrot(bdev_get_queue(sb->s_bdev)))
> +		sbi->s_mb_linear_limit = 0;
> +	else
> +		sbi->s_mb_linear_limit = MB_DEFAULT_LINEAR_LIMIT;
>  	/* init file for buddy data */
>  	ret = ext4_mb_init_backend(sb);
>  	if (ret != 0)
> @@ -2972,6 +3323,8 @@ int ext4_mb_init(struct super_block *sb)
>  	free_percpu(sbi->s_locality_groups);
>  	sbi->s_locality_groups = NULL;
>  out:
> +	kfree(sbi->s_mb_largest_free_orders);
> +	kfree(sbi->s_mb_largest_free_orders_locks);
>  	kfree(sbi->s_mb_offsets);
>  	sbi->s_mb_offsets = NULL;
>  	kfree(sbi->s_mb_maxs);
> @@ -3028,6 +3381,7 @@ int ext4_mb_release(struct super_block *sb)
>  		kvfree(group_info);
>  		rcu_read_unlock();
>  	}
> +	kfree(sbi->s_mb_largest_free_orders);


Add kfree(sbi->s_mb_largest_free_orders_locks);

>  	kfree(sbi->s_mb_offsets);
>  	kfree(sbi->s_mb_maxs);
>  	iput(sbi->s_buddy_cache);

regards,
dan carpenter

  parent reply	other threads:[~2021-03-16  7:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 17:37 Block allocator improvements Harshad Shirwadkar
2021-03-15 17:37 ` [PATCH v4 1/6] ext4: drop s_mb_bal_lock and convert protected fields to atomic Harshad Shirwadkar
2021-03-15 17:37 ` [PATCH v4 2/6] ext4: add ability to return parsed options from parse_options Harshad Shirwadkar
2021-03-15 19:06   ` Christoph Hellwig
2021-03-17 11:11   ` Благодаренко Артём
2021-03-15 17:37 ` [PATCH v4 3/6] ext4: add mballoc stats proc file Harshad Shirwadkar
2021-03-15 17:37 ` [PATCH v4 4/6] ext4: add MB_NUM_ORDERS macro Harshad Shirwadkar
2021-03-15 17:37 ` [PATCH v4 5/6] ext4: improve cr 0 / cr 1 group scanning Harshad Shirwadkar
2021-03-15 20:56   ` Andreas Dilger
2021-03-16  7:55   ` Dan Carpenter [this message]
2021-03-22 15:33   ` Благодаренко Артём
2021-03-22 17:25     ` harshad shirwadkar
2021-03-15 17:37 ` [PATCH v4 6/6] ext4: add proc files to monitor new structures Harshad Shirwadkar
2021-03-15 19:52   ` Andreas Dilger
2021-03-15 19:52 ` Block allocator improvements Andreas Dilger

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=20210316075530.GS21246@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=harshadshirwadkar@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=tytso@mit.edu \
    /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