Skip to contentSkip to conversation

xen: Put wait.c behind CONFIG_WAIT

PATCH Superseded Jason Andryuk 4 participants 7 messages Feb 11 – Feb 13

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Put wait.c behind CONFIG_WAIT

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

---
 xen/arch/x86/x86_64/entry.S |  2 ++
 xen/common/Kconfig          |  4 ++++
 xen/common/Makefile         |  2 +-
 xen/include/xen/sched.h     |  2 ++
 xen/include/xen/wait.h      | 11 +++++++++--
 5 files changed, 18 insertions(+), 3 deletions(-)
xen/arch/x86/x86_64/entry.S +2 -0
index ca446c6ff0..adb570c07e 100644
@@ -664,7 +664,9 @@ FUNC(continue_pv_domain)
         ALTERNATIVE "", "mov $2, %eax; incsspd %eax", X86_FEATURE_XEN_SHSTK
 #endif
 
+#ifdef CONFIG_WAIT
         call  check_wakeup_from_wait
+#endif
 ret_from_intr:
         GET_CURRENT(bx)
         testb $3, UREGS_cs(%rsp)
xen/common/Kconfig +4 -0
index d7e79e752a..ab3f24cb4f 100644
@@ -173,10 +173,14 @@ config HAS_VMAP
 config LIBFDT
 	bool
 
+config WAIT
+	bool
+
 config VM_EVENT
 	bool "Memory Access and VM events"
 	depends on HVM
 	default X86
+	select WAIT
 	help
 
 	  Framework to configure memory access types for guests and receive
xen/common/Makefile +1 -1
index 4fc0c15088..ef2c5ddd4e 100644
@@ -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_WAIT) += wait.o
 obj-bin-y += warning.init.o
 obj-y += xmalloc_tlsf.o
 
xen/include/xen/sched.h +2 -0
index 1268632344..f232f2731e 100644
@@ -293,7 +293,9 @@ struct vcpu
     /* Multicall information. */
     struct mc_state  mc_state;
 
+#ifdef CONFIG_WAIT
     struct waitqueue_vcpu *waitqueue_vcpu;
+#endif
 
     struct evtchn_fifo_vcpu *evtchn_fifo;
 
xen/include/xen/wait.h +9 -2
index 1c68bc564b..d7d83adef1 100644
@@ -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_WAIT
+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__ */
Signature · 1 line
2.53.0
#1 lore raw
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

~Andrew

#2 lore raw
Quoted 14 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Quoted 6 lines

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

I was focused on x86, and didn't realize this was used by ARM. I think I noticed the lack of check_wakeup_from_wait() calls on ARM. What did I not notice? Are you saying wait.c should only be built for x86?

Quoted 4 lines

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

Yes. I used CONFIG_WAIT since it matched wait.c. I considered CONFIG_WAITQUEUE, but went with the shorter option. Re-using CONFIG_VM_EVENT would be fine with me. I didn't use it in this submission since the waitqueue functionality is more generic.

Regards,
Jason

#3 lore raw
In reply to Andrew Cooper
Quoted 14 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Quoted 6 lines

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

But if we want it compiled out altogether on Arm, ...

Quoted 4 lines

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

... don't we need a separate kconfig control, for it to be selected only on x86 (or for it to be dependent on x86, and then imply-ed)? Imo CONFIG_WAITQUEUE would be okay, as long as it won't have a prompt. We'd then simply want to prevent further select-s / imply-s to appear.

Jan

#4 lore raw
Quoted 29 lines · Jan Beulich
Quoted 14 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Quoted 6 lines

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

But if we want it compiled out altogether on Arm, ...

Quoted 4 lines

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

Quoted 4 lines

... don't we need a separate kconfig control, for it to be selected only on x86 (or for it to be dependent on x86, and then imply-ed)? Imo CONFIG_WAITQUEUE would be okay, as long as it won't have a prompt. We'd then simply want to prevent further select-s / imply-s to appear.

ARM VM_EVENT=y won't link without wait.o. Undefined references to:
wake_up_nr
prepare_to_wait
finish_wait
destroy_waitqueue_head
init_waitqueue_head

So I think that points to re-using my original patch, but with either CONFIG_WAITQUEUE or CONFIG_VM_EVENT. Since CONFIG_VM_EVENT is the only user, and we don't want further uses, I would use that. But I am open to either.

Regards,
Jason

#5 lore raw
Quoted 35 lines · Jason Andryuk
Quoted 29 lines · Jan Beulich
Quoted 14 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Quoted 6 lines

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

But if we want it compiled out altogether on Arm, ...

Quoted 4 lines

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

Quoted 4 lines

... don't we need a separate kconfig control, for it to be selected only on x86 (or for it to be dependent on x86, and then imply-ed)? Imo CONFIG_WAITQUEUE would be okay, as long as it won't have a prompt. We'd then simply want to prevent further select-s / imply-s to appear.

Quoted 6 lines

ARM VM_EVENT=y won't link without wait.o. Undefined references to:
wake_up_nr
prepare_to_wait
finish_wait
destroy_waitqueue_head
init_waitqueue_head

Hmm, okay, assuming that then also actually works, ...

Quoted 3 lines

So I think that points to re-using my original patch, but with either CONFIG_WAITQUEUE or CONFIG_VM_EVENT. Since CONFIG_VM_EVENT is the only user, and we don't want further uses, I would use that.

... please do.

Jan

#6 lore raw
In reply to Jason Andryuk
Quoted 42 lines · Jason Andryuk
Quoted 29 lines · Jan Beulich
Quoted 14 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk

wait.c is only used by vm_event.c. Make CONFIG_VM_EVENT select CONFIG_WAIT, and use CONFIG_WAIT to control building it.

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.

I'd really rather see the API/ABI changes required to purge wait.c entirely, but I guess this will do in the short term.

Quoted 6 lines

Two things want further thought.

First, because ARM uses per-vCPU stacks not per-pCPU stacks, it doesn't need this infrastructure in the first place, but it looks like it's still compiled in and half wired up.  I suppose you don't notice because you compile out VM_EVENT on ARM too?

But if we want it compiled out altogether on Arm, ...

Quoted 4 lines

Second CONFIG_WAIT isn't great name because there are many things it could be.  I'd be tempted to just reuse CONFIG_VM_EVENT and go without CONFIG_WAIT.  I do not want to see any new users of wait.c, and it will disappear at some point.

Quoted 4 lines

... don't we need a separate kconfig control, for it to be selected only on x86 (or for it to be dependent on x86, and then imply-ed)? Imo CONFIG_WAITQUEUE would be okay, as long as it won't have a prompt. We'd then simply want to prevent further select-s / imply-s to appear.

ARM VM_EVENT=y won't link without wait.o. Undefined references to:
wake_up_nr
prepare_to_wait
finish_wait
destroy_waitqueue_head
init_waitqueue_head

Quoted 4 lines

So I think that points to re-using my original patch, but with either CONFIG_WAITQUEUE or CONFIG_VM_EVENT. Since CONFIG_VM_EVENT is the only user, and we don't want further uses, I would use that. But I am open to either.

I think hiding behind CONFIG_VM_EVENT is better, we want to avoid new instances of waitqueue (at least in it's current state), so not sure it makes a lot of sense to add it under a different Kconfig option if our intention is for waitqueue to only be used with VM events.

Thanks, Roger.