]> www.infradead.org Git - users/hch/block.git/commitdiff
tools/power turbostat: Move debug prints from stdout to stderr
authorPatryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Wed, 10 Jul 2024 09:34:38 +0000 (11:34 +0200)
committerLen Brown <len.brown@intel.com>
Fri, 26 Jul 2024 17:40:20 +0000 (13:40 -0400)
This leaves the stdout cleaner, having only counter data. It makes it
easier for programs to parse the output of turbostat, for example
selftests.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.c

index be345a4bbe966398fe6a29f27680201474d6af0d..cccd9f4311a08e1bc71af45510fd98cb3444f545 100644 (file)
@@ -1984,6 +1984,7 @@ void help(void)
                "  -c, --cpu    cpu-set limit output to summary plus cpu-set:\n"
                "                 {core | package | j,k,l..m,n-p }\n"
                "  -d, --debug  displays usec, Time_Of_Day_Seconds and more debugging\n"
+               "               debug messages are printed to stderr\n"
                "  -D, --Dump   displays the raw counter values\n"
                "  -e, --enable [all | column]\n"
                "               shows all or the specified disabled column\n"
@@ -8262,7 +8263,7 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo)
                        pinfo->scale = perf_scale;
 
                        if (debug)
-                               printf("Add perf/%s/%s cpu%d: %d\n",
+                               fprintf(stderr, "Add perf/%s/%s cpu%d: %d\n",
                                       pinfo->device, pinfo->event, cpu, pinfo->fd_perf_per_domain[next_domain]);
                }
 
@@ -8422,7 +8423,7 @@ struct msr_counter *find_msrp_by_name(struct msr_counter *head, char *name)
 
        for (mp = head; mp; mp = mp->next) {
                if (debug)
-                       printf("%s: %s %s\n", __func__, name, mp->name);
+                       fprintf(stderr, "%s: %s %s\n", __func__, name, mp->name);
                if (!strncmp(name, mp->name, strlen(mp->name)))
                        return mp;
        }
@@ -8439,8 +8440,8 @@ int add_counter(unsigned int msr_num, char *path, char *name,
                errx(1, "Requested MSR counter 0x%x, but in --no-msr mode", msr_num);
 
        if (debug)
-               printf("%s(msr%d, %s, %s, width%d, scope%d, type%d, format%d, flags%x, id%d)\n", __func__, msr_num,
-                      path, name, width, scope, type, format, flags, id);
+               fprintf(stderr, "%s(msr%d, %s, %s, width%d, scope%d, type%d, format%d, flags%x, id%d)\n",
+                       __func__, msr_num, path, name, width, scope, type, format, flags, id);
 
        switch (scope) {
 
@@ -8448,7 +8449,7 @@ int add_counter(unsigned int msr_num, char *path, char *name,
                msrp = find_msrp_by_name(sys.tp, name);
                if (msrp) {
                        if (debug)
-                               printf("%s: %s FOUND\n", __func__, name);
+                               fprintf(stderr, "%s: %s FOUND\n", __func__, name);
                        break;
                }
                if (sys.added_thread_counters++ >= MAX_ADDED_THREAD_COUNTERS) {
@@ -8460,7 +8461,7 @@ int add_counter(unsigned int msr_num, char *path, char *name,
                msrp = find_msrp_by_name(sys.cp, name);
                if (msrp) {
                        if (debug)
-                               printf("%s: %s FOUND\n", __func__, name);
+                               fprintf(stderr, "%s: %s FOUND\n", __func__, name);
                        break;
                }
                if (sys.added_core_counters++ >= MAX_ADDED_CORE_COUNTERS) {
@@ -8472,7 +8473,7 @@ int add_counter(unsigned int msr_num, char *path, char *name,
                msrp = find_msrp_by_name(sys.pp, name);
                if (msrp) {
                        if (debug)
-                               printf("%s: %s FOUND\n", __func__, name);
+                               fprintf(stderr, "%s: %s FOUND\n", __func__, name);
                        break;
                }
                if (sys.added_package_counters++ >= MAX_ADDED_PACKAGE_COUNTERS) {
@@ -8617,7 +8618,7 @@ int add_perf_counter(const char *perf_device, const char *perf_event, const char
 
        // FIXME: we might not have debug here yet
        if (debug)
-               printf("%s: %s/%s, name: %s, scope%d\n",
+               fprintf(stderr, "%s: %s/%s, name: %s, scope%d\n",
                       __func__, pinfo->device, pinfo->event, pinfo->name, pinfo->scope);
 
        return 0;