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

Re: [PATCH] device-tree: optimize dt_device_for_passthrough()


  • To: Grygorii Strashko <gragst.linux@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Tue, 11 Feb 2025 12:57:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=fMrPWyRZ3wVAw21prAg2l7jZTD3l0RnkBu91+GreTYA=; b=uhIcEj/tVS5MO4c10+MRtSGfRtmtOP3PRTkr6Lws+MauAK9aKgsij/bm4KxDX9+tl6Qidb828KnmJ8BxMeZIl4qUZo0GZPiFa4FEV9EjHPabdv6D2nIQ+/TmA0FkOZedX1wpYop955gVfTvP+sVVtcjHAhbES1HxBpjjXUb5wTdfZaACYGzDOD+Fq0KGh/KmpusXJlK3oESCxlB25UXODhVbanCtLYU+pzRWDHxK0kw8BVWZbnrVp0l5HJ1Hbws7ctY9q4WQ36p0S3qJ997d95qfTIwTXOjxjvdT31OqRqCoJdT2kpWx5pWxMvxa2qdLRiTEo7Cl7LnNqvs81WxvdQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pje75oF7oOIwcsxoaw//lsHv6sd9FGn3K2AA2PPyPN5j/pVqpfNEiUvWZMZc+UyLNzWA9H8NLiGbOzHp7xOzqeWp6zq7OPTa2N6wkKMo2lnRCmYnFX9nNcBSfIli6vY+wjdDfMGIVjBLZAlUIconx4ErVFhfPikXu4xOyIKL10X3xcWMroDbGkGDdHxjXNv6Ua7xO8lNaHBVNkZOl0Tz4A5/AqcIV70gDeX+PDKdzM0fsq3p1doljYDB3fVzB6+CjM8mNLyDL2RFYN3B67CCNvWGRXKN/7S+wU9kyQMIG+2eQVmHi1PFOpG2/3owg0a3zheI1UJJ6TKl0UfLWRUNgQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Delivery-date: Tue, 11 Feb 2025 11:57:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 11/02/2025 12:18, Grygorii Strashko wrote:
> 
> 
> The dt_device_for_passthrough() is called many times during Xen
> initialization and Dom0 creation. On every call it traverses struct
> dt_device_node properties list and compares compares properties name with
double "compares"

> "xen,passthrough" which is runtime overhead. This can be optimized by
Are you sure? Looking at the calls, it's almost only used at boot except for dt
overlay.

> marking dt_device_node as passthrough while unflattening DT.
> 
> This patch introduced new struct dt_device_node property "is_passthrough"
> which is filled if "xen,passthrough" property is present while unflattening
> DT and dt_device_for_passthrough() just return it's value.
In the past we were skeptical about adding new fields to the dt_device_node
structure for use cases like this one. I would say this optimization is not
worth it. Also, why would you optimize dt_device_for_passthrough but not
e.g. dt_device_is_available.

You can check with other Arm maintainers.

~Michal

> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
> ---
>  xen/common/device-tree/device-tree.c | 7 +++++--
>  xen/include/xen/device_tree.h        | 2 ++
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/common/device-tree/device-tree.c 
> b/xen/common/device-tree/device-tree.c
> index d0528c582565..a329aaf576da 100644
> --- a/xen/common/device-tree/device-tree.c
> +++ b/xen/common/device-tree/device-tree.c
> @@ -1682,8 +1682,7 @@ bool dt_device_is_available(const struct dt_device_node 
> *device)
> 
>  bool dt_device_for_passthrough(const struct dt_device_node *device)
>  {
> -    return (dt_find_property(device, "xen,passthrough", NULL) != NULL);
> -
> +    return device->is_passthrough;
>  }
> 
>  static int __dt_parse_phandle_with_args(const struct dt_device_node *np,
> @@ -1913,6 +1912,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
>          np->used_by = 0;
>          /* By default the device is not protected */
>          np->is_protected = false;
> +        np->is_passthrough = false;
>          INIT_LIST_HEAD(&np->domain_list);
> 
>          if ( new_format )
> @@ -2001,6 +2001,9 @@ static unsigned long unflatten_dt_node(const void *fdt,
>               * stuff */
>              if ( strcmp(pname, "ibm,phandle") == 0 )
>                  np->phandle = be32_to_cpup((__be32 *)*p);
> +
> +            if ( strcmp(pname, "xen,passthrough") == 0 )
> +                np->is_passthrough = true;
>              pp->name = pname;
>              pp->length = sz;
>              pp->value = (void *)*p;
> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> index 5ff763bb80bb..96001d5b7843 100644
> --- a/xen/include/xen/device_tree.h
> +++ b/xen/include/xen/device_tree.h
> @@ -94,6 +94,8 @@ struct dt_device_node {
> 
>      /* IOMMU specific fields */
>      bool is_protected;
> +    /* Indicates DT device is for passthrough */
> +    bool is_passthrough;
> 
>  #ifdef CONFIG_STATIC_EVTCHN
>      /* HACK: Remove this if there is a need of space */
> --
> 2.34.1
> 




 


Rackspace

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