Commit 87c9741a authored by Saurabh Sengar's avatar Saurabh Sengar Committed by Wei Liu

Drivers: hv: vmbus: Optimize boot time by concurrent execution of hv_synic_init()

Currently on a very large system with 1780 CPUs, hv_acpi_init() takes
around 3 seconds to complete. This is because of sequential synic
initialization for each CPU performed by hv_synic_init().

Schedule these tasks parallelly so that each CPU executes hv_synic_init()
in parallel to take full advantage of multiple CPUs.

This solution saves around 2 seconds of boot time on a 1780 CPU system,
which is around 66% improvement in the existing logic.
Signed-off-by: default avatarSaurabh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: default avatarNuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: default avatarSrivatsa S. Bhat (Microsoft) <srivatsa@csail.mit.edu>
Reviewed-by: default avatarDexuan Cui <decui@microsoft.com>
Link: https://lore.kernel.org/r/1722488136-6223-1-git-send-email-ssengar@linux.microsoft.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
Message-ID: <1722488136-6223-1-git-send-email-ssengar@linux.microsoft.com>
parent 47ac09b9
......@@ -1306,6 +1306,13 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
static void vmbus_percpu_work(struct work_struct *work)
{
unsigned int cpu = smp_processor_id();
hv_synic_init(cpu);
}
/*
* vmbus_bus_init -Main vmbus driver initialization routine.
*
......@@ -1316,7 +1323,8 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
*/
static int vmbus_bus_init(void)
{
int ret;
int ret, cpu;
struct work_struct __percpu *works;
ret = hv_init();
if (ret != 0) {
......@@ -1355,12 +1363,32 @@ static int vmbus_bus_init(void)
if (ret)
goto err_alloc;
works = alloc_percpu(struct work_struct);
if (!works) {
ret = -ENOMEM;
goto err_alloc;
}
/*
* Initialize the per-cpu interrupt state and stimer state.
* Then connect to the host.
*/
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
hv_synic_init, hv_synic_cleanup);
cpus_read_lock();
for_each_online_cpu(cpu) {
struct work_struct *work = per_cpu_ptr(works, cpu);
INIT_WORK(work, vmbus_percpu_work);
schedule_work_on(cpu, work);
}
for_each_online_cpu(cpu)
flush_work(per_cpu_ptr(works, cpu));
/* Register the callbacks for possible CPU online/offline'ing */
ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
hv_synic_init, hv_synic_cleanup);
cpus_read_unlock();
free_percpu(works);
if (ret < 0)
goto err_alloc;
hyperv_cpuhp_online = ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment