All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: "axboe@kernel.dk" <axboe@kernel.dk>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>,
	"damien.lemoal@opensource.wdc.com"
	<damien.lemoal@opensource.wdc.com>,
	Niklas Cassel <Niklas.Cassel@wdc.com>
Subject: [PATCH v2 04/18] client/server: convert ss_data to use an offset instead of fixed position
Date: Thu, 3 Feb 2022 19:28:25 +0000	[thread overview]
Message-ID: <20220203192814.18552-5-Niklas.Cassel@wdc.com> (raw)
In-Reply-To: <20220203192814.18552-1-Niklas.Cassel@wdc.com>

From: Niklas Cassel <niklas.cassel@wdc.com>

Store the location of the ss_data in the payload itself, rather than
assuming that it is always located at a fixed location, directly after
the cmd_ts_pdu data.

This is done as a cleanup patch in order to be able to handle
clat_prio_stats, which just like ss_data, may or may not be part of the
payload.

Server version is intentionally not incremented, as it will be incremented
in a later patch in the series. No need to bump it multiple times for the
same patch series.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 client.c | 10 ++++++----
 server.c | 59 ++++++++++++++++++++++++++++++++++++++++++--------------
 stat.h   | 10 ++++++++++
 3 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/client.c b/client.c
index 381af054..e51138ee 100644
--- a/client.c
+++ b/client.c
@@ -1761,7 +1761,6 @@ int fio_handle_client(struct fio_client *client)
 {
 	struct client_ops *ops = client->ops;
 	struct fio_net_cmd *cmd;
-	int size;
 
 	dprint(FD_NET, "client: handle %s\n", client->hostname);
 
@@ -1795,14 +1794,17 @@ int fio_handle_client(struct fio_client *client)
 		}
 	case FIO_NET_CMD_TS: {
 		struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
+		uint64_t offset;
 
 		dprint(FD_NET, "client: ts->ss_state = %u\n", (unsigned int) le32_to_cpu(p->ts.ss_state));
 		if (le32_to_cpu(p->ts.ss_state) & FIO_SS_DATA) {
 			dprint(FD_NET, "client: received steadystate ring buffers\n");
 
-			size = le64_to_cpu(p->ts.ss_dur);
-			p->ts.ss_iops_data = (uint64_t *) ((struct cmd_ts_pdu *)cmd->payload + 1);
-			p->ts.ss_bw_data = p->ts.ss_iops_data + size;
+			offset = le64_to_cpu(p->ts.ss_iops_data_offset);
+			p->ts.ss_iops_data = (uint64_t *)((char *)p + offset);
+
+			offset = le64_to_cpu(p->ts.ss_bw_data_offset);
+			p->ts.ss_bw_data = (uint64_t *)((char *)p + offset);
 		}
 
 		convert_ts(&p->ts, &p->ts);
diff --git a/server.c b/server.c
index af94cd78..9ec09345 100644
--- a/server.c
+++ b/server.c
@@ -1465,8 +1465,10 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
 {
 	struct cmd_ts_pdu p;
 	int i, j, k;
-	void *ss_buf;
-	uint64_t *ss_iops, *ss_bw;
+	size_t ss_extra_size = 0;
+	size_t extended_buf_size = 0;
+	void *extended_buf;
+	void *extended_buf_wp;
 
 	dprint(FD_NET, "server sending end stats\n");
 
@@ -1590,26 +1592,53 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
 	convert_gs(&p.rs, rs);
 
 	dprint(FD_NET, "ts->ss_state = %d\n", ts->ss_state);
-	if (ts->ss_state & FIO_SS_DATA) {
-		dprint(FD_NET, "server sending steadystate ring buffers\n");
+	if (ts->ss_state & FIO_SS_DATA)
+		ss_extra_size = 2 * ts->ss_dur * sizeof(uint64_t);
 
-		ss_buf = malloc(sizeof(p) + 2*ts->ss_dur*sizeof(uint64_t));
+	extended_buf_size += ss_extra_size;
+	if (!extended_buf_size) {
+		fio_net_queue_cmd(FIO_NET_CMD_TS, &p, sizeof(p), NULL, SK_F_COPY);
+		return;
+	}
 
-		memcpy(ss_buf, &p, sizeof(p));
+	extended_buf_size += sizeof(p);
+	extended_buf = calloc(1, extended_buf_size);
+	if (!extended_buf) {
+		log_err("fio: failed to allocate FIO_NET_CMD_TS buffer\n");
+		return;
+	}
+
+	memcpy(extended_buf, &p, sizeof(p));
+	extended_buf_wp = (struct cmd_ts_pdu *)extended_buf + 1;
 
-		ss_iops = (uint64_t *) ((struct cmd_ts_pdu *)ss_buf + 1);
-		ss_bw = ss_iops + (int) ts->ss_dur;
-		for (i = 0; i < ts->ss_dur; i++) {
+	if (ss_extra_size) {
+		uint64_t *ss_iops, *ss_bw;
+		uint64_t offset;
+		struct cmd_ts_pdu *ptr = extended_buf;
+
+		dprint(FD_NET, "server sending steadystate ring buffers\n");
+
+		/* ss iops */
+		ss_iops = (uint64_t *) extended_buf_wp;
+		for (i = 0; i < ts->ss_dur; i++)
 			ss_iops[i] = cpu_to_le64(ts->ss_iops_data[i]);
-			ss_bw[i] = cpu_to_le64(ts->ss_bw_data[i]);
-		}
 
-		fio_net_queue_cmd(FIO_NET_CMD_TS, ss_buf, sizeof(p) + 2*ts->ss_dur*sizeof(uint64_t), NULL, SK_F_COPY);
+		offset = (char *)extended_buf_wp - (char *)extended_buf;
+		ptr->ts.ss_iops_data_offset = cpu_to_le64(offset);
+		extended_buf_wp = ss_iops + (int) ts->ss_dur;
+
+		/* ss bw */
+		ss_bw = extended_buf_wp;
+		for (i = 0; i < ts->ss_dur; i++)
+			ss_bw[i] = cpu_to_le64(ts->ss_bw_data[i]);
 
-		free(ss_buf);
+		offset = (char *)extended_buf_wp - (char *)extended_buf;
+		ptr->ts.ss_bw_data_offset = cpu_to_le64(offset);
+		extended_buf_wp = ss_bw + (int) ts->ss_dur;
 	}
-	else
-		fio_net_queue_cmd(FIO_NET_CMD_TS, &p, sizeof(p), NULL, SK_F_COPY);
+
+	fio_net_queue_cmd(FIO_NET_CMD_TS, extended_buf, extended_buf_size, NULL, SK_F_COPY);
+	free(extended_buf);
 }
 
 void fio_server_send_gs(struct group_run_stats *rs)
diff --git a/stat.h b/stat.h
index 3ce821a7..5fa20f74 100644
--- a/stat.h
+++ b/stat.h
@@ -262,11 +262,21 @@ struct thread_stat {
 
 	union {
 		uint64_t *ss_iops_data;
+		/*
+		 * For FIO_NET_CMD_TS, the pointed to data will temporarily
+		 * be stored at this offset from the start of the payload.
+		 */
+		uint64_t ss_iops_data_offset;
 		uint64_t pad4;
 	};
 
 	union {
 		uint64_t *ss_bw_data;
+		/*
+		 * For FIO_NET_CMD_TS, the pointed to data will temporarily
+		 * be stored at this offset from the start of the payload.
+		 */
+		uint64_t ss_bw_data_offset;
 		uint64_t pad5;
 	};
 
-- 
2.34.1

  parent reply	other threads:[~2022-02-03 19:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 19:28 [PATCH v2 00/18] multiple priority latency stats support Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 02/18] backend: do ioprio_set() before calling the ioengine init callback Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 01/18] init: verify option lat_percentiles consistency for all jobs in group Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 03/18] stat: save the default ioprio in struct thread_stat Niklas Cassel
2022-02-03 19:28 ` Niklas Cassel [this message]
2022-02-03 19:28 ` [PATCH v2 05/18] stat: add a new function to allocate a clat_prio_stat array Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 06/18] os: define min/max prio class and level for systems without ioprio Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 07/18] options: add a parsing function for an additional cmdprio_bssplit format Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 08/18] cmdprio: add support for a new cmdprio_bssplit entry format Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 09/18] examples: add new cmdprio_bssplit format examples Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 10/18] stat: use enum fio_ddir consistently Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 12/18] stat: add helper for resetting the latency buckets Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 11/18] stat: increment members counter after call to sum_thread_stats() Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 14/18] stat: report clat stats on a per priority granularity Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 13/18] stat: disable per prio stats where not needed Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 15/18] stat: convert json output to a new per priority granularity format Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 16/18] gfio: drop support for high/low priority latency results Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 17/18] stat: remove unused high/low prio struct members Niklas Cassel
2022-02-03 19:28 ` [PATCH v2 18/18] t/latency_percentiles.py: add tests for the new cmdprio_bssplit format Niklas Cassel
2022-02-03 22:31 ` [PATCH v2 00/18] multiple priority latency stats support Jens Axboe

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=20220203192814.18552-5-Niklas.Cassel@wdc.com \
    --to=niklas.cassel@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@opensource.wdc.com \
    --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.