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

Re: [PATCH 2/9] AMD/IOMMU: re-work locking around sending of commands


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 9 Jun 2021 11:53:25 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=FvtKM8hZcyiOKUxPEBrh3kQZZTzUXlzcfWC1I/fdj5s=; b=LoEBB77bY8uk5mKXG/wNAfN8HHHOAdsV5R1BQmRZHvzhosY5YPikJ2tuAehuT4wR+M4jYmlTMqnyB+nxaKISoB3uWNMMt7o3/S1H1Et5IxozgGRvt8JhOBSkp96t8HxY0IA9dON8WWqXK4UzJY/GYX/m5S39kTfkaTNegNM79xZuozVlCZLDsaqmkt+ldLHx2mtMZzvTF+9bX80kRRdOMMfs2kjn1BdGJf0p/q5McQnzblCN7C84tAYXqBQnF/zu3mp9bSxCx/6pTryAHQhkmS99uf/ebap3lj1lEjX0vFO9bPyG3QtmgClND5xOLqJA7VFrkElWkmaDayeR0OzMaw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=glrVPH/NGipcmYS+hBER8wcgvMafYEc7sTSeNRxka0esobIsIAe4g9Ogp1ior4rBRXhcfnhwl92Sp4pr5EC86aJqWfRZ6NMw3FLd7Sfpph1+HdSPF3LM0tfsUGZlPHukbsg8vc3VLflaTtt+SvypUjMFY7kiK+76ydfgm2qsm3B69PRrxHjTJvMw7pjjfQrUZiGSaTtF0J+6A7de7sDc9fdvLW8OOy2nesNprwCHk0bJSje2SbJtiiH4vSxe6OrRKd54YgdIKzv5zVB+R+nTyyYpMo+iyI30qJDetwfjht71bTQ+q5qyFW3eyMRV7qHLbfjorDBx//ET9nDGFrUsmg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Wed, 09 Jun 2021 10:53:42 +0000
  • Ironport-hdrordr: A9a23:+FEuc6DhWs+F2FDlHehBsceALOsnbusQ8zAXPh9KJyC9I/b2qy nxppgmPH/P6Ar4WBkb6LS90dq7MA3hHPlOkPYs1NaZLXXbUQ6TTb2KgrGSuAEIdxeOkNK1kJ 0QDpSWa+eAf2SS7/yKmDVQeuxIqLLsndHK9IWuu0uFDzsaDJ2Ihz0JeTpzeXcGPTWua6BJca Z0qvA33QZJLh8sH7SG7zQ+Lqf+juyOsKijTQ8NBhYh5gXLpTS06ITiGxzd+hsFSTtAzZor7G CAymXCl+SemsD+7iWZ+37Y7pxQltek4txfBPaUgsxQDjn3kA6naKloRrXHljEop+OE7kosjb D30lkdFvU2z0mUUnC+oBPr1QWl+i0p8WXexViRhmamidDlRRohYvAxx75xQ1/80Q4Nrdt82K VE0yayrJxMFy7Nmyz7+pzhSwxqrEypunAv+NRjzEC3abFuLIO5kLZvu3+8SPw7bWTHAcEcYa lT5fjnlbNrmQjwVQGBgoEHq+bcK0jaHX+9MwI/U4KuomBrdUtCvj0lLfok7zw9HaIGOu55Dt v/Q+1VfZF1P4IrhPFGdas8qfXeMB2EffuaChPiHb2gLtBdB07w
  • Ironport-sdr: 1kgU9iqzK8ymFuM9n5R/Z4I3cglnAgEhhyfmGIq73u6wBZ408AnlOR+I1oxCWiLa3GSqtGiLZX 7y6pQCXvK6NzIfvmwaD2MnV7kWyspNuHps0Gyu4xaRFWWlfDO2lQS9a34tX8Qs0v6THQaUOMVv htTNY92sNewatbB8p/do7BQCtRC3feYrFwE6MIYr/r4HU6oORy2l9MMhfS5GOLIY16jiWt0N7j ZNCcWM9GOMQTQlsgmGoRQ/ohSgG+KcsK5ODdx+stQvISThBaqgoe+0zP/9m1BWJ+XVF72uolZG ldo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09/06/2021 10:27, Jan Beulich wrote:
> It appears unhelpful to me for flush_command_buffer() to block all
> progress elsewhere for the given IOMMU by holding its lock while
> waiting for command completion. Unless the lock is already held,
> acquire it in send_iommu_command(). Release it in all cases in
> flush_command_buffer(), before actually starting the wait loop.
>
> Some of the involved functions did/do get called with the lock already
> held: For amd_iommu_flush_intremap() we can simply move the locking
> inside. For amd_iommu_flush_device() and amd_iommu_flush_all_caches()
> the lock now gets dropped in the course of the function's operation.
>
> Where touching function headers anyway, also adjust types used to be
> better in line with our coding style and, where applicable, the
> functions' callers.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Reviewed-by: Paul Durrant <paul@xxxxxxx>

Honestly, I'm -2 to this.  It is horrible obfuscation of the logic.

I agree with the premise of not holding the lock when we don't need to,
but moving the lock/unlocks into different functions makes it impossible
to follow.  (Also, the static analysers are going to scream at this
patch, and rightfully so IMO.)

send_iommu_command() is static, as is flush_command_buffer(), so there
is no need to split the locking like this AFAICT.

Instead, each amd_iommu_flush_* external accessor knows exactly what it
is doing, and whether a wait descriptor is wanted. 
flush_command_buffer() wants merging into send_iommu_command() as a
"bool wait" parameter, at which point the locking and unlocking moves
entirely into send_iommu_command() with no pointer games.

~Andrew




 


Rackspace

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