diff mbox series

[17/36] xen/arm: add get_max_color function

Message ID 20220304174701.1453977-18-marco.solieri@minervasys.tech (mailing list archive)
State New, archived
Headers show
Series Arm cache coloring | expand

Commit Message

Marco Solieri March 4, 2022, 5:46 p.m. UTC
From: Luca Miccio <lucmiccio@gmail.com>

In order to initialize the colored allocator data structure, the maximum
amount of colors defined by the hardware has to be know.
Add a helper function that returns this information.

Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
---
 xen/arch/arm/coloring.c             | 5 +++++
 xen/arch/arm/include/asm/coloring.h | 8 ++++++++
 2 files changed, 13 insertions(+)

Comments

Julien Grall March 11, 2022, 7:09 p.m. UTC | #1
Hi Marco,

On 04/03/2022 17:46, Marco Solieri wrote:
> From: Luca Miccio <lucmiccio@gmail.com>
> 
> In order to initialize the colored allocator data structure, the maximum
> amount of colors defined by the hardware has to be know.
> Add a helper function that returns this information.
> 
> Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
> ---
>   xen/arch/arm/coloring.c             | 5 +++++
>   xen/arch/arm/include/asm/coloring.h | 8 ++++++++

This helper is simple enough that I think it would be better to fold in 
the first patch using it.

>   2 files changed, 13 insertions(+)
> 
> diff --git a/xen/arch/arm/coloring.c b/xen/arch/arm/coloring.c
> index 4748d717d6..d1ac193a80 100644
> --- a/xen/arch/arm/coloring.c
> +++ b/xen/arch/arm/coloring.c
> @@ -209,6 +209,11 @@ unsigned long color_from_page(struct page_info *pg)
>     return ((addr_col_mask & page_to_maddr(pg)) >> PAGE_SHIFT);
>   }
>   
> +uint32_t get_max_colors(void)
> +{
> +    return max_col_num;
> +}
> +
>   bool __init coloring_init(void)
>   {
>       int i;
> diff --git a/xen/arch/arm/include/asm/coloring.h b/xen/arch/arm/include/asm/coloring.h
> index 318e2a4521..22e67dc9d8 100644
> --- a/xen/arch/arm/include/asm/coloring.h
> +++ b/xen/arch/arm/include/asm/coloring.h
> @@ -49,6 +49,9 @@ void coloring_dump_info(struct domain *d);
>    * specifications.
>    */
>   unsigned long color_from_page(struct page_info *pg);
> +
> +/* Return the maximum available number of colors supported by the hardware */
> +uint32_t get_max_colors(void);
>   #else /* !CONFIG_COLORING */
>   static inline bool __init coloring_init(void)
>   {
> @@ -59,5 +62,10 @@ static inline void coloring_dump_info(struct domain *d)
>   {
>       return;
>   }
> +
> +static inline uint32_t get_max_colors(void)
> +{
> +    return 0;
> +}
>   #endif /* CONFIG_COLORING */
>   #endif /* !__ASM_ARM_COLORING_H__ */

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/coloring.c b/xen/arch/arm/coloring.c
index 4748d717d6..d1ac193a80 100644
--- a/xen/arch/arm/coloring.c
+++ b/xen/arch/arm/coloring.c
@@ -209,6 +209,11 @@  unsigned long color_from_page(struct page_info *pg)
   return ((addr_col_mask & page_to_maddr(pg)) >> PAGE_SHIFT);
 }
 
+uint32_t get_max_colors(void)
+{
+    return max_col_num;
+}
+
 bool __init coloring_init(void)
 {
     int i;
diff --git a/xen/arch/arm/include/asm/coloring.h b/xen/arch/arm/include/asm/coloring.h
index 318e2a4521..22e67dc9d8 100644
--- a/xen/arch/arm/include/asm/coloring.h
+++ b/xen/arch/arm/include/asm/coloring.h
@@ -49,6 +49,9 @@  void coloring_dump_info(struct domain *d);
  * specifications.
  */
 unsigned long color_from_page(struct page_info *pg);
+
+/* Return the maximum available number of colors supported by the hardware */
+uint32_t get_max_colors(void);
 #else /* !CONFIG_COLORING */
 static inline bool __init coloring_init(void)
 {
@@ -59,5 +62,10 @@  static inline void coloring_dump_info(struct domain *d)
 {
     return;
 }
+
+static inline uint32_t get_max_colors(void)
+{
+    return 0;
+}
 #endif /* CONFIG_COLORING */
 #endif /* !__ASM_ARM_COLORING_H__ */