From nobody Sat Feb 7 20:39:35 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D35E13D511; Thu, 1 Aug 2024 04:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722488143; cv=none; b=K+7y8CJjYiyjIzzJVcbk8k5O4gceumU6yi8k0aCB3CmIfQF3FL4MbG2SJ15h/fxO3rWwgXMvbJzHU1xHYaoFkBvfT/qsimkFPYURO+Z135iwEbQO0OuhNblmUuBo1KS1UQojIveLs56VG5eBIlFcCpVHEvjxSFX7XPx1m01RDq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722488143; c=relaxed/simple; bh=97NBC7ZpgRbtyaCYYGMlXFTaIdrjUOyDg1PD9Qk/1DQ=; h=From:To:Cc:Subject:Date:Message-Id; b=tgaVYW1tOffHaC7tNrv2OCKIp6q31Ai1TXUNqUVA2XrXmA+KAW9E0mm+VsUvPkocW1uo/a4zOQHLQtXQmUFY43pzMokA1nqbn360ZmJJ+Y58N6n+j0j4yPH/l4TwO+epUEbcBiwxC4hsjiMEN+BceKpq1AQrBgZeCo66lYsaYvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=U9rrZop6; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="U9rrZop6" Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id AEF1920B7165; Wed, 31 Jul 2024 21:55:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AEF1920B7165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1722488141; bh=pj8ZxHjO8beellSxC17OnhVfsUVVIIR4qH190zx6V3U=; h=From:To:Cc:Subject:Date:From; b=U9rrZop62Py07uugr1lypzCy3CKg0Nh4Qbkd3VIRE3LK1FMoHkyRvczGl0wSn61F2 QqTlMb9SYOVmEyo9Esn0LOKk43WNmsjtWuhiDOCYqKEopbpKHy58bM2GDRwYuguD4V iLTLwCKtc4XPaKP0iu348Rj2KUw0a/M/U9oEu4LA= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ssengar@microsoft.com, srivatsa@csail.mit.edu Subject: [PATCH v3] Drivers: hv: vmbus: Optimize boot time by concurrent execution of hv_synic_init() Date: Wed, 31 Jul 2024 21:55:36 -0700 Message-Id: <1722488136-6223-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Nuno Das Neves Reviewed-by: Srivatsa S. Bhat (Microsoft) Reviewed-by: Dexuan Cui --- [V3] - Modify comment, removing hotplug mention - Added Reviewed-by [V2] - used cpuhp_setup_state_nocalls_cpuslocked instead of internal function - improve commit message and subject - Added a comment for cpu hotplug callback drivers/hv/vmbus_drv.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index c857dc3975be..7242c4920427 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1306,6 +1306,13 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *d= ev_id) return IRQ_HANDLED; } =20 +static void vmbus_percpu_work(struct work_struct *work) +{ + unsigned int cpu =3D 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 *de= v_id) */ static int vmbus_bus_init(void) { - int ret; + int ret, cpu; + struct work_struct __percpu *works; =20 ret =3D hv_init(); if (ret !=3D 0) { @@ -1355,12 +1363,32 @@ static int vmbus_bus_init(void) if (ret) goto err_alloc; =20 + works =3D alloc_percpu(struct work_struct); + if (!works) { + ret =3D -ENOMEM; + goto err_alloc; + } + /* * Initialize the per-cpu interrupt state and stimer state. * Then connect to the host. */ - ret =3D 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 =3D 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 =3D 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 =3D ret; --=20 2.43.0