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

RE: [XEN][PATCH v6 14/19] common/device_tree: Add rwlock for dt_host


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Thu, 4 May 2023 04:38:26 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9IMZTaetQU/LDyWZ0wOaYTWh5ffcjtrO06NcTJvkw4Y=; b=HvUYcRfbl+iLpyD14flz4wfc8EkAPOQ/UZhar/y5f8WXxRzUGk7BrEJfcsnSoFpbXou5aFsk9mE9KEdksEZc7YmLI7U9asGdtFSOwd4cDwojKfV8nnaQw4b7G0tfayL9T/YowrLVr0JnPsKEJ6ldafH8f5cQlePKyhJqtPl8jpj+t0Daejw9ArOH8p2xBr9WMMpghIPUuVhGR6xB8BDtjgvKhisxd7ZYYQIqY3XanIppFWdkPDXUgTIPILdqLKRZRO6QtHffzyrTznYPZvGa8pCS9YenRNNuAKkwhKb+fim3k/SuBE+HzZGxBVkA27t7vadimFx/vfvTOGFDrhLRCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h891+WVSYNkDSsl0p3idiC+O4Vh0a2bV8iqvG3t3xxQlrHTz8U3fXuB3klsRmMip6Cp1KrNvgdIUbQ7X2hwSpdF4VCbIf7Ql3VQoqsoaWwY33qs5YDIQd7P8jW3+IkAdlgVO6Lt8Xb58FOaMGwrQTA5YfHCNQ3XS4lhcucQi1JdWH7Cy2K5Fq+6I81Xvs8B+4+jYGV4d0emF3WnLUGngeI7aj22lUYOPirPohSu5P86Lknff7rhXcf93uyEWeT/JtmLPhDsO8jXUiLaR2GP76CQhnrjY81pLiodYK5DwjV43JF3IRwbqjypsGmOWHruv419DIbxE6mtGoYpkpecM9g==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Thu, 04 May 2023 04:39:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZfU8ldKybmQ5LfEKEsMjqvUt8n69Jh4jw
  • Thread-topic: [XEN][PATCH v6 14/19] common/device_tree: Add rwlock for dt_host

Hi Vikram,

> -----Original Message-----
> Subject: [XEN][PATCH v6 14/19] common/device_tree: Add rwlock for dt_host
> 
>  Dynamic programming ops will modify the dt_host and there might be other
>  function which are browsing the dt_host at the same time. To avoid the race
>  conditions, adding rwlock for browsing the dt_host during runtime.

While now I understand why you use rwlock instead of spinlock in this patch
since you explained it in replying my comment in v5 (Thanks!). I would still
suggest that you can add that kind of explanation in the commit message to
make the commit message clear to everyone that reading this patch.

> 
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
> ---
>  xen/common/device_tree.c              |  4 ++++
>  xen/drivers/passthrough/device_tree.c | 18 ++++++++++++++++++
>  xen/include/xen/device_tree.h         |  6 ++++++
>  3 files changed, 28 insertions(+)
> 

[...]

>          ret = iommu_add_dt_device(dev);
>          if ( ret < 0 )
> @@ -310,6 +321,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl,
> struct domain *d,
>              printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign
> \"%s\""
>                     " to dom%u failed (%d)\n",
>                     dt_node_full_name(dev), d->domain_id, ret);
> +
> +        read_unlock(&dt_host->lock);

Since you added "read_unlock(&dt_host->lock);" before the final return,
i.e. "return ret", I don't think you need to add "read_unlock(&dt_host->lock);"
here before the break. Or am I missing something?

>          break;
> 
>      case XEN_DOMCTL_deassign_device:
> @@ -328,11 +341,15 @@ int iommu_do_dt_domctl(struct xen_domctl
> *domctl, struct domain *d,
>              break;
> 
>          ret = xsm_deassign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev));
> +

Nit: Unnecessary blank line addition here.

Kind regards,
Henry



 


Rackspace

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