diff mbox

[5/5] tmem: allow tmem to be disabled with Kconfig

Message ID 1457987365-866-6-git-send-email-cardoe@cardoe.com (mailing list archive)
State New, archived
Headers show

Commit Message

Douglas Goldstein March 14, 2016, 8:29 p.m. UTC
Wrap the various tmem functions with the Kconfig generated CONFIG_TMEM
option allowing users to build Xen without tmem support.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
---
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 xen/arch/x86/hvm/hvm.c             |  4 ++++
 xen/arch/x86/x86_64/compat/entry.S |  4 ++++
 xen/arch/x86/x86_64/entry.S        |  4 ++++
 xen/common/Kconfig                 | 11 +++++++++++
 xen/common/Makefile                |  7 ++++---
 xen/include/xen/tmem.h             | 26 ++++++++++++++++++++++++++
 xen/include/xen/tmem_xen.h         | 11 +++++++++++
 7 files changed, 64 insertions(+), 3 deletions(-)

Comments

Jan Beulich March 15, 2016, 8:31 a.m. UTC | #1
>>> On 14.03.16 at 21:29, <cardoe@cardoe.com> wrote:
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -5311,6 +5311,10 @@ typedef unsigned long hvm_hypercall_t(
>  #define compat_grant_table_op hvm_grant_table_op_compat32
>  #define do_arch_1             paging_domctl_continuation
>  
> +#ifndef CONFIG_TMEM
> +#define do_tmem_op do_ni_hypercall
> +#endif

This being repeated in 3 places, wouldn't be better to put this in,
say, xen/hypercall.h, next to the function declaration?

> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -87,6 +87,17 @@ config LATE_HWDOM
>  
>  	  If unsure, say N.
>  
> +# Enables transactional memory support
> +config TMEM
> +	bool "Transaction Memory Support"

I think it should be "Transactional" here too.

> +	default y

No EXPERT dependency?

> +	---help---
> +	  fill me out

Indeed.

> +config TMEM_COMPAT
> +	bool
> +	default y if COMPAT && TMEM

I don't see the need for such an extra symbol:

> --- a/xen/common/Makefile
> +++ b/xen/common/Makefile
> @@ -49,8 +49,8 @@ obj-y += sysctl.o
>  obj-y += tasklet.o
>  obj-y += time.o
>  obj-y += timer.o
> -obj-y += tmem.o
> -obj-y += tmem_xen.o
> +obj-$(CONFIG_TMEM) += tmem.o
> +obj-$(CONFIG_TMEM) += tmem_xen.o
>  obj-y += trace.o
>  obj-y += version.o
>  obj-y += vm_event.o
> @@ -65,7 +65,8 @@ obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4
>  obj-$(perfc)       += perfc.o
>  obj-$(crash_debug) += gdbstub.o
>  
> -obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o tmem_xen.o xlat.o)
> +obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o xlat.o)
> +obj-$(CONFIG_TMEM_COMPAT) += compat/tmem_xen.o

tmem-y := tmem.o tmem_xen.o
tmem-$(CONFIG_COMPAT) += compat/tmem_xen.o
obj-$(CONFIG_TMEM) += $(tmem-y)

or some such would have the same effect.

Jan
Douglas Goldstein March 15, 2016, 6:28 p.m. UTC | #2
On 3/15/16 3:31 AM, Jan Beulich wrote:
>>>> On 14.03.16 at 21:29, <cardoe@cardoe.com> wrote:
>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -5311,6 +5311,10 @@ typedef unsigned long hvm_hypercall_t(
>>  #define compat_grant_table_op hvm_grant_table_op_compat32
>>  #define do_arch_1             paging_domctl_continuation
>>  
>> +#ifndef CONFIG_TMEM
>> +#define do_tmem_op do_ni_hypercall
>> +#endif
> 
> This being repeated in 3 places, wouldn't be better to put this in,
> say, xen/hypercall.h, next to the function declaration?

We can do this but I'd like to move the other ones from entry.S into
here as well in a follow on then.
Douglas Goldstein March 15, 2016, 7:04 p.m. UTC | #3
On 3/15/16 3:31 AM, Jan Beulich wrote:
>>>> On 14.03.16 at 21:29, <cardoe@cardoe.com> wrote:
>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -5311,6 +5311,10 @@ typedef unsigned long hvm_hypercall_t(
>>  #define compat_grant_table_op hvm_grant_table_op_compat32
>>  #define do_arch_1             paging_domctl_continuation
>>  
>> +#ifndef CONFIG_TMEM
>> +#define do_tmem_op do_ni_hypercall
>> +#endif
> 
> This being repeated in 3 places, wouldn't be better to put this in,
> say, xen/hypercall.h, next to the function declaration?
> 

Actually I tried this and it doesn't compile because that header isn't
included. Including that header into the relevant files (entry.S)
doesn't work either. Got a different suggestion?
Jan Beulich March 16, 2016, 8:36 a.m. UTC | #4
>>> On 15.03.16 at 20:04, <cardoe@cardoe.com> wrote:
> On 3/15/16 3:31 AM, Jan Beulich wrote:
>>>>> On 14.03.16 at 21:29, <cardoe@cardoe.com> wrote:
>>> --- a/xen/arch/x86/hvm/hvm.c
>>> +++ b/xen/arch/x86/hvm/hvm.c
>>> @@ -5311,6 +5311,10 @@ typedef unsigned long hvm_hypercall_t(
>>>  #define compat_grant_table_op hvm_grant_table_op_compat32
>>>  #define do_arch_1             paging_domctl_continuation
>>>  
>>> +#ifndef CONFIG_TMEM
>>> +#define do_tmem_op do_ni_hypercall
>>> +#endif
>> 
>> This being repeated in 3 places, wouldn't be better to put this in,
>> say, xen/hypercall.h, next to the function declaration?
> 
> Actually I tried this and it doesn't compile because that header isn't
> included. Including that header into the relevant files (entry.S)
> doesn't work either. Got a different suggestion?

Well, if the header can't be used in assembly files, so be it (for now
at least, as mentioned by Andrew on IRC). But this then still calls
for the #define to go into the header for the C source(s) sake.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 255a1d6..e05a4d9 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5311,6 +5311,10 @@  typedef unsigned long hvm_hypercall_t(
 #define compat_grant_table_op hvm_grant_table_op_compat32
 #define do_arch_1             paging_domctl_continuation
 
+#ifndef CONFIG_TMEM
+#define do_tmem_op do_ni_hypercall
+#endif
+
 static const struct {
     hvm_hypercall_t *native;
     hvm_hypercall_t *compat;
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 927439d..5218f8a 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -345,6 +345,10 @@  compat_crash_page_fault:
 #define compat_kexec_op do_ni_hypercall
 #endif
 
+#ifndef CONFIG_TMEM
+#define do_tmem_op do_ni_hypercall
+#endif
+
 #ifndef CONFIG_XENOPROF
 #define compat_xenoprof_op do_ni_hypercall
 #endif
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index dd7f114..cab9763 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -681,6 +681,10 @@  ENTRY(exception_table)
 #define do_kexec_op do_ni_hypercall
 #endif
 
+#ifndef CONFIG_TMEM
+#define do_tmem_op do_ni_hypercall
+#endif
+
 #ifndef CONFIG_XENOPROF
 #define do_xenoprof_op do_ni_hypercall
 #endif
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 8fbc46d..24eb60b 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -87,6 +87,17 @@  config LATE_HWDOM
 
 	  If unsure, say N.
 
+# Enables transactional memory support
+config TMEM
+	bool "Transaction Memory Support"
+	default y
+	---help---
+	  fill me out
+
+config TMEM_COMPAT
+	bool
+	default y if COMPAT && TMEM
+
 # Adds support for Xenoprof
 config XENOPROF
 	def_bool y
diff --git a/xen/common/Makefile b/xen/common/Makefile
index 82625a5..8a3c87a 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -49,8 +49,8 @@  obj-y += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
-obj-y += tmem.o
-obj-y += tmem_xen.o
+obj-$(CONFIG_TMEM) += tmem.o
+obj-$(CONFIG_TMEM) += tmem_xen.o
 obj-y += trace.o
 obj-y += version.o
 obj-y += vm_event.o
@@ -65,7 +65,8 @@  obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4
 obj-$(perfc)       += perfc.o
 obj-$(crash_debug) += gdbstub.o
 
-obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o tmem_xen.o xlat.o)
+obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o xlat.o)
+obj-$(CONFIG_TMEM_COMPAT) += compat/tmem_xen.o
 
 subdir-$(CONFIG_X86) += hvm
 
diff --git a/xen/include/xen/tmem.h b/xen/include/xen/tmem.h
index 32a542a..414a14d 100644
--- a/xen/include/xen/tmem.h
+++ b/xen/include/xen/tmem.h
@@ -11,9 +11,35 @@ 
 
 struct xen_sysctl_tmem_op;
 
+#ifdef CONFIG_TMEM
 extern int tmem_control(struct xen_sysctl_tmem_op *op);
 extern void tmem_destroy(void *);
 extern void *tmem_relinquish_pages(unsigned int, unsigned int);
 extern unsigned long tmem_freeable_pages(void);
+#else
+static inline int
+tmem_control(struct xen_sysctl_tmem_op *op)
+{
+    return -ENOSYS;
+}
+
+static inline void
+tmem_destroy(void *p)
+{
+    return;
+}
+
+static inline void *
+tmem_relinquish_pages(unsigned int x, unsigned int y)
+{
+    return NULL;
+}
+
+static inline unsigned long
+tmem_freeable_pages(void)
+{
+    return 0;
+}
+#endif /* CONFIG_TMEM */
 
 #endif /* __XEN_TMEM_H__ */
diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h
index b95bde9..33f75e0 100644
--- a/xen/include/xen/tmem_xen.h
+++ b/xen/include/xen/tmem_xen.h
@@ -64,6 +64,7 @@  static inline bool_t tmem_shared_auth(void)
     return opt_tmem_shared_auth;
 }
 
+#ifdef CONFIG_TMEM
 extern bool_t opt_tmem;
 static inline bool_t tmem_enabled(void)
 {
@@ -74,6 +75,16 @@  static inline void tmem_disable(void)
 {
     opt_tmem = 0;
 }
+#else
+static inline bool_t tmem_enabled(void)
+{
+    return false;
+}
+
+static inline void tmem_disable(void)
+{
+}
+#endif /* CONFIG_TMEM */
 
 /*
  * Memory free page list management