All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Fomichev <dmitry.fomichev@wdc.com>
To: Jens Axboe <axboe@kernel.dk>,
	fio@vger.kernel.org, Aravind Ramesh <aravind.ramesh@wdc.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Niklas Cassel <niklas.cassel@wdc.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>,
	Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	Dmitry Fomichev <dmitry.fomichev@wdc.com>
Subject: [PATCH v3 12/38] zbd: count sectors with data for write pointer zones
Date: Thu,  7 Jan 2021 06:57:13 +0900	[thread overview]
Message-ID: <20210106215739.264524-13-dmitry.fomichev@wdc.com> (raw)
In-Reply-To: <20210106215739.264524-1-dmitry.fomichev@wdc.com>

From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

ZBD fio code tracks 'sectors with data' for two different purposes.
The first one is to process zone_reset_threshold. When the ratio of
sectors with data in zones with write pointer goes beyond the specified
number, zone reset is triggered. The second purpose is to control the
direction of the first I/O of random mixed read/write workloads. If all
write pointer zones in the I/O range are reset at the beginning of such
a workload, fio has no data to read and will immediately end the run of
the test section. To avoid this, fio checks 'sectors with data' and if
it is zero (i.e. it is the very first I/O), it modifies the direction
of that I/O from read to write.

Currently, when the workload range includes both conventional and
sequential zones, all sectors in conventional zones are counted as
'sectors with data' along with sectors in sequential zones.
This leads to incorrect handling  of 'zone_reset_threshold' option -
zone reset timing of sequential zones is affected by the amount of
data read from or written to conventional zones. To avoid this,
conventional zones should be excluded from 'sectors with data'
calculation.

On the other hand, if the sectors of conventional zones were excluded
from the sectors with data, it could result in the wrong initial I/O
direction for random workloads. When the zones in I/O region are all
conventional, 'sectors with data' would always be zero. Because of
this, read operations are always changed to writes and reads are never
performed.

To avoid this contradiction, introduce another counter,
'wp_sector_with_data'. It works similar to the existing
'sectors_with_data', but it counts data sectors only in write pointer
zones. Use this newly introduced count for zone_reset_threshold checks
and keep on using the original count for the initial random I/O
direction determination.

When counting sectors with data, lock only write pointer zones, no need
to lock conventional zones.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 zbd.c | 25 ++++++++++++++++++-------
 zbd.h |  3 +++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/zbd.c b/zbd.c
index f7c29250..757e72d5 100644
--- a/zbd.c
+++ b/zbd.c
@@ -734,9 +734,10 @@ static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
 {
 	uint64_t offset = z->start;
 	uint64_t length = (z+1)->start - offset;
+	uint64_t data_in_zone = z->wp - z->start;
 	int ret = 0;
 
-	if (z->wp == z->start)
+	if (!data_in_zone)
 		return 0;
 
 	assert(is_valid_offset(f, offset + length - 1));
@@ -755,7 +756,8 @@ static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
 	}
 
 	pthread_mutex_lock(&f->zbd_info->mutex);
-	f->zbd_info->sectors_with_data -= z->wp - z->start;
+	f->zbd_info->sectors_with_data -= data_in_zone;
+	f->zbd_info->wp_sectors_with_data -= data_in_zone;
 	pthread_mutex_unlock(&f->zbd_info->mutex);
 	z->wp = z->start;
 	z->verify_block = 0;
