All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Alexey Dobriyan <adobriyan@gmail.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>
Subject: Re: [PATCH 6/9] zbd: consolidate zone mutex initialisation
Date: Mon, 11 May 2020 01:16:04 +0000	[thread overview]
Message-ID: <BY5PR04MB690046CB592B1B01E93B18B5E7A10@BY5PR04MB6900.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200505175634.2517-6-adobriyan@gmail.com

On 2020/05/06 2:56, Alexey Dobriyan wrote:
> Initialise everything that is not write pointers coming from device or
> faked separatedly.

s/Initialise/Initialize
s/separatedly/separately

> 
> More stuff (verification in ZBD mode and ->write_mutex) will be added.
> 
> Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
> ---
>  zbd.c | 39 ++++++++++++++++++++-------------------
>  1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/zbd.c b/zbd.c
> index 2926bae9..df46da42 100644
> --- a/zbd.c
> +++ b/zbd.c
> @@ -351,7 +351,6 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)
>  	struct fio_zone_info *p;
>  	uint64_t zone_size = td->o.zone_size;
>  	struct zoned_block_device_info *zbd_info = NULL;
> -	pthread_mutexattr_t attr;
>  	int i;
>  
>  	if (zone_size == 0) {
> @@ -372,14 +371,9 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)
>  	if (!zbd_info)
>  		return -ENOMEM;
>  
> -	pthread_mutexattr_init(&attr);
> -	pthread_mutexattr_setpshared(&attr, true);
> -	pthread_mutex_init(&zbd_info->mutex, &attr);
> -	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
>  	zbd_info->refcount = 1;
>  	p = &zbd_info->zone_info[0];
>  	for (i = 0; i < nr_zones; i++, p++) {
> -		pthread_mutex_init(&p->mutex, &attr);
>  		p->start = i * zone_size;
>  		p->wp = p->start + zone_size;
>  		p->type = ZBD_ZONE_TYPE_SWR;
> @@ -393,7 +387,6 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)
>  	f->zbd_info->zone_size_log2 = is_power_of_2(zone_size) ?
>  		ilog2(zone_size) : 0;
>  	f->zbd_info->nr_zones = nr_zones;
> -	pthread_mutexattr_destroy(&attr);
>  	return 0;
>  }
>  
> @@ -413,12 +406,8 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
>  	struct fio_zone_info *p;
>  	uint64_t zone_size, offset;
>  	struct zoned_block_device_info *zbd_info = NULL;
> -	pthread_mutexattr_t attr;
>  	int i, j, ret = 0;
>  
> -	pthread_mutexattr_init(&attr);
> -	pthread_mutexattr_setpshared(&attr, true);
> -
>  	zones = calloc(ZBD_REPORT_MAX_ZONES, sizeof(struct zbd_zone));
>  	if (!zones)
>  		goto out;
> @@ -452,14 +441,11 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
>  	ret = -ENOMEM;
>  	if (!zbd_info)
>  		goto out;
> -	pthread_mutex_init(&zbd_info->mutex, &attr);
> -	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
>  	zbd_info->refcount = 1;
>  	p = &zbd_info->zone_info[0];
>  	for (offset = 0, j = 0; j < nr_zones;) {
>  		z = &zones[0];
>  		for (i = 0; i < nrz; i++, j++, z++, p++) {
> -			pthread_mutex_init(&p->mutex, &attr);
>  			p->start = z->start;
>  			switch (z->cond) {
>  			case ZBD_ZONE_COND_NOT_WP:
> @@ -510,7 +496,6 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
>  out:
>  	sfree(zbd_info);
>  	free(zones);
> -	pthread_mutexattr_destroy(&attr);
>  	return ret;
>  }
>  
> @@ -521,7 +506,9 @@ out:
>   */
>  static int zbd_create_zone_info(struct thread_data *td, struct fio_file *f)
>  {
> +	struct zoned_block_device_info *zbd;
>  	enum zbd_zoned_model zbd_model;
> +	pthread_mutexattr_t attr;
>  	int ret;
>  
>  	assert(td->o.zone_mode == ZONE_MODE_ZBD);
> @@ -546,11 +533,25 @@ static int zbd_create_zone_info(struct thread_data *td, struct fio_file *f)
>  		return -EINVAL;
>  	}
>  
> -	if (ret == 0) {
> -		f->zbd_info->model = zbd_model;
> -		f->zbd_info->max_open_zones = td->o.max_open_zones;
> +	if (ret)
> +		return ret;
> +
> +	zbd = f->zbd_info;
> +	zbd->model = zbd_model;
> +	zbd->max_open_zones = td->o.max_open_zones;
> +
> +	pthread_mutexattr_init(&attr);
> +	pthread_mutexattr_setpshared(&attr, true);
> +	pthread_mutex_init(&zbd->mutex, &attr);
> +	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
> +	for (uint32_t z = 0; z < zbd->nr_zones; z++) {
> +		struct fio_zone_info *zi = &zbd->zone_info[z];
> +
> +		pthread_mutex_init(&zi->mutex, &attr);
>  	}
> -	return ret;
> +	pthread_mutexattr_destroy(&attr);
> +
> +	return 0;
>  }
>  
>  void zbd_free_zone_info(struct fio_file *f)
> 

On a very large drive (e.g. 20TB SMR), we have in excess of 70000 zones. Having
to loop over all of them again will start to be painful and likely slow down (a
little) startup. And going forward with ever increasing disk capacity, this will
get even worse. So not sure if this patch makes much sense.

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2020-05-11  1:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 17:56 [PATCH 1/9] verify: decouple seed generation from buffer fill Alexey Dobriyan
2020-05-05 17:56 ` [PATCH 2/9] zbd: bump ZBD_MAX_OPEN_ZONES Alexey Dobriyan
2020-05-05 17:56 ` [PATCH 3/9] zbd: don't lock zones outside working area Alexey Dobriyan
2020-05-05 17:56 ` [PATCH 4/9] zbd: introduce per job maximum open zones limit Alexey Dobriyan
2020-05-11  1:09   ` Damien Le Moal
2020-05-05 17:56 ` [PATCH 5/9] zbd: make zbd_info->mutex non-recursive Alexey Dobriyan
2020-05-11  1:11   ` Damien Le Moal
2020-05-05 17:56 ` [PATCH 6/9] zbd: consolidate zone mutex initialisation Alexey Dobriyan
2020-05-11  1:16   ` Damien Le Moal [this message]
2020-05-21 21:44     ` Alexey Dobriyan
2020-05-21 22:02       ` Damien Le Moal
2020-05-21 22:27         ` Alexey Dobriyan
2020-05-05 17:56 ` [PATCH 7/9] fio: parse "io_size=1%" Alexey Dobriyan
2020-05-11  1:20   ` Damien Le Moal
2020-05-21 22:13     ` Alexey Dobriyan
2020-05-05 17:56 ` [PATCH 8/9] zbd: support verification Alexey Dobriyan
2020-05-05 17:59   ` Alexey Dobriyan
2020-05-11  2:01     ` Damien Le Moal
2020-05-11  1:59   ` Damien Le Moal
2020-05-11 16:00     ` Alexey Dobriyan
2020-05-11  0:56 ` [PATCH 1/9] verify: decouple seed generation from buffer fill Damien Le Moal

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=BY5PR04MB690046CB592B1B01E93B18B5E7A10@BY5PR04MB6900.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=adobriyan@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=fio@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.