From nobody Thu Apr 9 09:47:31 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6F6E40F8FC for ; Mon, 9 Mar 2026 19:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084675; cv=none; b=Qv5/QB4HOqmeB21Jkc/g87Eq9wyrPJ9qvEp0xRVSxUrDkaniSUZBOeVS4+xHxe6UJeewNKzyZuj4MgOE3uVcFuKRMh4lYZqgPCUuSPIZjfYCnc8qqFDCvHZVdWznqsPcpyp7MxjMNGknMtUukZgASA7dOD2CnxiZaNMFdFBvL0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084675; c=relaxed/simple; bh=zqSouceZtFC5TpkGpy+KiFus4h62hOvNb+G9ZODiRYE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KZUTEWyC2ji4avkh6e5m1nwuK43M1mz8AEsqfOCVrEoSugUeGVgsmLU405MiT8lEXzFaPesguBTwdRKjfcNsr64jRL7x+gEBL1Ndy8AgQ2ohVgTwFYF2g6NgRkOa7T1PQ45A8CMW6QcR429CjkeAr7UEjqSmTHPm8jYQ6ts0HrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XUgzOMyp; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XUgzOMyp" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2ae669a8ff1so327515335ad.3 for ; Mon, 09 Mar 2026 12:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773084674; x=1773689474; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=wblNA6bj3f7w06PD/nTLmV/SuffW2mSGdWVBXF9Y8dI=; b=XUgzOMyp9Y1oN6fXRl22p6JHmy+Xk/0x9JJMz5aNgNrg+0pZAzkdJhdZsLswx6n5JD ciR4DVH6f4KR6mMlag6337uQsGjHDcGmcEtv/GvO9B9yvCj5MrUS6JDPZ37lI0Fkmmir wX8bMRkP4t+3Il56No5JdzJMxuKv5MWXfqu4R8t53MJ5f/pESOzRwkfvTabK7WdYBu1d WcKbWcr4u+FHYuLs/zV6DMOOAuWOlYx5l6lw/5+vLwLnpYT/JUJ/IETPlA/NQStMviGE JbEHh7ZDbsx/TSGttOlv/lUtV8hPCgo6sblYdZDRBWMMAIc+EBLPle/VpeqylZr7jlmq RVmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773084674; x=1773689474; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wblNA6bj3f7w06PD/nTLmV/SuffW2mSGdWVBXF9Y8dI=; b=pzSyZefG/bJjmN85AI8GanysjvcI8VUOqC7fQ5xAVnSG9hKNiiH5xFRilds2+yQ5re V6oYh20fLny6xdTyEq1Udv7+SP8KkCdBueES8k/U3Z/JqMxXZrpSLmdpJPQRP0ZWHR3u va+9+YvKTbqyxa10j9iTvwzgNm2vEYXJ6cNXHmf78r1kAfKZZtFQWRoUPrSET1CVNRRt vsnCPqEnSp/s1ztkTp1lGN+JzoyHpkmdWCUQ7OUDOLaSNsFw8gzvIFin143X2SFBKrkx CWeHMQqtAZJSsZkIcICZ0Tmsv2GSBy1mnCGr+PQVA/6r6Z8yhMGvyX6EMGkKa/B5K0Y0 PuVA== X-Forwarded-Encrypted: i=1; AJvYcCX6yalgKm2NM1GGU/GaObfom4A03e+nmO0EFVmvv0g9c9NFQ/cXplIeqxdQVvJ6skAouICrHqjeLnikTwM=@vger.kernel.org X-Gm-Message-State: AOJu0YxZVqBieYJpseWBaLFhSJitkkng7+Ba0hZvunumaEIBXsNTM2oO QsJ5TdWIS+sk2gbVj0Le0XGOdzTnxzmrvgI/HDzEaee/2jMjMkPynDlhU3Ygz2kKq/1RB4mXp1z 1+8Wd+w== X-Received: from plcy10.prod.google.com ([2002:a17:903:10a:b0:2ae:45a4:ca9f]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2b06:b0:2ae:50ec:fa2e with SMTP id d9443c01a7336-2ae823a1f61mr121594565ad.21.1773084674028; Mon, 09 Mar 2026 12:31:14 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 9 Mar 2026 12:30:57 -0700 In-Reply-To: <20260309193059.2244645-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309193059.2244645-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309193059.2244645-2-seanjc@google.com> Subject: [RFC PATCH 1/3] srcu: Declare exported symbols before including srcu{tiny,tree}.h From: Sean Christopherson To: Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , Paolo Bonzini Cc: rcu@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Nikita Kalyazin , Keir Fraser Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the declarations of call_srcu(), cleanup_srcu_struct(), and synchronize_srcu() above the inclusion of the implementation specific SRCU header so that tiny SRCU can provide inline wrappers, e.g. for expedited versions, without needing to re-declare synchronize_srcu() and call_srcu(). Opportunsitically use rcu_callback_t in the call_srcu() declaration instead of an open coded equivalent (all implementations already use rcu_callback_t). No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/srcu.h | 10 +++++----- include/linux/srcutiny.h | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/linux/srcu.h b/include/linux/srcu.h index bb44a0bd7696..1cbc37e3b59c 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -79,6 +79,11 @@ int init_srcu_struct_fast_updown(struct srcu_struct *ssp= ); // instead of smp_mb(). void __srcu_read_unlock(struct srcu_struct *ssp, int idx) __releases_share= d(ssp); =20 +void call_srcu(struct srcu_struct *ssp, struct rcu_head *head, + rcu_callback_t func); +void cleanup_srcu_struct(struct srcu_struct *ssp); +void synchronize_srcu(struct srcu_struct *ssp); + #ifdef CONFIG_TINY_SRCU #include #elif defined(CONFIG_TREE_SRCU) @@ -87,11 +92,6 @@ void __srcu_read_unlock(struct srcu_struct *ssp, int idx= ) __releases_shared(ssp) #error "Unknown SRCU implementation specified to kernel configuration" #endif =20 -void call_srcu(struct srcu_struct *ssp, struct rcu_head *head, - void (*func)(struct rcu_head *head)); -void cleanup_srcu_struct(struct srcu_struct *ssp); -void synchronize_srcu(struct srcu_struct *ssp); - #define SRCU_GET_STATE_COMPLETED 0x1 =20 /** diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h index dec7cbe015aa..4976536e8b28 100644 --- a/include/linux/srcutiny.h +++ b/include/linux/srcutiny.h @@ -64,8 +64,6 @@ struct srcu_usage { }; #define init_srcu_struct_fast_updown init_srcu_struct #endif // #ifndef CONFIG_DEBUG_LOCK_ALLOC =20 -void synchronize_srcu(struct srcu_struct *ssp); - /* * Counts the new reader in the appropriate per-CPU element of the * srcu_struct. Can be invoked from irq/bh handlers, but the matching --=20 2.53.0.473.g4a7958ca14-goog From nobody Thu Apr 9 09:47:31 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DB5A410D1A for ; Mon, 9 Mar 2026 19:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084677; cv=none; b=GWNoe31/LSwIez1Fy1gfe1gp1hHXseOkCVl7Pil0S74dvtaRvnLzLLF05I6k4znN/xPLNnlwJpNP5z9QwSMIiOAMfpI4lgGkuA3FwsG3k1xWFodW09HXdT1bmH0zbH2hHTJk5IZidONe3S+DS/Rrzr2uKlCJhQy1+PEsyCZvXh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084677; c=relaxed/simple; bh=mUKw0kl0f4KxNAzKhr8UyqO0R7jCXXC379eGBhra2Q8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=psQY8NaO5/VKAWL2RQ0Gt+AaLaP3knZML5hu+VSXbLSlFzack+jynMMgVMti/2HPuH3D54XlAQAkySfB4uvW5HwY9+s2BD/bgWwVOTS2GxgtMhp6CkiZ7iS+mS/9GEEgNKnLEPcdqL3TAyISg38QfyV3PxHbQE/Qcvp5vFYR4sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zYVzPMLx; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zYVzPMLx" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82988b04c5cso11742191b3a.3 for ; Mon, 09 Mar 2026 12:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773084676; x=1773689476; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=1G09RtyABu4hfI9DMnNr2bllkac+dmhEIEcvARTdDJk=; b=zYVzPMLxyfgWNWIGVx+FhZzYjdW6KlRPal5FWU5nVKX9Ekz020jycy/N8L4pWnNwDv tIr8HIwIpIO4PDWBU9CESIhnABTGwOpuVAKEGjcBiO1rlqIOHn0tauHjBU8TShrppBV0 6Vj/daXm88s5hP4OJkotY7xxO6TH75dDN4Xl+7R/pFnCx1STvW+t1kKUI5DAtNpFfVDZ pNZ5xKZgudojvAYZWIuK9bNn4utQO6v/5Uz0saTNC5dwlTzdhaMS+RzudcSybAlMEgPN wzMy0JC3b3V4l7eQqF4rxbCJSQAGiQxRjtmUPxt1h1+U1RIu0+TxKTL/9q0FUB8tHUz7 awRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773084676; x=1773689476; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1G09RtyABu4hfI9DMnNr2bllkac+dmhEIEcvARTdDJk=; b=MUUL/NISRCipl0gTTpvOe81DiGiP+Sa1hQkz8F8zN1KoeI9zyg+8qzwua5KGchbbPD V32w8m4eZ8lVXbSPUASntERWZNxP63v1/VVg1AA8Dxk6hHfvlcqU0OmKtWnNuQB9uEb9 ibJtr7fjNTqzZHRCxmLsIBURtFsgASZizGXjpAcqdUpiHzTXwRCpOx8vPGaXH1SVYaOb 8m42a137gIdj94uSqp7pxXMhLXCKX+v9C/gbWD3ST+WfbYx7TJYNCoqeIg3qaqNsag9d 7C/k2pyGmTxwZlqXZv5BkODmumnS7XAmXJtSEdBv3PrRFUt/db3DaC4jjmwMU0gjGrmq Iwow== X-Forwarded-Encrypted: i=1; AJvYcCWce310XfCwVjHXt4UKs5T+U0vm2j8fDO9BwSn3x7nkBFROb0Rj7EDRjnUvY54A8c8aGmOBWYnDFrAi4F8=@vger.kernel.org X-Gm-Message-State: AOJu0YyI4yhUFVThSSwrO9j+2QeoreErm7UlxSjt1lAdgLz6RN5PmXo5 K4yb2tpB74nxZkYxbanFF25NzVZ1xb1PbvECMckEa5fQWRMg+NfcD8aY/H8KfXCJT3V4Zr5/Tj8 pVmgjKQ== X-Received: from pfog16.prod.google.com ([2002:aa7:8750:0:b0:829:707f:6f3e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1827:b0:827:444a:58e0 with SMTP id d2e1a72fcca58-829a2ea9fd8mr11118741b3a.32.1773084675798; Mon, 09 Mar 2026 12:31:15 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 9 Mar 2026 12:30:58 -0700 In-Reply-To: <20260309193059.2244645-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309193059.2244645-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309193059.2244645-3-seanjc@google.com> Subject: [RFC PATCH 2/3] srcu: Add and export call_srcu_expedited() to avoid transferring grace periods From: Sean Christopherson To: Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , Paolo Bonzini Cc: rcu@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Nikita Kalyazin , Keir Fraser Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add and export an expedited version of call_srcu() so that users of synchronize_srcu_expedited() can avoid "transferring" non-expedited grace periods. In response to userspace changes to guest devices and memory, KVM uses call_srcu() when freeing an object to avoid having to wait for readers to go away, but then often emits a synchronize_srcu_expedited() in a largely unrelated path shortly thereafter (on the same SRCU object). Due to differences in how VMMs manage guest devices, and in the architecture being emulated by userspace, some updates trigger call_srcu() with concurrent readers (i.e. while the VM is active), while others occur without readers, e.g. when configuring devices during a pre-boot setup. For the later case (no concurrent readers), using the vanilla call_srcu() is problematic, as it can kick off a normal grace period (totally fine for freeing the object) and effectively transfer the non-expedited grace period to the upcoming synchronize_srcu_expedited(). For micro-VM use cases with CONFIG_HZ=3D100 kernels, the resulting ~20ms delay on the would-be-expedited sync can increase the boot time of the VM by 15% or more. Link: https://lore.kernel.org/all/a84ddba8-12da-489a-9dd1-ccdf7451a1ba@amaz= on.com Signed-off-by: Sean Christopherson --- include/linux/srcutiny.h | 6 ++++++ include/linux/srcutree.h | 2 ++ kernel/rcu/srcutree.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h index 4976536e8b28..e2fc8c138e6a 100644 --- a/include/linux/srcutiny.h +++ b/include/linux/srcutiny.h @@ -130,6 +130,12 @@ static inline void srcu_barrier(struct srcu_struct *ss= p) synchronize_srcu(ssp); } =20 +static inline void call_srcu_expedited(struct srcu_struct *ssp, struct rcu= _head *rhp, + rcu_callback_t func) +{ + call_srcu(ssp, rhp, func); +} + static inline void srcu_expedite_current(struct srcu_struct *ssp) { } #define srcu_check_read_flavor(ssp, read_flavor) do { } while (0) =20 diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h index 958cb7ef41cb..ed3cbbe7f5ce 100644 --- a/include/linux/srcutree.h +++ b/include/linux/srcutree.h @@ -234,6 +234,8 @@ struct srcu_struct { __DEFINE_SRCU(name, SRCU_READ_FLAVOR_FAST_UPDOWN, static) =20 int __srcu_read_lock(struct srcu_struct *ssp) __acquires_shared(ssp); +void call_srcu_expedited(struct srcu_struct *ssp, struct rcu_head *head, + rcu_callback_t func); void synchronize_srcu_expedited(struct srcu_struct *ssp); void srcu_barrier(struct srcu_struct *ssp); void srcu_expedite_current(struct srcu_struct *ssp); diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index aef8e91ad33e..77076d2a1c57 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1495,6 +1495,13 @@ void call_srcu(struct srcu_struct *ssp, struct rcu_h= ead *rhp, } EXPORT_SYMBOL_GPL(call_srcu); =20 +void call_srcu_expedited(struct srcu_struct *ssp, struct rcu_head *rhp, + rcu_callback_t func) +{ + __call_srcu(ssp, rhp, func, rcu_gp_is_normal()); +} +EXPORT_SYMBOL_GPL(call_srcu_expedited); + /* * Helper function for synchronize_srcu() and synchronize_srcu_expedited(). */ --=20 2.53.0.473.g4a7958ca14-goog From nobody Thu Apr 9 09:47:31 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 839A341161B for ; Mon, 9 Mar 2026 19:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084679; cv=none; b=nwUABOL34bZ6xt5FrhdYkTk26eOEjYwrxi4NGUBYF/bQSZB41dfRbyEpoxBFWXH3KeiV6ms1PPv47ysiiBRfSuXXVqnDWSBOAexpuFJLwpBKXA5KWXSNuQjV5P3oncnXtW8slF/enlKt4VUPAfzbc3cvGiDrxyeMchE4lgitFuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084679; c=relaxed/simple; bh=Nh7tJ/pXL5Y8LgZgxu8ghrpxcPTqp2B/CPbh/N2FO2o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AIxjD4xKkw9V4WsSZhEQND6c2QMfL7A7D1dL5WzXTy5IZz+YO08lAvVKlGSDxWTaTrZ55/bddUyxNr9MC6slCv5zZgBkZZPp28Owtni1jUfSuV+QvB/5vqSvrZSSAR6I6HbY6KwluN6unDIMbo4m1yuZWFBoYV15vYmIKUr6kcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=T8OOh4Xp; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T8OOh4Xp" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-c70dd30025fso44866426a12.2 for ; Mon, 09 Mar 2026 12:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773084678; x=1773689478; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=dwTNwSVWtekPolaPxHcXxrp4YHsI9DpDNNtRgjqHJNI=; b=T8OOh4XplhQwITKtupHWbpHnO9AipUvoIybVxEjI8yMS05fUcYk3dUt2Wn3nKuDYPr NwMv/6ehPFXa5pTb4Mjx8cVRpejXZElS3/blRbM21LFNEE6tJ52K0HdBfKMvgqZV3WvI byqS5d/Q4Cgx+0u/AKKUuxXc6bqikgfVOUCWC83WMRjCuU+yQ9W0XC5ji80FW0BbJcvd 9coVuRAR7u/uoBD8tpBGlxyYOq9Dwak42M2fNLZpF9wPee57q1779Q/BIVeDkQ9S9HxD ifiXyv0QFGcaKNr3PxgeLbpAbPR8VV3V2BLCG1976Pl224nL73WTtTl9sV/6Iquj129x 8nng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773084678; x=1773689478; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dwTNwSVWtekPolaPxHcXxrp4YHsI9DpDNNtRgjqHJNI=; b=r/A6ECEs8ng0+6m0axwPT0X9G0fYHC34We6a+NYQXkO4Q9DlOptw0X1646xULEBnoI 6FzPw1qC66M8ZoKiz9b1mmQoaiCoamy3e299c2CXFTU9h2hgyhY6RhVppQDoqbsbfeUh FkBunSXC245yigPPP6WHXbnHCSVwAR+p2EqYlYfxJkDZfRn+IVBVVV76/FlbAlHq+PlV b2aF+YSmNjzoxcxCedmsHenIhIIfvPkaYokGflUjf5Gx6Ivip6oWXNXQWIYUttLdW+gi J3gn3hAcRBsdSI7Sm3tPh6Vhf6qupma2UxQeMTIkc0lwPmOQxVjpIOWlqJl2zOfK9iCr T3OA== X-Forwarded-Encrypted: i=1; AJvYcCUcWHJlAJ8yYqPfCxl/MZFeGPjLZVUtokd7JQ44SLIltKUBl2K6E70QstKUq+FVXNr+kXm4xNxR2be7kdw=@vger.kernel.org X-Gm-Message-State: AOJu0YxHp+ssa5oGOQkPP42yiGWiLjonjcXPjaqY3cyU3o+Lan0LBXjq Wg4KKp2sLp2/gmIOEOymOm5iG+Keh/3Erl3pD9XuYw3oD7Nd6i+D8kpPg/ylL9h43kKmCRP+XAb HIT1ecQ== X-Received: from pgbfq28.prod.google.com ([2002:a05:6a02:299c:b0:c6e:1ddf:c9ec]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:549f:b0:398:78cb:d85 with SMTP id adf61e73a8af0-39878cb252emr6354695637.13.1773084677666; Mon, 09 Mar 2026 12:31:17 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 9 Mar 2026 12:30:59 -0700 In-Reply-To: <20260309193059.2244645-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309193059.2244645-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309193059.2244645-4-seanjc@google.com> Subject: [RFC PATCH 3/3] KVM: Expedite SRCU callbacks when freeing objects during I/O bus registration From: Sean Christopherson To: Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , Paolo Bonzini Cc: rcu@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Nikita Kalyazin , Keir Fraser Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the recently introduced call_srcu_expedited() when freeing the old I/O bug during device registration to avoid triggering a non-expedited grace period. Delaying the freeing of the object by a full grace period is a complete non-issue, but the grace period also gets transferred to future synchronizations, e.g. to the synchronize_srcu_expedited() invocation in kvm_swap_active_memslots(). For micro-VM use cases, effectively transferring the non-expedited grace period to memslot updates results in a meaningful delay in overall boot time. E.g. with a CONFIG_HZ=3D100 kernel, the sync triggers a ~20ms delay, increasing boot times by 15% or more. Fixes: 7d9a0273c459 ("KVM: Avoid synchronize_srcu() in kvm_io_bus_register_= dev()") Reported-by: Nikita Kalyazin Closes: https://lore.kernel.org/all/a84ddba8-12da-489a-9dd1-ccdf7451a1ba@am= azon.com Cc: Keir Fraser Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9faf70ccae7a..ceaf08a03428 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -6021,7 +6021,7 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm= _bus bus_idx, gpa_t addr, memcpy(new_bus->range + i + 1, bus->range + i, (bus->dev_count - i) * sizeof(struct kvm_io_range)); rcu_assign_pointer(kvm->buses[bus_idx], new_bus); - call_srcu(&kvm->srcu, &bus->rcu, __free_bus); + call_srcu_expedited(&kvm->srcu, &bus->rcu, __free_bus); =20 return 0; } --=20 2.53.0.473.g4a7958ca14-goog