public inbox for rcu@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Lai Jiangshan <jiangshanlai@gmail.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	 Josh Triplett <josh@joshtriplett.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: rcu@vger.kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Sean Christopherson <seanjc@google.com>,
	Nikita Kalyazin <kalyazin@amazon.com>,
	Keir Fraser <keirf@google.com>
Subject: [RFC PATCH 3/3] KVM: Expedite SRCU callbacks when freeing objects during I/O bus registration
Date: Mon,  9 Mar 2026 12:30:59 -0700	[thread overview]
Message-ID: <20260309193059.2244645-4-seanjc@google.com> (raw)
In-Reply-To: <20260309193059.2244645-1-seanjc@google.com>

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=100 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 <kalyazin@amazon.com>
Closes: https://lore.kernel.org/all/a84ddba8-12da-489a-9dd1-ccdf7451a1ba@amazon.com
Cc: Keir Fraser <keirf@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 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);
 
 	return 0;
 }
-- 
2.53.0.473.g4a7958ca14-goog


  parent reply	other threads:[~2026-03-09 19:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 19:30 [RFC PATCH 0/3] srcu: KVM: Add, export and use call_srcu_expedited() Sean Christopherson
2026-03-09 19:30 ` [RFC PATCH 1/3] srcu: Declare exported symbols before including srcu{tiny,tree}.h Sean Christopherson
2026-03-09 19:30 ` [RFC PATCH 2/3] srcu: Add and export call_srcu_expedited() to avoid transferring grace periods Sean Christopherson
2026-03-09 19:30 ` Sean Christopherson [this message]
2026-03-13  8:51 ` [RFC PATCH 0/3] srcu: KVM: Add, export and use call_srcu_expedited() Kunwu Chan
2026-03-13 23:12   ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260309193059.2244645-4-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=kalyazin@amazon.com \
    --cc=keirf@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rcu@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox