Message ID | 20240213093250.3960069-1-oliver.upton@linux.dev (mailing list archive) |
---|---|
Headers | show |
Series | KVM: arm64: Improvements to LPI injection | expand |
On Tue, Feb 13, 2024 at 09:32:37AM +0000, Oliver Upton wrote: [...] > Clearly the RCU synchronization is a bounding issue in this case. I > think other scenarios where the cache is overcommitted (16 vCPUs, 16 > devices, 17 events / device) are able to hide effects somewhat, as other > threads can make forward progress while others are stuck waiting on RCU. > > A few ideas on next steps: > > 1) Rework the lpi_list_lock as an rwlock. This would obviate the need > for RCU protection in the LPI cache as well as memory allocations on > the injection path. This is actually what I had in the internal > version of the series, although it was very incomplete. > > I'd expect this to nullify the improvement on the > slightly-overcommitted case and 'fix' the pathological case. > > 2) call_rcu() and move on. This feels somewhat abusive of the API, as > the guest can flood the host with RCU callbacks, but I wasn't able > to make my machine fall over in any mean configuration of the test. > > I haven't studied the degree to which such a malicious VM could > adversely affect neighboring workloads. > > 3) Redo the whole ITS representation with xarrays and allow RCU readers > outside of the ITS lock. I haven't fully thought this out, and if we > pursue this option then we will need a secondary data structure to > track where ITSes have been placed in guest memory to avoid taking > the SRCU lock. We can then stick RCU synchronization in ITS command > processing, which feels right to me, and dump the translation cache > altogether. > > I'd expect slightly worse average case performance in favor of more > consistent performance. Marc and I had an off-list conversation about this and agreed on option 4! It is somewhat similar in spirit to (3), in that KVM will maintain an xarray translation cache per ITS, indexed by (device_id, event_id). This will be a perfect cache that can fit the entire range addressed by the ITS. The memory overheads of the xarray are not anticipated to be consequential, as the ITS memory footprint already scales linearly with the number of entries in the ITS. Separately the DB -> ITS translation will be resolved by walking the ITSes present in the VM. The existing invalidation calls will be scoped to an ITS besides the case where the guest disables LPIs on a redistributor.
On Tue, 13 Feb 2024 09:32:37 +0000, Oliver Upton <oliver.upton@linux.dev> wrote: > > For full details on the what/why, please see the cover letter in v1. > > Apologies for the delay on v2, I wanted to spend some time to get a > microbenchmark in place to slam the ITS code pretty hard, and based on > the results I'm glad I did. [...] Buglets and potential improvements aside, I like the smell of this. At least the first handful of patches could easily be taken as a separate improvement series. Let me know how you'd like to play this. Thanks, M.
On Wed, Feb 14, 2024 at 05:43:13PM +0000, Marc Zyngier wrote: > On Tue, 13 Feb 2024 09:32:37 +0000, > Oliver Upton <oliver.upton@linux.dev> wrote: > > > > For full details on the what/why, please see the cover letter in v1. > > > > Apologies for the delay on v2, I wanted to spend some time to get a > > microbenchmark in place to slam the ITS code pretty hard, and based on > > the results I'm glad I did. > > [...] > > Buglets and potential improvements aside, I like the smell of this. At > least the first handful of patches could easily be taken as a separate > improvement series. > > Let me know how you'd like to play this. Yeah, I think there's 3 independent series here if we want to take the initial improvements: - Address contention around vgic_get_irq() / vgic_put_irq() with the first 10 patches. Appears there is violent agreement these are good to go. - Changing out the translation cache into a per-ITS xarray - A final series cleaning up a lot of the warts we have in LPI management, like vgic_copy_lpi_list(). I believe we can get rid of the lpi_list_lock as well, but this needs to be ordered after the first 2. I'd really like to de-risk the performance changes from the cleanups, as I'm convinced they're going to have their own respective piles of bugs. How does that sound?
On Wed, 14 Feb 2024 18:40:27 +0000, Oliver Upton <oliver.upton@linux.dev> wrote: > > On Wed, Feb 14, 2024 at 05:43:13PM +0000, Marc Zyngier wrote: > > On Tue, 13 Feb 2024 09:32:37 +0000, > > Oliver Upton <oliver.upton@linux.dev> wrote: > > > > > > For full details on the what/why, please see the cover letter in v1. > > > > > > Apologies for the delay on v2, I wanted to spend some time to get a > > > microbenchmark in place to slam the ITS code pretty hard, and based on > > > the results I'm glad I did. > > > > [...] > > > > Buglets and potential improvements aside, I like the smell of this. At > > least the first handful of patches could easily be taken as a separate > > improvement series. > > > > Let me know how you'd like to play this. > > Yeah, I think there's 3 independent series here if we want to take the > initial improvements: > > - Address contention around vgic_get_irq() / vgic_put_irq() with the > first 10 patches. Appears there is violent agreement these are good > to go. > > - Changing out the translation cache into a per-ITS xarray > > - A final series cleaning up a lot of the warts we have in LPI > management, like vgic_copy_lpi_list(). I believe we can get rid of > the lpi_list_lock as well, but this needs to be ordered after the > first 2. > > I'd really like to de-risk the performance changes from the cleanups, as > I'm convinced they're going to have their own respective piles of bugs. > > How does that sound? Yup, I'd be on board with that. If you can respin the first part with bugs fixed and without the stats, that'd be great. We can further bikeshed on the rest in the 6.10 time frame. Also please Cc: Eric Auger, as he dealt with a lot of the ITS save/restore stuff. Thanks, M.
On Thu, Feb 15, 2024 at 03:37:45PM +0000, Marc Zyngier wrote: > > I'd really like to de-risk the performance changes from the cleanups, as > > I'm convinced they're going to have their own respective piles of bugs. > > > > How does that sound? > > Yup, I'd be on board with that. If you can respin the first part with > bugs fixed and without the stats, that'd be great. We can further > bikeshed on the rest in the 6.10 time frame. Cool. That makes things much easier to manage. I'll respin the get / put improvements shortly, and hopefully this time I actually fix the stupid lock imbalance :) > Also please Cc: Eric Auger, as he dealt with a lot of the ITS > save/restore stuff. Always happy to designate another victim to review my crap.