]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
timing debug
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 15 Dec 2021 08:11:49 +0000 (08:11 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Sat, 4 Feb 2023 15:33:36 +0000 (15:33 +0000)
arch/x86/kernel/smpboot.c
kernel/cpu.c

index 638dc63bc1d115bca6821e613aaa0f9de9a493b0..f8cdd85e239f871208814db74aa802bcd06aa407 100644 (file)
@@ -1353,10 +1353,13 @@ unreg_nmi:
        return ret;
 }
 
+extern cycles_t cpu_up_times[100];
+#define t cpu_up_times
 int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int ret;
 
+       t[3] = get_cycles();
        /* If parallel AP bringup isn't enabled, perform the first steps now. */
        if (!do_parallel_bringup) {
                ret = do_cpu_up(cpu, tidle);
@@ -1368,19 +1371,21 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
                        return ret;
        }
 
+       t[4] = get_cycles();
+
        ret = do_wait_cpu_callin(cpu);
        if (ret)
                return ret;
-
+       t[5] = get_cycles();
        ret = do_wait_cpu_online(cpu);
-
+       t[6] = get_cycles();
        if (x86_platform.legacy.warm_reset) {
                /*
                 * Cleanup possible dangling ends...
                 */
                smpboot_restore_warm_reset_vector();
        }
-
+       t[7] = get_cycles();
        return ret;
 }
 
index 305b2b109a43d4009e5e800634138fabbdf18c3c..46d73c55c8d431c7bb4ac761be3182f00fc4937a 100644 (file)
@@ -558,12 +558,16 @@ static int cpuhp_kick_ap(int cpu, struct cpuhp_cpu_state *st,
        return ret;
 }
 
+cycles_t cpu_up_times[100];
+#define t cpu_up_times
+
 static int bringup_wait_for_ap(unsigned int cpu)
 {
        struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 
        /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */
        wait_for_ap_thread(st, true);
+       t[9] = get_cycles();
        if (WARN_ON_ONCE((!cpu_online(cpu))))
                return -ECANCELED;
 
@@ -609,6 +613,7 @@ static int bringup_cpu(unsigned int cpu)
        irq_unlock_sparse();
        if (ret)
                return ret;
+       t[8] = get_cycles();
        return bringup_wait_for_ap(cpu);
 }
 
@@ -1376,6 +1381,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
        if (st->state >= target)
                goto out;
 
+       t[0] = get_cycles();
        if (st->state == CPUHP_OFFLINE) {
                /* Let it fail before we try to bring the cpu up */
                idle = idle_thread_get(cpu);
@@ -1392,6 +1398,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
         * If the current CPU state is in the range of the AP hotplug thread,
         * then we need to kick the thread once more.
         */
+       t[1] = get_cycles();
        if (st->state > CPUHP_BRINGUP_CPU) {
                ret = cpuhp_kick_ap_work(cpu);
                /*
@@ -1401,7 +1408,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
                if (ret)
                        goto out;
        }
-
+       t[2] = get_cycles();
        /*
         * Try to reach the target state. We max out on the BP at
         * CPUHP_BRINGUP_CPU. After that the AP hotplug thread is
@@ -1409,6 +1416,11 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
         */
        target = min((int)target, CPUHP_BRINGUP_CPU);
        ret = cpuhp_up_callbacks(cpu, st, target);
+       t[10] = get_cycles();
+
+       printk("CPU %d to %d/%s in %lld %lld %lld %lld . %lld %lld %lld %lld . %lld %lld\n", cpu, target,
+              cpuhp_hp_states[target].name, t[1] - t[0], t[2] - t[1], t[3] - t[2], t[4] - t[3],
+              t[5] - t[4], t[6] - t[5], t[7] - t[6], t[8] - t[7], t[9] - t[8], t[10] - t[9]);
 out:
        cpus_write_unlock();
        arch_smt_update();