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

Re: [PATCH v5 11/11] xen/arm: create another /memory node for static shm


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Thu, 7 Dec 2023 16:28:01 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.com 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 (0)
  • 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=dpMG63mrgN/tJWzH5iLAK5Euh3C5zliYN2vIz1Zx/nc=; b=jVy82q6xwN7wNmbbQJ+2gm+Ww7pAfJ4xWHOxMx/YXP8xavIllwCNuMHkqXtdjyC4tthe92L39AM4bw2DrunzmsfL9LlWzFDFuTSdObFjos82xY9EP0Dcjjboq45Fj70KPgwjpD48wmu0rHPu7IB7BnB+DLe391ji4iBrohQCX4GElJrQehazG2LsggjZ6782Nq2OTKLICLkd1Zqf4J7ickx2nppYPQcdP/L0Ty4Z8Gj4OcHlZvnB1u0BTHh19LEOns3sYLCCKRKhPN+GnPVVE2BPpEdmJG3WyslUQJ2Ps813ESbOvfgsAkIm9yTVZDqAdQDJKuxLRaR8w2ygKR4uUA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+CHjTPBCYvmJeCLDzc1kKPRuwSzlFHQSTT1TCogrNgW9EHaePyylY0kkAG70NP/N/k7/RJz+C22yxvzuGdQltCJZ49GDaJfBK3ioB+fsCwqA1xDf0Vu5/wrVqcf28H6EgRKvB+3/qUxgsOyXErn5ZSHCby+Wlu/88PBcrrLMiQMXtY6nVBIow6VKHSNxH6KJOxB/vinPSU4ToDUToqEKBKNlWx84Ox8P8XB1K4NLXCsmouF/WowQdT8lBOwqTjKH9Bqfe9pRVcOyRZdT+lRkfq/wNfpcpBsqVMUcuI4YWaWfuICGG7athktZJMBSxUMIONE+3ZPb3Eu81+MjiZLQA==
  • Cc: <wei.chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 07 Dec 2023 15:28:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Penny,

On 06/12/2023 10:06, Penny Zheng wrote:
> 
> 
> Static shared memory region shall be described both under /memory and
> /reserved-memory.
> 
> We introduce export_shm_memory_node() to create another /memory node to
> contain the static shared memory ranges.
> 
> Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> 
> ---
> v3 -> v4:
> new commit
> ---
> v4 -> v5:
> rebase and no changes
> ---
>  xen/arch/arm/dom0less-build.c           |  8 ++++++++
>  xen/arch/arm/domain_build.c             |  8 ++++++++
>  xen/arch/arm/include/asm/static-shmem.h | 10 ++++++++++
>  xen/arch/arm/static-shmem.c             | 19 +++++++++++++++++++
>  4 files changed, 45 insertions(+)
> 
> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> index ac096fa3fa..870b8a553f 100644
> --- a/xen/arch/arm/dom0less-build.c
> +++ b/xen/arch/arm/dom0less-build.c
> @@ -645,6 +645,14 @@ static int __init prepare_dtb_domU(struct domain *d, 
> struct kernel_info *kinfo)
>      if ( ret )
>          goto err;
> 
> +    /* Create a memory node to store the static shared memory regions */
> +    if ( kinfo->shminfo.nr_banks != 0 )
There is no need for this check to be repeated every time 
export_shm_memory_node is used.
When the feature is disabled, export_shm_memory_node will return 0 anyway.
Furthermore, there is no need for kinfo->shminfo exposure. Please move the 
check to the function itself.

Also, I think both this and previous patch could be moved towards the beginning 
of the series.
They are not related to other things you do in the series.


> +    {
> +        ret = export_shm_memory_node(d, kinfo, addrcells, sizecells);
> +        if ( ret )
> +            goto err;
> +    }
> +
>      ret = make_resv_memory_node(d, kinfo->fdt, addrcells, sizecells, kinfo);
>      if ( ret )
>          goto err;
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index f098678ea3..4e450cb4c7 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1873,6 +1873,14 @@ static int __init handle_node(struct domain *d, struct 
> kernel_info *kinfo,
>                  return res;
>          }
> 
> +        /* Create a memory node to store the static shared memory regions */
> +        if ( kinfo->shminfo.nr_banks != 0 )
> +        {
> +            res = export_shm_memory_node(d, kinfo, addrcells, sizecells);
> +            if ( res )
> +                return res;
> +        }
> +
>          /* Avoid duplicate /reserved-memory nodes in Device Tree */
>          if ( !kinfo->resv_mem )
>          {
> diff --git a/xen/arch/arm/include/asm/static-shmem.h 
> b/xen/arch/arm/include/asm/static-shmem.h
> index 6cb4ef9646..385fd24c17 100644
> --- a/xen/arch/arm/include/asm/static-shmem.h
> +++ b/xen/arch/arm/include/asm/static-shmem.h
> @@ -38,6 +38,10 @@ int make_shm_memory_node(const struct domain *d,
>                           void *fdt,
>                           int addrcells, int sizecells,
>                           const struct kernel_info *kinfo);
> +
> +int export_shm_memory_node(const struct domain *d,
> +                           const struct kernel_info *kinfo,
> +                           int addrcells, int sizecells);
>  #else /* !CONFIG_STATIC_SHM */
> 
>  static inline int make_resv_memory_node(const struct domain *d, void *fdt,
> @@ -86,6 +90,12 @@ static inline int make_shm_memory_node(const struct domain 
> *d,
>      return 0;
>  }
> 
> +static inline int export_shm_memory_node(const struct domain *d,
> +                                         const struct kernel_info *kinfo,
> +                                         int addrcells, int sizecells)
> +{
> +    return 0;
> +}
>  #endif /* CONFIG_STATIC_SHM */
> 
>  #endif /* __ASM_STATIC_SHMEM_H_ */
> diff --git a/xen/arch/arm/static-shmem.c b/xen/arch/arm/static-shmem.c
> index bfce5bbad0..e583aae685 100644
> --- a/xen/arch/arm/static-shmem.c
> +++ b/xen/arch/arm/static-shmem.c
> @@ -505,6 +505,25 @@ int __init process_shm(struct domain *d, struct 
> kernel_info *kinfo,
>      return 0;
>  }
> 
> +int __init export_shm_memory_node(const struct domain *d,
> +                                  const struct kernel_info *kinfo,
> +                                  int addrcells, int sizecells)
> +{
> +    unsigned int i = 0;
> +    struct meminfo shm_meminfo;
> +
> +    /* Extract meminfo from kinfo.shminfo */
> +    for ( ; i < kinfo->shminfo.nr_banks; i++ )
> +    {
> +        shm_meminfo.bank[i].start = kinfo->shminfo.bank[i].membank.start;
> +        shm_meminfo.bank[i].size = kinfo->shminfo.bank[i].membank.size;
> +        shm_meminfo.bank[i].type = MEMBANK_DEFAULT;
Is all of this really needed? This series introduces so many structures to 
avoid using
meminfo but at the end we still need to use it. The amount of meminfo like 
structures copying
done in this series worries me a bit.

~Michal




 


Rackspace

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