Skip to content

Commit 87c9741

Browse files
Saurabh Sengarliuw
authored andcommitted
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: Saurabh Sengar <[email protected]> Reviewed-by: Nuno Das Neves <[email protected]> Reviewed-by: Srivatsa S. Bhat (Microsoft) <[email protected]> Reviewed-by: Dexuan Cui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]> Message-ID: <[email protected]>
1 parent 47ac09b commit 87c9741

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,13 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
13061306
return IRQ_HANDLED;
13071307
}
13081308

1309+
static void vmbus_percpu_work(struct work_struct *work)
1310+
{
1311+
unsigned int cpu = smp_processor_id();
1312+
1313+
hv_synic_init(cpu);
1314+
}
1315+
13091316
/*
13101317
* vmbus_bus_init -Main vmbus driver initialization routine.
13111318
*
@@ -1316,7 +1323,8 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
13161323
*/
13171324
static int vmbus_bus_init(void)
13181325
{
1319-
int ret;
1326+
int ret, cpu;
1327+
struct work_struct __percpu *works;
13201328

13211329
ret = hv_init();
13221330
if (ret != 0) {
@@ -1355,12 +1363,32 @@ static int vmbus_bus_init(void)
13551363
if (ret)
13561364
goto err_alloc;
13571365

1366+
works = alloc_percpu(struct work_struct);
1367+
if (!works) {
1368+
ret = -ENOMEM;
1369+
goto err_alloc;
1370+
}
1371+
13581372
/*
13591373
* Initialize the per-cpu interrupt state and stimer state.
13601374
* Then connect to the host.
13611375
*/
1362-
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
1363-
hv_synic_init, hv_synic_cleanup);
1376+
cpus_read_lock();
1377+
for_each_online_cpu(cpu) {
1378+
struct work_struct *work = per_cpu_ptr(works, cpu);
1379+
1380+
INIT_WORK(work, vmbus_percpu_work);
1381+
schedule_work_on(cpu, work);
1382+
}
1383+
1384+
for_each_online_cpu(cpu)
1385+
flush_work(per_cpu_ptr(works, cpu));
1386+
1387+
/* Register the callbacks for possible CPU online/offline'ing */
1388+
ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
1389+
hv_synic_init, hv_synic_cleanup);
1390+
cpus_read_unlock();
1391+
free_percpu(works);
13641392
if (ret < 0)
13651393
goto err_alloc;
13661394
hyperv_cpuhp_online = ret;

0 commit comments

Comments
 (0)