Blame SOURCES/0015-Move-block_in_bytes-entirely-to-the-presentation-lay.patch

271612
From 10660e29ea19a0e290e28afe0425f63afd0abd58 Mon Sep 17 00:00:00 2001
695b7d
From: "Richard W.M. Jones" <rjones@redhat.com>
695b7d
Date: Mon, 27 Mar 2017 21:22:52 +0100
271612
Subject: [PATCH 15/23] Move block_in_bytes entirely to the presentation layer.
695b7d
695b7d
Simplifies and updates commit dbef8dd3bf00417e75a12c851b053e49c9e1a79e.
695b7d
---
695b7d
 src/collect.ml       | 19 +++----------------
695b7d
 src/collect.mli      |  6 +-----
695b7d
 src/csv_output.ml    | 14 ++++++++++----
695b7d
 src/csv_output.mli   |  2 +-
695b7d
 src/redraw.ml        | 10 +++++++---
695b7d
 src/stream_output.ml | 14 ++++++++++----
695b7d
 src/top.ml           |  4 ++--
695b7d
 7 files changed, 34 insertions(+), 35 deletions(-)
695b7d
695b7d
diff --git a/src/collect.ml b/src/collect.ml
695b7d
index f856067..448ce8c 100644
695b7d
--- a/src/collect.ml
695b7d
+++ b/src/collect.ml
695b7d
@@ -57,12 +57,8 @@ and rd_active = {
695b7d
   (* The following are since the last slice, or None if cannot be calc'd: *)
695b7d
   rd_block_rd_reqs : int64 option;      (* Number of block device read rqs. *)
695b7d
   rd_block_wr_reqs : int64 option;      (* Number of block device write rqs. *)
695b7d
-  rd_block_rd_bytes : int64 option;   (* Number of bytes block device read *)
695b7d
-  rd_block_wr_bytes : int64 option;   (* Number of bytes block device write *)
695b7d
-  (* _info fields includes the number considering --block_in_bytes option *)
695b7d
-  rd_block_rd_info : int64 option;    (* Block device read info for user *)
695b7d
-  rd_block_wr_info : int64 option;    (* Block device read info for user *)
695b7d
-
695b7d
+  rd_block_rd_bytes : int64 option;     (* Number of bytes block device read *)
695b7d
+  rd_block_wr_bytes : int64 option;     (* Number of bytes block device write *)
695b7d
   rd_net_rx_bytes : int64 option;	(* Number of bytes received. *)
695b7d
   rd_net_tx_bytes : int64 option;	(* Number of bytes transmitted. *)
695b7d
 }
695b7d
@@ -114,7 +110,7 @@ let last_pcpu_usages = Hashtbl.create 13
695b7d
 let clear_pcpu_display_data () =
695b7d
   Hashtbl.clear last_pcpu_usages
695b7d
 
695b7d
-let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
695b7d
+let collect (conn, _, _, _, _, node_info, _, _) =
695b7d
   (* Number of physical CPUs (some may be disabled). *)
695b7d
   let nr_pcpus = C.maxcpus_of_node_info node_info in
695b7d
 
695b7d
@@ -178,7 +174,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
695b7d
                       rd_mem_bytes = 0L; rd_mem_percent = 0L;
695b7d
 		      rd_block_rd_reqs = None; rd_block_wr_reqs = None;
695b7d
                       rd_block_rd_bytes = None; rd_block_wr_bytes = None;
695b7d
-                      rd_block_rd_info = None; rd_block_wr_info = None;
695b7d
 		      rd_net_rx_bytes = None; rd_net_tx_bytes = None;
695b7d
 		    })
695b7d
 	  with
695b7d
@@ -256,14 +251,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
695b7d
                     rd_block_rd_bytes = Some read_bytes;
695b7d
                     rd_block_wr_bytes = Some write_bytes;
695b7d
          } in
695b7d
-         let rd = { rd with
695b7d
-                    rd_block_rd_info =
695b7d
-                      if block_in_bytes then
695b7d
-                        rd.rd_block_rd_bytes else rd.rd_block_rd_reqs;
695b7d
-                    rd_block_wr_info =
695b7d
-                      if block_in_bytes then
695b7d
-                        rd.rd_block_wr_bytes else rd.rd_block_wr_reqs;
695b7d
-         } in
695b7d
 	 name, Active rd
