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

Re: [XEN][PATCH v10 14/20] common/device_tree: Add rwlock for dt_host


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 29 Aug 2023 11:27:55 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=fu4VVJqq9b9fKEZMeTNYlgVkRBo58iQhbc1iPxMsUlE=; b=NaohxbepdtQXdC30qArOkobzOhx7pus3+JCMTVkpUArDnazuMNIgF46+v3r3dSTn7tDsUqK+BSOFjPnnzS2tRYokV6AuXW7Ekr3i54gSuAij9u8487PP7cRJC6c+P3MF0HP535beEurJGqe/grPqtnxDP75rFkNdQ2uCr5wuAtJvjxW4SE/LUifeRWnwZPNAUpbaB9Hqliqk3UvmCSxIiAv5GZJP5Zj0woTzTuw4/aoO21T9QSSgxBtCH1vuMaPiKKMwS4y1O3C0+9VGwvlZSm9L/B5TiG6q41ddz5zxLWwpZYpSOVnzEteD0HfpLpS2Mm2NRhCK30hqTmzAf5QcSw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FVVAXqejr89dzpzHfphByKplHftCpmmSNmXFyLr1MdIHmgUrWBCLb7c8d1TQwWOXw1ICWDu7GxHKD+qxmj24P36UtHRZXx0KjT0TMynr8bu8EUMl6SS4oNDBUbOWUuJwtro7QKl/LhP0LKLq8wZrrTujFpv7MIuNzMIyTHtqd2esBuKNEIvNy59xO8fUHn2hq0LYckHXrIBQU4RCzO35kGDJHZzQxM5SFW7q9vp4KblMSGFwDwvC/lDRPLwegfKIDeO6YQwfiUIvv9quYHhp3tUQUZ7oYWGSAuxZN2f+7ASURou/LAsbyCMn3Em+tABKGXJGPTkO3Ko+c4kkoE7Kww==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>
  • Delivery-date: Tue, 29 Aug 2023 09:28:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 25/08/2023 10:02, Vikram Garhwal wrote:
> 
> 
> Dynamic programming ops will modify the dt_host and there might be other
> functions which are browsing the dt_host at the same time. To avoid the race
> conditions, adding rwlock for browsing the dt_host during runtime. dt_host
> writer will be added in the follow-up patch for device tree overlay
> functionalities."
Please drop "

> 
> Reason behind adding rwlock instead of spinlock:
>    For now, dynamic programming is the sole modifier of dt_host in Xen during
>        run time. All other access functions like iommu_release_dt_device() are
Indentation is incorrect. All this text block should be aligned to "For now" 
above.

>        just reading the dt_host during run-time. So, there is a need to 
> protect
>        others from browsing the dt_host while dynamic programming is modifying
>        it. rwlock is better suitable for this task as spinlock won't be able 
> to
>        differentiate between read and write access.
> 
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
Apart from that, the patch itself looks good:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

although I would recommend to follow Julien suggestion and to at least
add an assert in iommu_assign_dt_device() and iommu_add_dt_device() to check if 
the lock
is taken (given the system state is >= active to exclude calls from boot state).

~Michal




 


Rackspace

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