WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 09/11] x86: MTRR cleanup

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 09/11] x86: MTRR cleanup
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Wed, 09 Mar 2011 12:30:08 +0000
Delivery-date: Wed, 09 Mar 2011 04:38:16 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Remove unused and pointless bits from MTRR handling code. Move some
data items into .data.read_mostly. Adjust some types.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/Makefile
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/Makefile
@@ -2,4 +2,4 @@ obj-$(x86_32) += amd.o
 obj-$(x86_32) += cyrix.o
 obj-y += generic.o
 obj-y += main.o
-obj-y += state.o
+obj-$(x86_32) += state.o
--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/amd.c
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/amd.c
@@ -103,7 +103,7 @@ static int amd_validate_add_page(unsigne
        return 0;
 }
 
-static struct mtrr_ops amd_mtrr_ops = {
+static const struct mtrr_ops amd_mtrr_ops = {
        .vendor            = X86_VENDOR_AMD,
        .set               = amd_set_mtrr,
        .get               = amd_get_mtrr,
--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/cyrix.c
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/cyrix.c
@@ -359,7 +359,7 @@ cyrix_arr_init(void)
 }
 #endif
 
-static struct mtrr_ops cyrix_mtrr_ops = {
+static const struct mtrr_ops cyrix_mtrr_ops = {
        .vendor            = X86_VENDOR_CYRIX,
 //     .init              = cyrix_arr_init,
        .set_all           = cyrix_set_all,
--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/generic.c
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/generic.c
@@ -467,7 +467,7 @@ int positive_have_wrcomb(void)
 
 /* generic structure...
  */
-struct mtrr_ops generic_mtrr_ops = {
+const struct mtrr_ops generic_mtrr_ops = {
        .use_intel_if      = 1,
        .set_all           = generic_set_all,
        .get               = generic_get_mtrr,
--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/main.c
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/main.c
@@ -50,16 +50,15 @@
 #define        get_cpu()       smp_processor_id()
 #define put_cpu()      do {} while(0)
 
-u32 num_var_ranges = 0;
+u32 __read_mostly num_var_ranges = 0;
 
-unsigned int *usage_table;
+unsigned int *__read_mostly usage_table;
 static DEFINE_MUTEX(mtrr_mutex);
 
-u64 size_or_mask, size_and_mask;
+u64 __read_mostly size_or_mask;
+u64 __read_mostly size_and_mask;
 
-static struct mtrr_ops * mtrr_ops[X86_VENDOR_NUM] = {};
-
-struct mtrr_ops * mtrr_if = NULL;
+const struct mtrr_ops *__read_mostly mtrr_if = NULL;
 
 static void set_mtrr(unsigned int reg, unsigned long base,
                     unsigned long size, mtrr_type type);
@@ -70,7 +69,7 @@ extern int arr3_protected;
 #define arr3_protected 0
 #endif
 
-static const char *mtrr_strings[MTRR_NUM_TYPES] =
+static const char *const mtrr_strings[MTRR_NUM_TYPES] =
 {
     "uncachable",               /* 0 */
     "write-combining",          /* 1 */
@@ -81,16 +80,20 @@ static const char *mtrr_strings[MTRR_NUM
     "write-back",               /* 6 */
 };
 
-const char *mtrr_attrib_to_str(int x)
+static const char *mtrr_attrib_to_str(int x)
 {
        return (x <= 6) ? mtrr_strings[x] : "?";
 }
 
-void set_mtrr_ops(struct mtrr_ops * ops)
+#ifndef CONFIG_X86_64
+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
+
+void set_mtrr_ops(const struct mtrr_ops * ops)
 {
        if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
                mtrr_ops[ops->vendor] = ops;
 }
+#endif
 
 /*  Returns non-zero if we have the write-combining memory type  */
 static int have_wrcomb(void)
@@ -472,7 +475,7 @@ static int mtrr_check(unsigned long base
  *     failures and do not wish system log messages to be sent.
  */
 
-int
+int __init
 mtrr_add(unsigned long base, unsigned long size, unsigned int type,
         char increment)
 {
@@ -565,7 +568,7 @@ int mtrr_del_page(int reg, unsigned long
  *     code.
  */
 
-int
+int __init
 mtrr_del(int reg, unsigned long base, unsigned long size)
 {
        if (mtrr_check(base, size))
@@ -573,9 +576,6 @@ mtrr_del(int reg, unsigned long base, un
        return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
 }
 
-EXPORT_SYMBOL(mtrr_add);
-EXPORT_SYMBOL(mtrr_del);
-
 /* HACK ALERT!
  * These should be called implicitly, but we can't yet until all the initcall
  * stuff is done...
--- 2011-02-10.orig/xen/arch/x86/cpu/mtrr/mtrr.h
+++ 2011-02-10/xen/arch/x86/cpu/mtrr/mtrr.h
@@ -52,7 +52,7 @@ extern int generic_get_free_region(unsig
 extern int generic_validate_add_page(unsigned long base, unsigned long size,
                                     unsigned int type);
 
-extern struct mtrr_ops generic_mtrr_ops;
+extern const struct mtrr_ops generic_mtrr_ops;
 
 extern int positive_have_wrcomb(void);
 
@@ -70,10 +70,10 @@ void set_mtrr_prepare_save(struct set_mt
 
 void get_mtrr_state(void);
 
-extern void set_mtrr_ops(struct mtrr_ops * ops);
+extern void set_mtrr_ops(const struct mtrr_ops *);
 
 extern u64 size_or_mask, size_and_mask;
-extern struct mtrr_ops * mtrr_if;
+extern const struct mtrr_ops *mtrr_if;
 
 #define is_cpu(vnd)    (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
 #define use_intel()    (mtrr_if && mtrr_if->use_intel_if == 1)
@@ -81,6 +81,5 @@ extern struct mtrr_ops * mtrr_if;
 extern unsigned int num_var_ranges;
 
 void mtrr_state_warn(void);
-const char *mtrr_attrib_to_str(int x);
 void mtrr_wrmsr(unsigned int msr, uint64_t msr_content);
 


Attachment: x86-mtrr-cleanup.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 09/11] x86: MTRR cleanup, Jan Beulich <=