695b7d
       (* For all other domains we can't calculate it, so leave as None. *)
695b7d
       | rd -> rd
695b7d
diff --git a/src/collect.mli b/src/collect.mli
695b7d
index 440859b..9ad3dcb 100644
695b7d
--- a/src/collect.mli
695b7d
+++ b/src/collect.mli
695b7d
@@ -48,10 +48,6 @@ and rd_active = {
695b7d
   rd_block_wr_reqs : int64 option;      (* Number of block device write rqs. *)
695b7d
   rd_block_rd_bytes : int64 option;     (* Number of bytes block device read *)
695b7d
   rd_block_wr_bytes : int64 option;     (* Number of bytes block device write *)
695b7d
-  (* _info fields includes the number considering --block_in_bytes option *)
695b7d
-  rd_block_rd_info : int64 option;      (* Block device read info for user *)
695b7d
-  rd_block_wr_info : int64 option;      (* Block device read info for user *)
695b7d
-
695b7d
   rd_net_rx_bytes : int64 option;	(* Number of bytes received. *)
695b7d
   rd_net_tx_bytes : int64 option;	(* Number of bytes transmitted. *)
695b7d
 }
695b7d
@@ -75,7 +71,7 @@ type pcpu_stats = {
695b7d
   rd_pcpu_pcpus_cpu_time : float array
695b7d
 }
695b7d
 
695b7d
-val collect : Types.setup -> bool -> stats
695b7d
+val collect : Types.setup -> stats
695b7d
 (** Collect statistics. *)
695b7d
 
695b7d
 val collect_pcpu : stats -> pcpu_stats
695b7d
diff --git a/src/csv_output.ml b/src/csv_output.ml
695b7d
index 9496ca8..f23d673 100644
695b7d
--- a/src/csv_output.ml
695b7d
+++ b/src/csv_output.ml
695b7d
@@ -56,6 +56,7 @@ let write_csv_header (csv_cpu, csv_mem, csv_block, csv_net) block_in_bytes =
695b7d
 (* Write summary data to CSV file. *)
695b7d
 let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
695b7d
                (csv_cpu, csv_mem, csv_block, csv_net)
695b7d
+               block_in_bytes
695b7d
                { rd_doms = doms;
695b7d
                  rd_printable_time = printable_time;
695b7d
                  rd_nr_pcpus = nr_pcpus; rd_total_cpu = total_cpu;
695b7d
@@ -104,10 +105,15 @@ let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
695b7d
         (if csv_mem then [
695b7d
             Int64.to_string rd.rd_mem_bytes; Int64.to_string rd.rd_mem_percent
695b7d
          ] else []) @
695b7d
-	(if csv_block then [
695b7d
-	   string_of_int64_option rd.rd_block_rd_info;
695b7d
-	   string_of_int64_option rd.rd_block_wr_info;
695b7d
-	 ] else []) @
695b7d
+	(if csv_block then
695b7d
+           if block_in_bytes then [
695b7d
+	     string_of_int64_option rd.rd_block_rd_bytes;
695b7d
+	     string_of_int64_option rd.rd_block_wr_bytes;
695b7d
+	   ] else [
695b7d
+	     string_of_int64_option rd.rd_block_rd_reqs;
695b7d
+	     string_of_int64_option rd.rd_block_wr_reqs;
695b7d
+           ]
695b7d
+         else []) @
695b7d
 	(if csv_net then [
695b7d
 	   string_of_int64_option rd.rd_net_rx_bytes;
695b7d
 	   string_of_int64_option rd.rd_net_tx_bytes;
695b7d
diff --git a/src/csv_output.mli b/src/csv_output.mli
695b7d
index d5eab0f..4064be5 100644
695b7d
--- a/src/csv_output.mli
695b7d
+++ b/src/csv_output.mli
695b7d
@@ -24,4 +24,4 @@ val csv_write : (string list -> unit) ref
695b7d
 
695b7d
 val write_csv_header : bool * bool * bool * bool -> bool -> unit
695b7d
 
695b7d
-val append_csv : Types.setup -> bool * bool * bool * bool -> Collect.stats -> unit
695b7d
+val append_csv : Types.setup -> bool * bool * bool * bool -> bool -> Collect.stats -> unit
695b7d
diff --git a/src/redraw.ml b/src/redraw.ml
695b7d
index 9ce889b..0403158 100644
695b7d
--- a/src/redraw.ml
695b7d
+++ b/src/redraw.ml
695b7d
@@ -155,8 +155,12 @@ let redraw display_mode sort_order
695b7d
 	| (name, Active rd) :: doms ->
695b7d
 	   if lineno < lines then (
695b7d
 	     let state = show_state rd.rd_info.D.state in
695b7d
-	     let rd_req = Show.int64_option rd.rd_block_rd_info in
695b7d
-	     let wr_req = Show.int64_option rd.rd_block_wr_info in
695b7d
+	     let rd_info =
695b7d
+               if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
695b7d
+               else Show.int64_option rd.rd_block_rd_reqs in
695b7d
+	     let wr_info =
695b7d
+               if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
695b7d
+               else Show.int64_option rd.rd_block_wr_reqs in
695b7d
 	     let rx_bytes = Show.int64_option rd.rd_net_rx_bytes in
695b7d
 	     let tx_bytes = Show.int64_option rd.rd_net_tx_bytes in
695b7d
 	     let percent_cpu = Show.percent rd.rd_percent_cpu in
695b7d
@@ -166,7 +170,7 @@ let redraw display_mode sort_order
695b7d
 
695b7d
 	     let line =
695b7d
                sprintf "%5d %c %s %s %s %s %s %s %s %s"
695b7d
-		       rd.rd_domid state rd_req wr_req rx_bytes tx_bytes
695b7d
+		       rd.rd_domid state rd_info wr_info rx_bytes tx_bytes
695b7d
 		       percent_cpu percent_mem time name in
695b7d
 	     let line = pad cols line in
695b7d
 	     mvaddstr lineno 0 line;
695b7d
diff --git a/src/stream_output.ml b/src/stream_output.ml
695b7d
index bf7b114..c3af99b 100644
695b7d
--- a/src/stream_output.ml
695b7d
+++ b/src/stream_output.ml
695b7d
@@ -59,10 +59,16 @@ let append_stream (_, _, _, _, _, node_info, hostname, _) (* setup *)
695b7d
   let dump_domain = fun name rd
695b7d
   -> begin
695b7d
     let state = Screen.show_state rd.rd_info.D.state in
695b7d
-         let rd_req = if rd.rd_block_rd_info = None then "   0"
695b7d
-                      else Show.int64_option rd.rd_block_rd_info in
695b7d
-         let wr_req = if rd.rd_block_wr_info = None then "   0"
695b7d
-                      else Show.int64_option rd.rd_block_wr_info in
695b7d
+         let rd_req =
695b7d
+           if rd.rd_block_rd_reqs = None then "   0"
695b7d
+           else
695b7d
+             if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
695b7d
+             else Show.int64_option rd.rd_block_rd_reqs in
695b7d
+         let wr_req =
695b7d
+           if rd.rd_block_wr_reqs = None then "   0"
695b7d
+           else
695b7d
+             if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
695b7d
+             else Show.int64_option rd.rd_block_wr_reqs in
695b7d
     let rx_bytes = if rd.rd_net_rx_bytes = None then "   0"
695b7d
     else Show.int64_option rd.rd_net_rx_bytes in
695b7d
     let tx_bytes = if rd.rd_net_tx_bytes = None then "   0"
695b7d
diff --git a/src/top.ml b/src/top.ml
695b7d
index 204f3b6..e2a93d6 100644
695b7d
--- a/src/top.ml
695b7d
+++ b/src/top.ml
695b7d
@@ -319,7 +319,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
695b7d
 
695b7d
   while not !quit do
695b7d
     (* Collect stats. *)
695b7d
-    let state = collect setup !block_in_bytes in
695b7d
+    let state = collect setup in
695b7d
     let pcpu_display =
695b7d
       if !display_mode = PCPUDisplay then Some (collect_pcpu state)
695b7d
       else None in
695b7d
@@ -331,7 +331,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
695b7d
 
695b7d
     (* Update CSV file. *)
695b7d
     if csv_enabled then
695b7d
-      Csv_output.append_csv setup csv_flags state;
695b7d
+      Csv_output.append_csv setup csv_flags !block_in_bytes state;
695b7d
 
695b7d
     (* Append to stream output file. *)
695b7d
     if stream_mode then
695b7d
-- 
271612
2.31.1
695b7d