Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: Isolate apicv_update_lock and apicv_nr_irq_window_req in a cacheline

Force apicv_update_lock and apicv_nr_irq_window_req to reside in their own
cacheline to avoid generating significant contention due to false sharing
when KVM is contantly creating IRQ windows. E.g. apicv_inhibit_reasons is
read on every VM-Enter; disabled_exits is read on page faults, on PAUSE
exits, if a vCPU is scheduled out, etc.; kvmclock_offset is read every time
a vCPU needs to refresh kvmclock, and so on and so forth.

Isolating the write-mostly fields from all other (read-mostly) fields
improves performance by 7-8% when running netperf TCP_RR between two guests
on the same physical host when using an in-kernel PIT in re-inject mode.

Reported-by: Naveen N Rao (AMD) <naveen@kernel.org>
Closes: https://lore.kernel.org/all/yrxhngndj37edud6tj5y3vunaf7nirwor4n63yf4275wdocnd3@c77ujgialc6r
Tested-by: Naveen N Rao (AMD) <naveen@kernel.org>
Link: https://patch.msgid.link/20260123224514.2509129-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

+11 -1
+11 -1
arch/x86/include/asm/kvm_host.h
··· 1442 1442 bool apic_access_memslot_inhibited; 1443 1443 1444 1444 /* 1445 + * Force apicv_update_lock and apicv_nr_irq_window_req to reside in a 1446 + * dedicated cacheline. They are write-mostly, whereas most everything 1447 + * else in kvm_arch is read-mostly. Note that apicv_inhibit_reasons is 1448 + * read-mostly: toggling VM-wide inhibits is rare; _checking_ for 1449 + * inhibits is common. 1450 + */ 1451 + ____cacheline_aligned 1452 + /* 1445 1453 * Protects apicv_inhibit_reasons and apicv_nr_irq_window_req (with an 1446 1454 * asterisk, see kvm_inc_or_dec_irq_window_inhibit() for details). 1447 1455 */ 1448 1456 struct rw_semaphore apicv_update_lock; 1449 - unsigned long apicv_inhibit_reasons; 1450 1457 atomic_t apicv_nr_irq_window_req; 1458 + ____cacheline_aligned 1459 + 1460 + unsigned long apicv_inhibit_reasons; 1451 1461 1452 1462 gpa_t wall_clock; 1453 1463