@@ -887,25 +889,32 @@ static uint64_t zbd_process_swd(const struct fio_file *f, enum swd_action a)
 {
 	struct fio_zone_info *zb, *ze, *z;
 	uint64_t swd = 0;
+	uint64_t wp_swd = 0;
 
 	zb = get_zone(f, f->min_zone);
 	ze = get_zone(f, f->max_zone);
 	for (z = zb; z < ze; z++) {
-		pthread_mutex_lock(&z->mutex);
+		if (z->has_wp) {
+			pthread_mutex_lock(&z->mutex);
+			wp_swd += z->wp - z->start;
+		}
 		swd += z->wp - z->start;
 	}
 	pthread_mutex_lock(&f->zbd_info->mutex);
 	switch (a) {
 	case CHECK_SWD:
 		assert(f->zbd_info->sectors_with_data == swd);
+		assert(f->zbd_info->wp_sectors_with_data == wp_swd);
 		break;
 	case SET_SWD:
 		f->zbd_info->sectors_with_data = swd;
+		f->zbd_info->wp_sectors_with_data = wp_swd;
 		break;
 	}
 	pthread_mutex_unlock(&f->zbd_info->mutex);
 	for (z = zb; z < ze; z++)
-		zone_unlock(z);
+		if (z->has_wp)
+			zone_unlock(z);
 
 	return swd;
 }
@@ -916,7 +925,7 @@ static uint64_t zbd_process_swd(const struct fio_file *f, enum swd_action a)
  */
 static const bool enable_check_swd = false;
 
-/* Check whether the value of zbd_info.sectors_with_data is correct. */
+/* Check whether the values of zbd_info.*sectors_with_data are correct. */
 static void zbd_check_swd(const struct fio_file *f)
 {
 	if (!enable_check_swd)
@@ -1347,8 +1356,10 @@ static void zbd_queue_io(struct thread_data *td, struct io_u *io_u, int q,
 		 * z->wp > zone_end means that one or more I/O errors
 		 * have occurred.
 		 */
-		if (z->wp <= zone_end)
+		if (z->wp <= zone_end) {
 			zbd_info->sectors_with_data += zone_end - z->wp;
+			zbd_info->wp_sectors_with_data += zone_end - z->wp;
+		}
 		pthread_mutex_unlock(&zbd_info->mutex);
 		z->wp = zone_end;
 		break;
@@ -1650,7 +1661,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
 		}
 		/* Check whether the zone reset threshold has been exceeded */
 		if (td->o.zrf.u.f) {
-			if (f->zbd_info->sectors_with_data >=
+			if (f->zbd_info->wp_sectors_with_data >=
 			    f->io_size * td->o.zrt.u.f &&
 			    zbd_dec_and_reset_write_cnt(td, f)) {
 				zb->reset_zone = 1;
diff --git a/zbd.h b/zbd.h
index 059a9f9e..cc3ab624 100644
--- a/zbd.h
+++ b/zbd.h
@@ -55,6 +55,8 @@ struct fio_zone_info {
  *		num_open_zones).
  * @zone_size: size of a single zone in bytes.
  * @sectors_with_data: total size of data in all zones in units of 512 bytes
+ * @wp_sectors_with_data: total size of data in zones with write pointers in
+ *                        units of 512 bytes
  * @zone_size_log2: log2 of the zone size in bytes if it is a power of 2 or 0
  *		if the zone size is not a power of 2.
  * @nr_zones: number of zones
@@ -75,6 +77,7 @@ struct zoned_block_device_info {
 	pthread_mutex_t		mutex;
 	uint64_t		zone_size;
 	uint64_t		sectors_with_data;
+	uint64_t		wp_sectors_with_data;
 	uint32_t		zone_size_log2;
 	uint32_t		nr_zones;
 	uint32_t		refcount;
-- 
2.28.0



  parent reply	other threads:[~2021-01-06 21:57 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 21:57 [PATCH v3 00/38] ZBD fixes and improvements Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 01/38] zbd: return ENOMEM if zone buffer allocation fails Dmitry Fomichev
2021-01-22  2:07   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 02/38] zbd: use zbd_zone_nr() more actively in the code Dmitry Fomichev
2021-01-22  2:14   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 03/38] zbd: add get_zone() helper function Dmitry Fomichev
2021-01-22  2:19   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 04/38] zbd: introduce zone_unlock() Dmitry Fomichev
2021-01-22  2:23   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 05/38] zbd: engines/libzbc: don't fail on assert for offline zones Dmitry Fomichev
2021-01-22  2:27   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 06/38] zbd: remove dependency on zone type during i/o Dmitry Fomichev
2021-01-22  3:56   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 07/38] zbd: skip offline zones in zbd_convert_to_open_zone() Dmitry Fomichev
2021-01-22  3:59   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 08/38] zbd: avoid zone buffer overrun Dmitry Fomichev
2021-01-22  4:02   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 09/38] zbd: don't unlock zone mutex after verify replay Dmitry Fomichev
2021-01-22  4:13   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 10/38] zbd: do not lock conventional zones on I/O adjustment Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 11/38] zbd: do not set zbd handlers for conventional zones Dmitry Fomichev
2021-01-06 21:57 ` Dmitry Fomichev [this message]
2021-01-06 21:57 ` [PATCH v3 13/38] zbd: initialize min_zone and max_zone for all zone types Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 14/38] zbd: initialize sectors with data at start time Dmitry Fomichev
2021-01-22  4:19   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 15/38] zbd: use zone_lock() in zbd_process_swd() Dmitry Fomichev
2021-01-22  4:28   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 16/38] zbd: disable crossing from conventional to sequential zones Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 17/38] zbd: don't log "zone nnnn is not open" message Dmitry Fomichev
2021-01-22  4:31   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 18/38] zbd: handle conventional start zone in zbd_convert_to_open_zone() Dmitry Fomichev
2021-01-22  4:36   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 19/38] zbd: improve replay range validation Dmitry Fomichev
2021-01-22  4:47   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 20/38] engines/libzbc: enable block backend Dmitry Fomichev
2021-01-22  4:49   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 21/38] zbd: avoid failing assertion in zbd_convert_to_open_zone() Dmitry Fomichev
2021-01-22  5:05   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 22/38] zbd: set thread errors in zbd_adjust_block() Dmitry Fomichev
2021-01-22  5:12   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 23/38] t/zbd: check for error in test #2 Dmitry Fomichev
2021-01-22  5:13   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 24/38] t/zbd: add run-tests-against-nullb script Dmitry Fomichev
2021-01-22  8:47   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 25/38] t/zbd: add -t option to run-tests-against-nullb Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 26/38] t/zbd: skip tests when test prerequisites are not met Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 27/38] t/zbd: skip tests that need too many sequential zones Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 28/38] t/zbd: test that conventional zones are not locked during random i/o Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 29/38] t/zbd: test that zone_reset_threshold calculation is correct Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 30/38] t/zbd: test random I/O direction in all-conventional case Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 31/38] t/zbd: fix wrong units in test case #37 Dmitry Fomichev
2021-01-06 21:57 ` [PATCH v3 32/38] t/zbd: add an option to bail on a failed test Dmitry Fomichev
2021-01-22  8:53   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 33/38] t/zbd: prevent test #31 from looping Dmitry Fomichev
2021-01-22  8:56   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 34/38] t/zbd: add checks for offline zone condition Dmitry Fomichev
2021-01-22  9:06   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 35/38] t/zbd: add test #54 to exercise ZBD verification Dmitry Fomichev
2021-01-22  9:10   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 36/38] t/zbd: show elapsed time in test-zbd-support Dmitry Fomichev
2021-01-22  9:11   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 37/38] t/zbd: increase timeout in test #48 Dmitry Fomichev
2021-01-22  9:12   ` Shinichiro Kawasaki
2021-01-06 21:57 ` [PATCH v3 38/38] t/zbd: avoid looping on invalid command line options Dmitry Fomichev
2021-01-22  9:14   ` Shinichiro Kawasaki
2021-01-22  9:24 ` [PATCH v3 00/38] ZBD fixes and improvements Shinichiro Kawasaki
2021-01-22 20:31   ` Dmitry Fomichev

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=20210106215739.264524-13-dmitry.fomichev@wdc.com \
    --to=dmitry.fomichev@wdc.com \
    --cc=aravind.ramesh@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=damien.lemoal@wdc.com \
    --cc=fio@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=niklas.cassel@wdc.com \
    --cc=shinichiro.kawasaki@wdc.com \
    /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.