[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH v2] top '-c' switch to enable output of SMP cpu lines.
From:       Jonathan Sambrook <jonathan () hmmn ! org>
Date:       2022-01-27 12:08:29
Message-ID: a70ead03-663f-3063-284b-127ae724533e () hmmn ! org
[Download RAW message or body]

 From 2c2819a75aca64ef67efde7c3c5c4ede76d23957 Mon Sep 17 00:00:00 2001
From: Jonathan Sambrook <jonathan@hmmn.org>
Date: Thu, 27 Jan 2022 11:37:10 +0000
Subject: [PATCH] Add '-c' switch to enable output of SMP cpu lines.

This allows access to SMP cpu lines for batch output, as well as
displaying SMP info in interactive mode without having to press '1'.

My motivation here is to be able to access the SMP information when
graphing BusyBox top batch output with topplot
(see: https://gitlab.com/eBardie/topplot).
---
  procps/top.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/procps/top.c b/procps/top.c
index 804d6f258..32d08737b 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -224,7 +224,8 @@ enum {
  	OPT_b = (1 << 2),
  	OPT_H = (1 << 3),
  	OPT_m = (1 << 4),
-	OPT_EOF = (1 << 5), /* pseudo: "we saw EOF in stdin" */
+	OPT_c = (1 << 5),
+	OPT_EOF = (1 << 6), /* pseudo: "we saw EOF in stdin" */
  };
  #define OPT_BATCH_MODE (option_mask32 & OPT_b)

@@ -1078,6 +1079,9 @@ static unsigned handle_input(unsigned scan_mask, 
duration_t interval)
  //usage:   "\n""Options:"
  //usage:	)
  //usage:   "\n""	-b	Batch mode"
+//usage:	IF_FEATURE_TOP_SMP_CPU(
+//usage:   "\n""	-c	CPU info for each core"
+//usage:	)
  //usage:   "\n""	-n N	Exit after N iterations"
  //usage:   "\n""	-d SEC	Delay between updates"
  //usage:	IF_FEATURE_TOPMEM(
@@ -1120,8 +1124,8 @@ int top_main(int argc UNUSED_PARAM, char **argv)

  	/* all args are options; -n NUM */
  	make_all_argv_opts(argv); /* options can be specified w/o dash */
-	col = getopt32(argv, "d:n:bHm", &str_interval, &str_iterations);
-	/* NB: -m and -H are accepted even if not configured */
+	col = getopt32(argv, "d:n:bHmc", &str_interval, &str_iterations);
+	/* NB: -c, -m, and -H are accepted even if not configured */
  #if ENABLE_FEATURE_TOPMEM
  	if (col & OPT_m) /* -m (busybox specific) */
  		scan_mask = TOPMEM_MASK;
@@ -1149,6 +1153,13 @@ int top_main(int argc UNUSED_PARAM, char **argv)
  	/* change to /proc */
  	xchdir("/proc");

+#if ENABLE_FEATURE_TOP_SMP_CPU
+	if (col & OPT_c) {
+		cpu_jif = cpu_prev_jif = NULL;
+		smp_cpu_info = ~0;
+	}
+#endif
+
  #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
  	sort_function[0] = pcpu_sort;
  	sort_function[1] = mem_sort;
-- 
2.34.1


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic