platform/x86/intel/ifs: Trace on all HT threads when executing a test
authorAshok Raj <ashok.raj@intel.com>
Thu, 25 Jan 2024 08:22:51 +0000 (00:22 -0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 31 Jan 2024 09:57:23 +0000 (11:57 +0200)
Enable the trace function on all HT threads.  Currently, the trace is
called from some arbitrary CPU where the test was invoked.

This change gives visibility to the exact errors as seen by each
participating HT threads, and not just what was seen from the primary
thread.

Sample output below.

#           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
#              | |         |   |||||     |         |
     migration/0-18      [000] d..1. 527287.084668: start: 0000, stop: 007f, status: 0000000000007f80
   migration/128-785     [128] d..1. 527287.084669: start: 0000, stop: 007f, status: 0000000000007f80

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20240125082254.424859-3-ashok.raj@intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/ifs/runtest.c
include/trace/events/intel_ifs.h

index 13ecd55c66680339af31b10484cf1929041f0a0e..c8352ffb919562c5dd932191fd81c46fa8fdbf96 100644 (file)
 /* Max retries on the same chunk */
 #define MAX_IFS_RETRIES  5
 
+struct run_params {
+       struct ifs_data *ifsd;
+       union ifs_scan *activate;
+       union ifs_status status;
+};
+
 /*
  * Number of TSC cycles that a logical CPU will wait for the other
  * logical CPU on the core in the WRMSR(ACTIVATE_SCAN).
@@ -140,10 +146,22 @@ static bool can_restart(union ifs_status status)
  */
 static int doscan(void *data)
 {
-       int cpu = smp_processor_id();
-       u64 *msrs = data;
+       int cpu = smp_processor_id(), start, stop;
+       struct run_params *params = data;
+       union ifs_status status;
+       struct ifs_data *ifsd;
        int first;
 
+       ifsd = params->ifsd;
+
+       if (ifsd->generation) {
+               start = params->activate->gen2.start;
+               stop = params->activate->gen2.stop;
+       } else {
+               start = params->activate->gen0.start;
+               stop = params->activate->gen0.stop;
+       }
+
        /* Only the first logical CPU on a core reports result */
        first = cpumask_first(cpu_smt_mask(cpu));
 
@@ -155,12 +173,14 @@ static int doscan(void *data)
         * take up to 200 milliseconds (in the case where all chunks
         * are processed in a single pass) before it retires.
         */
-       wrmsrl(MSR_ACTIVATE_SCAN, msrs[0]);
+       wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data);
+       rdmsrl(MSR_SCAN_STATUS, status.data);
 
-       if (cpu == first) {
-               /* Pass back the result of the scan */
-               rdmsrl(MSR_SCAN_STATUS, msrs[1]);
-       }
+       trace_ifs_status(start, stop, status.data);
+
+       /* Pass back the result of the scan */
+       if (cpu == first)
+               params->status = status;
 
        return 0;
 }
@@ -179,7 +199,7 @@ static void ifs_test_core(int cpu, struct device *dev)
        struct ifs_data *ifsd;
        int to_start, to_stop;
        int status_chunk;
-       u64 msrvals[2];
+       struct run_params params;
        int retries;
 
        ifsd = ifs_get_data(dev);
@@ -190,6 +210,8 @@ static void ifs_test_core(int cpu, struct device *dev)
        to_start = 0;
        to_stop = ifsd->valid_chunks - 1;
 
+       params.ifsd = ifs_get_data(dev);
+
        if (ifsd->generation) {
                activate.gen2.start = to_start;
                activate.gen2.stop = to_stop;
@@ -207,12 +229,10 @@ static void ifs_test_core(int cpu, struct device *dev)
                        break;
                }
 
-               msrvals[0] = activate.data;
-               stop_core_cpuslocked(cpu, doscan, msrvals);
-
-               status.data = msrvals[1];
+               params.activate = &activate;
+               stop_core_cpuslocked(cpu, doscan, &params);
 
-               trace_ifs_status(cpu, to_start, to_stop, status.data);
+               status = params.status;
 
                /* Some cases can be retried, give up for others */
                if (!can_restart(status))
index af0af3f1d9b7c081fb61ab582482302094409ff3..8462dfb7a0203ae3673ad2122f7f0cdd3fbf3ee8 100644 (file)
 
 TRACE_EVENT(ifs_status,
 
-       TP_PROTO(int cpu, int start, int stop, u64 status),
+       TP_PROTO(int start, int stop, u64 status),
 
-       TP_ARGS(cpu, start, stop, status),
+       TP_ARGS(start, stop, status),
 
        TP_STRUCT__entry(
                __field(        u64,    status  )
-               __field(        int,    cpu     )
                __field(        u16,    start   )
                __field(        u16,    stop    )
        ),
 
        TP_fast_assign(
-               __entry->cpu    = cpu;
                __entry->start  = start;
                __entry->stop   = stop;
                __entry->status = status;
        ),
 
-       TP_printk("cpu: %d, start: %.4x, stop: %.4x, status: %.16llx",
-               __entry->cpu,
+       TP_printk("start: %.4x, stop: %.4x, status: %.16llx",
                __entry->start,
                __entry->stop,
                __entry->status)