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

Re: [PATCH v5 4/7] xen/arm: static memory initialization


  • To: Penny Zheng <penny.zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 24 Aug 2021 13:59:00 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=11ieDCyf49YgIwSuJtBWwxS7LbVOTbTc4zhWNsxNMCU=; b=W8I57WZ/Zlwr7p8kyUB4rhVsZ9VmdQDpEotWOU3HSDAceg9U2XQVEzxutxijGZieWl8B+8fO8AiqVzhxHJRkg6gt3NU53AyGw3citBdyPSfzEb54ZIxqeqFOQC0drmlKnYVBHtDzSkSgHIErLV0Krap7+CJPpxs5LrJE+H2ZUAyvR2yHweZZKC6sZEOZ7GDxeu65BoVnsVsMoObxppmL0YD+WIYQJ+inTgF9bV3O8bcozUdW2+MnZg615xVhnH5YWeK9/iASaClhy2OLOIzUSyID8iFxQd/FER+DIQqnN/OTKECrgBOlgJmW9Dq7i4Dii1Z9zifDo0IU36TnzzJm2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXdJnQ4Iz8Cohomav6nf0dM/02zRU8GAoHPcWZ/tSfwjNyFxq1GOrkPbbHv8TVZlT2YUjsd+2qQJt0trbC/tvV3QnuBDnpC80Sb2VC+TuPYAS3YVn55EtqLTJosBxti0fBZDJWM8N9hcAUrrJpGUa0p88hNbPvB8ap5bfV+/sCO6i/f/KDBnlXo9p2T04t39ozoWPWtKZsKSNQFpzzN+/wGaSnnZ8vrNr5NGrqv6wWKXCWGaUoJLKfN8ki7+t/BOKwULwr5Uy1UytOQw6E3OzW1B/gUjfVLfZfk11PnbyS+b8ILHSitNKBK3Gb6XNqDXVhvfP97rbmm76Um1dfB5qg==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand.Marquis@xxxxxxx, Wei.Chen@xxxxxxx, nd@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, julien@xxxxxxx
  • Delivery-date: Tue, 24 Aug 2021 11:59:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.08.2021 11:50, Penny Zheng wrote:
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -609,6 +609,29 @@ static void __init init_pdx(void)
>      }
>  }
>  
> +#ifdef CONFIG_STATIC_MEMORY
> +/* Static memory initialization */
> +static void __init init_staticmem_pages(void)
> +{
> +    unsigned int bank;
> +
> +    for ( bank = 0 ; bank < bootinfo.reserved_mem.nr_banks; bank++ )
> +    {
> +        if ( bootinfo.reserved_mem.bank[bank].xen_domain )
> +        {
> +            mfn_t bank_start = 
> _mfn(PFN_UP(bootinfo.reserved_mem.bank[bank].start));
> +            unsigned long bank_pages = 
> PFN_DOWN(bootinfo.reserved_mem.bank[bank].size);
> +            mfn_t bank_end = mfn_add(bank_start, bank_pages);
> +
> +            if ( mfn_x(bank_end) <= mfn_x(bank_start) )
> +                return;
> +
> +            free_staticmem_pages(mfn_to_page(bank_start), bank_pages, false);
> +        }
> +    }
> +}
> +#endif

If you moved the #ifdef inside the function body, ...

> @@ -736,6 +759,10 @@ static void __init setup_mm(void)
>      /* Add xenheap memory that was not already added to the boot allocator. 
> */
>      init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start),
>                         mfn_to_maddr(xenheap_mfn_end));
> +
> +#ifdef CONFIG_STATIC_MEMORY
> +    init_staticmem_pages();
> +#endif
>  }
>  #else /* CONFIG_ARM_64 */
>  static void __init setup_mm(void)
> @@ -789,6 +816,10 @@ static void __init setup_mm(void)
>  
>      setup_frametable_mappings(ram_start, ram_end);
>      max_page = PFN_DOWN(ram_end);
> +
> +#ifdef CONFIG_STATIC_MEMORY
> +    init_staticmem_pages();
> +#endif

... you could avoid this further #ifdef-ary.

> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -67,6 +67,23 @@ config MEM_ACCESS
>  config NEEDS_LIBELF
>       bool
>  
> +config STATIC_MEMORY
> +        bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
> +     depends on ARM

Inconsistent indentation. Both want to use a single tab.

> +     ---help---

We try to phase out "---help---", following Linux. Please use just
"help".

> +       Static Allocation refers to system or sub-system(domains) for
> +       which memory areas are pre-defined by configuration using physical
> +          address ranges.

Inconsistent indentation again. A tab and two spaces, uniformly.


> +       Those pre-defined memory, -- Static Memory, as parts of RAM reserved
> +       during system boot-up, shall never go to heap allocator or boot
> +       allocator for any use.

I find this hard to parse and I'm also unconvinced this belongs here.

> +       When enabled, memory can be statically allocated to a domain using
> +       the property "xen,static-mem" defined in the domain configuration.
> +
> +       If unsure, say Y.

As being unsupported, perhaps rather "N"?

> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -1519,7 +1519,6 @@ static void free_heap_pages(
>      spin_unlock(&heap_lock);
>  }
>  
> -
>  /*
>   * Following rules applied for page offline:
>   * Once a page is broken, it can't be assigned anymore

Stray change (I don't really mind it, but it doesn't belong here).

Jan




 


Rackspace

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