diff mbox series

[v2,2/2] xen: remove init_constructors out of start_xen

Message ID 1238367271.9969045.1659494647714@mail-kr2-1 (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] xen: add late init call in start_xen | expand

Commit Message

Boyoun Park Aug. 3, 2022, 2:44 a.m. UTC
From: Boyoun Park <boyoun.park@samsung.com>
Date: Wed, 3 Aug 2022 10:31:55 +0900
Subject: [PATCH v2 2/2] xen: remove init_constructors out of start_xen

This patch removed init_constructors from start_xen
by using __late_initcall.
It can be applied to other init functions in start_xen
so that only main init functions are included in there.

To use __late_initcall, the format of a function should
be changed according to initcall. Thus, the return type
of init_constructors function is changed in this patch.

Change-Id: Ife13484d346cff15983aacbfefde21d508f4690a
Signed-off-by: Boyoun Park <boyoun.park@samsung.com>
---
 xen/arch/arm/setup.c  | 2 --
 xen/arch/x86/setup.c  | 2 --
 xen/include/xen/lib.h | 2 +-
 xen/lib/ctors.c       | 6 +++++-
 4 files changed, 6 insertions(+), 6 deletions(-)

Comments

Jan Beulich Aug. 3, 2022, 7:10 a.m. UTC | #1
On 03.08.2022 04:44, Boyoun Park wrote:
> From: Boyoun Park <boyoun.park@samsung.com>
> Date: Wed, 3 Aug 2022 10:31:55 +0900
> Subject: [PATCH v2 2/2] xen: remove init_constructors out of start_xen
> 
> This patch removed init_constructors from start_xen
> by using __late_initcall.
> It can be applied to other init functions in start_xen
> so that only main init functions are included in there.

Only if the relative order in which they're called doesn't matter. In
fact ...

> To use __late_initcall, the format of a function should
> be changed according to initcall. Thus, the return type
> of init_constructors function is changed in this patch.

... you're changing the point in time when the constructors are called.
This _may_ be fine, but the reason(s) why it is would need supplying in
the description.

> Change-Id: Ife13484d346cff15983aacbfefde21d508f4690a

Please omit such.

> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -211,7 +211,7 @@ extern void add_taint(unsigned int taint);
>  struct cpu_user_regs;
>  void cf_check dump_execstate(struct cpu_user_regs *);
>  
> -void init_constructors(void);
> +int init_constructors(void);

This wants to be removed, with ...

> --- a/xen/lib/ctors.c
> +++ b/xen/lib/ctors.c
> @@ -4,7 +4,7 @@
>  typedef void (*ctor_func_t)(void);
>  extern const ctor_func_t __ctors_start[], __ctors_end[];
>  
> -void __init init_constructors(void)
> +int __init init_constructors(void)

... static added here.

> @@ -12,8 +12,12 @@ void __init init_constructors(void)
>  
>      /* Putting this here seems as good (or bad) as any other place. */
>      BUILD_BUG_ON(sizeof(size_t) != sizeof(ssize_t));
> +
> +    return 0;
>  }
>  
> +__late_initcall(init_constructors);
> +
>  /*
>   * Local variables:
>   * mode: C

We prefer to not leave a blank line between the function referenced by
__initcall et al and the __initcall() itself.

Jan
diff mbox series

Patch

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 332a207..6c88b31 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -1056,8 +1056,6 @@  void __init start_xen(unsigned long boot_phys_offset,
 
     init_trace_bufs();
 
-    init_constructors();
-
     console_endboot();
 
     /* Hide UART from DOM0 if we're using it */
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 5dc6654..603100c 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1941,8 +1941,6 @@  void __init noreturn __start_xen(unsigned long mbi_p)
 
     init_trace_bufs();
 
-    init_constructors();
-
     console_endboot();
 
     /* Hide UART from DOM0 if we're using it */
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 05ee1e1..8e08c29 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -211,7 +211,7 @@  extern void add_taint(unsigned int taint);
 struct cpu_user_regs;
 void cf_check dump_execstate(struct cpu_user_regs *);
 
-void init_constructors(void);
+int init_constructors(void);
 
 /*
  * bsearch - binary search an array of elements
diff --git a/xen/lib/ctors.c b/xen/lib/ctors.c
index 5bdc591..b54144b 100644
--- a/xen/lib/ctors.c
+++ b/xen/lib/ctors.c
@@ -4,7 +4,7 @@ 
 typedef void (*ctor_func_t)(void);
 extern const ctor_func_t __ctors_start[], __ctors_end[];
 
-void __init init_constructors(void)
+int __init init_constructors(void)
 {
     const ctor_func_t *f;
     for ( f = __ctors_start; f < __ctors_end; ++f )
@@ -12,8 +12,12 @@  void __init init_constructors(void)
 
     /* Putting this here seems as good (or bad) as any other place. */
     BUILD_BUG_ON(sizeof(size_t) != sizeof(ssize_t));
+
+    return 0;
 }
 
+__late_initcall(init_constructors);
+
 /*
  * Local variables:
  * mode: C