[PATCH v2] xen: Put wait.c behind CONFIG_VM_EVENT

Jason Andryuk posted 1 patch 1 month, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260213225635.346187-1-jason.andryuk@amd.com
xen/arch/x86/x86_64/entry.S |  2 ++
xen/common/Makefile         |  2 +-
xen/include/xen/sched.h     |  2 ++
xen/include/xen/wait.h      | 11 +++++++++--
4 files changed, 14 insertions(+), 3 deletions(-)
[PATCH v2] xen: Put wait.c behind CONFIG_VM_EVENT
Posted by Jason Andryuk 1 month, 4 weeks ago
wait.c is only used by vm_event.c, so build it when CONFIG_VM_EVENT is
selected.

Provide stubs of functions called from common code.  entry.S needs an
ifdef to hide the symbol from the assembly.

Also conditionalize .waitqueue_vcpu in struct vcpu to save space.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
v2:
Use CONFIG_VM_EVENT
---
 xen/arch/x86/x86_64/entry.S |  2 ++
 xen/common/Makefile         |  2 +-
 xen/include/xen/sched.h     |  2 ++
 xen/include/xen/wait.h      | 11 +++++++++--
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index ca446c6ff0..8b83082413 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -664,7 +664,9 @@ FUNC(continue_pv_domain)
         ALTERNATIVE "", "mov $2, %eax; incsspd %eax", X86_FEATURE_XEN_SHSTK
 #endif
 
+#ifdef CONFIG_VM_EVENT
         call  check_wakeup_from_wait
+#endif
 ret_from_intr:
         GET_CURRENT(bx)
         testb $3, UREGS_cs(%rsp)
diff --git a/xen/common/Makefile b/xen/common/Makefile
index 4fc0c15088..dac8b711cd 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -61,7 +61,7 @@ obj-y += virtual_region.o
 obj-$(CONFIG_VM_EVENT) += vm_event.o
 obj-$(CONFIG_HAS_VMAP) += vmap.o
 obj-y += vsprintf.o
-obj-y += wait.o
+obj-$(CONFIG_VM_EVENT) += wait.o
 obj-bin-y += warning.init.o
 obj-y += xmalloc_tlsf.o
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 1268632344..40a35fc15c 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -293,7 +293,9 @@ struct vcpu
     /* Multicall information. */
     struct mc_state  mc_state;
 
+#ifdef CONFIG_VM_EVENT
     struct waitqueue_vcpu *waitqueue_vcpu;
+#endif
 
     struct evtchn_fifo_vcpu *evtchn_fifo;
 
diff --git a/xen/include/xen/wait.h b/xen/include/xen/wait.h
index 1c68bc564b..e3510431ac 100644
--- a/xen/include/xen/wait.h
+++ b/xen/include/xen/wait.h
@@ -49,11 +49,18 @@ do {                                            \
 } while (0)
 
 /* Private functions. */
-int init_waitqueue_vcpu(struct vcpu *v);
-void destroy_waitqueue_vcpu(struct vcpu *v);
 void prepare_to_wait(struct waitqueue_head *wq);
 void wait(void);
 void finish_wait(struct waitqueue_head *wq);
+
+#ifdef CONFIG_VM_EVENT
+int init_waitqueue_vcpu(struct vcpu *v);
+void destroy_waitqueue_vcpu(struct vcpu *v);
 void check_wakeup_from_wait(void);
+#else
+static inline int init_waitqueue_vcpu(struct vcpu *v) { return 0; }
+static inline void destroy_waitqueue_vcpu(struct vcpu *v) {}
+static inline void check_wakeup_from_wait(void) {}
+#endif
 
 #endif /* __XEN_WAIT_H__ */
-- 
2.53.0
Re: [PATCH v2] xen: Put wait.c behind CONFIG_VM_EVENT
Posted by Andrew Cooper 1 month, 4 weeks ago
On 13/02/2026 10:56 pm, Jason Andryuk wrote:
> wait.c is only used by vm_event.c, so build it when CONFIG_VM_EVENT is
> selected.
>
> Provide stubs of functions called from common code.  entry.S needs an
> ifdef to hide the symbol from the assembly.
>
> Also conditionalize .waitqueue_vcpu in struct vcpu to save space.
>
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

This will do.  It's probably not worth the effort to move the file or
untangle it in ARM, given that it's intended for /dev/null.

~Andrew