]> 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>
Thu, 16 Dec 2021 19:48:25 +0000 (19:48 +0000)
arch/x86/kernel/smpboot.c
kernel/cpu.c

index bed2b606211b684a7ff88cd839c39d4bfbc3180b..060fdc4db8b0d96fb6c7d433662f970f7fafb07e 100644 (file)
@@ -1332,6 +1332,8 @@ 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;
@@ -1342,24 +1344,24 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
                if (ret)
                        return ret;
        }
-
+       t[3] = get_cycles();
        ret = do_wait_cpu_initialized(cpu);
        if (ret)
                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 9979f670501b0a0f1b06d65c40996a68e53c272c..583a2ec25efa2a253f1d1d952b65f802ba8c3cc5 100644 (file)
@@ -554,12 +554,16 @@ static int cpuhp_kick_ap(struct cpuhp_cpu_state *st, enum cpuhp_state target)
        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;
 
@@ -599,6 +603,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);
 }
 
@@ -1333,6 +1338,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);
@@ -1349,6 +1355,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);
                /*
@@ -1358,7 +1365,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
@@ -1366,6 +1373,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();