[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RESEND] x86/vpt: Replace per-guest pt_migrate lock with per pt lock


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Thu, 25 Mar 2021 19:17:10 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j9wkUCORkX/lz7apVR880/LJ25oSKh6Y81+b7CDAxUo=; b=oUtBX/2MN3gSJrbkL82dsNlM0wqWV2hjeAzBYj2wzuI//PgR2plG2tiisD0HMz4qRYbEzIi2rvY5SoXIZlSTTMSLRF6N3n9Oq58r8UKiruZN+hG+wKF7NuWC3gaKbfDiyBjPHhUkQ3kS11R0SeMMLfsD2NdAQ4FIhU20cpfojwi878Ysnh5ezUw7O/SCzKWDpAcIlRxQWQnp0mDswvSGuFTm9HY4oYlTmmCu4o3gGUWufA9yo49d9Vi3BdOQU58zKfeZf17gK7NK5hC5u/TMlZOdMLf2snfrgTkkWjvujj9/KcoQ06TF4f11REzIp1XQX7hq+kmo7aw6pRM9KkBtzA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnjiaohNTQAy3Oax0K991AdNAEvI2Qy0s0YLG0dyCyvcm6b0y22/+hc0ehqEVzckVKo7thft9TyI34j7naxjeZ2wwSZp37qRkkoiFikAQYcDBOqZv8Qj4z2LoT86imwR7wApACnlMCk6wrUv/lMSehKSv2y7Rrdgg6rK3Nrgi5Onl6FuDL8CCRxdhHIoyRZuB1H7rxNs+ypCGTwPygSNCheBm3uUDDhqCv4sZWR1afOWcM7T7baOrOfgdThCD+XqPBBcPIOYJXsEleeH7CNNjWw0MtBI4WA3jEOYpZIE0+ypCcsmSaQsnZEIgytTwthaSCpBhUlX7WoGO53npgrfrg==
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, wl@xxxxxxx, stephen.s.brennan@xxxxxxxxxx
  • Delivery-date: Thu, 25 Mar 2021 23:18:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 3/25/21 10:48 AM, Roger Pau Monné wrote:
> On Wed, Mar 24, 2021 at 05:05:05PM -0400, Boris Ostrovsky wrote:
>> Commit 8e76aef72820 ("x86/vpt: fix race when migrating timers between
>> vCPUs") addressed XSA-336 by introducing a per-domain rwlock that was
>> intended to protect periodic timer during VCPU migration. Since such
>> migration is an infrequent event no performance impact was expected.
>>
>> Unfortunately this turned out not to be the case: on a fairly large
>> guest (92 VCPUs) we've observed as much as 40% TPCC performance regression
>> with some guest kernels. Further investigation pointed to pt_migrate
>> read lock taken in pt_update_irq() as the largest contributor to this
>> regression. With large number of VCPUs and large number of VMEXITs
>> (from where pt_update_irq() is always called) the update of an atomic in
>> read_lock() is thought to be the main cause.
> Right, seems like a very plausible analysis.
>
> Since I suspect most (if not all?) 


pt_restore_timer() (called from the scheduler) also contributes a couple of 
percent. But yes.


> of the performance regression is
> from the read_lock in pt_update_irq I think we can remove that without
> doing such a big change to the current locking logic, and instead
> merging part of the logic that you detail in the cover letter without
> moving to a per-timer lock.
>
>> Stephen Brennan examined the locking pattern and suggested using a
>> per-timer lock instead. This lock will need to be held whenever there is
>> a chance that pt->vcpu field may change (thus avoiding XSA-336
>> condition).
>>
>> Suggested-by: Stephen Brennan <stephen.s.brennan@xxxxxxxxxx>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> So while I think this is indeed a working solution, I'm not convinced
> we require a per-timer lock, I think we can find some middle ground
> using both a per-domain rwlock and the more fine grained per-vcpu
> lock.
>
> Basically for type 1 accesses (pt_vcpu_{un}lock) I think we can safely
> drop the read_{un}lock call,


Yes, if that's the case then current rwlock should be fine.


>  and remove the performance bottleneck
> while slightly adjusting the functions that modify the per-vcpu timer
> lists to take the per-vcpu locks when doing so.
>
> I've tried to convey that in the comments below, while also pointing
> out some suitable places where comments can be added based on the text
> from your cover letter.
>
> Overall this should result in a smaller patch that will be both easier
> to review and argue in terms of inclusion into 4.15.


Sure. Thanks for the review/suggestions.


-boris




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.