[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86-64: reduce symbol table size



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1247500190 -3600
# Node ID 75e63b73075a7bb89db61219dd6cdd91b423ea2f
# Parent  c0cb307d927f7c9cd64a726c3e2124c4c1d7c970
x86-64: reduce symbol table size

With all of Xen's symbols sitting within a 2Gb range on x86-64, they
can be referred to by the kallsyms-like offset table using 4- instead
of 8-byte slots.

The marker table can use 4-byte slots in all cases, just like the
table entry counts can (though that's only a minor improvement).

If ia64's PERCPU_ADDR got moved down to (KERNEL_START + 2Gb -
PERCPU_PAGE_SIZE), it could also utilize the more compact form.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/common/symbols-dummy.c   |   16 +++++++++-----
 xen/common/symbols.c         |   34 ++++++++++++++++++-------------
 xen/include/asm-x86/config.h |   16 +++++++++-----
 xen/tools/symbols.c          |   47 ++++++++++++-------------------------------
 4 files changed, 54 insertions(+), 59 deletions(-)

diff -r c0cb307d927f -r 75e63b73075a xen/common/symbols-dummy.c
--- a/xen/common/symbols-dummy.c        Mon Jul 13 12:35:34 2009 +0100
+++ b/xen/common/symbols-dummy.c        Mon Jul 13 16:49:50 2009 +0100
@@ -6,11 +6,15 @@
 #include <xen/config.h>
 #include <xen/types.h>
 
-unsigned long symbols_addresses[1];
-unsigned long symbols_num_syms;
-u8 symbols_names[1];
+#ifdef SYMBOLS_ORIGIN
+const unsigned int symbols_offsets[1];
+#else
+const unsigned long symbols_addresses[1];
+#endif
+const unsigned int symbols_num_syms;
+const u8 symbols_names[1];
 
-u8 symbols_token_table[1];
-u16 symbols_token_index[1];
+const u8 symbols_token_table[1];
+const u16 symbols_token_index[1];
 
-unsigned long symbols_markers[1];
+const unsigned int symbols_markers[1];
diff -r c0cb307d927f -r 75e63b73075a xen/common/symbols.c
--- a/xen/common/symbols.c      Mon Jul 13 12:35:34 2009 +0100
+++ b/xen/common/symbols.c      Mon Jul 13 16:49:50 2009 +0100
@@ -18,21 +18,27 @@
 #include <xen/string.h>
 #include <xen/spinlock.h>
 
-extern unsigned long symbols_addresses[];
-extern unsigned long symbols_num_syms;
-extern u8 symbols_names[];
+#ifdef SYMBOLS_ORIGIN
+extern const unsigned int symbols_offsets[1];
+#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n])
+#else
+extern const unsigned long symbols_addresses[];
+#define symbols_address(n) symbols_addresses[n]
+#endif
+extern const unsigned int symbols_num_syms;
+extern const u8 symbols_names[];
 
-extern u8 symbols_token_table[];
-extern u16 symbols_token_index[];
+extern const u8 symbols_token_table[];
+extern const u16 symbols_token_index[];
 
-extern unsigned long symbols_markers[];
+extern const unsigned int symbols_markers[];
 
 /* expand a compressed symbol data into the resulting uncompressed string,
    given the offset to where the symbol is in the compressed stream */
 static unsigned int symbols_expand_symbol(unsigned int off, char *result)
 {
     int len, skipped_first = 0;
-    u8 *tptr, *data;
+    const u8 *tptr, *data;
 
     /* get the compressed symbol length from the first symbol byte */
     data = &symbols_names[off];
@@ -70,7 +76,7 @@ static unsigned int symbols_expand_symbo
  * symbols array */
 static unsigned int get_symbol_offset(unsigned long pos)
 {
-    u8 *name;
+    const u8 *name;
     int i;
 
     /* use the closest marker we have. We have markers every 256 positions,
@@ -107,13 +113,13 @@ const char *symbols_lookup(unsigned long
 
     while (high-low > 1) {
         mid = (low + high) / 2;
-        if (symbols_addresses[mid] <= addr) low = mid;
+        if (symbols_address(mid) <= addr) low = mid;
         else high = mid;
     }
 
     /* search for the first aliased symbol. Aliased symbols are
            symbols with the same address */
-    while (low && symbols_addresses[low - 1] == symbols_addresses[low])
+    while (low && symbols_address(low - 1) == symbols_address(low))
         --low;
 
         /* Grab name */
@@ -121,8 +127,8 @@ const char *symbols_lookup(unsigned long
 
     /* Search for next non-aliased symbol */
     for (i = low + 1; i < symbols_num_syms; i++) {
-        if (symbols_addresses[i] > symbols_addresses[low]) {
-            symbol_end = symbols_addresses[i];
+        if (symbols_address(i) > symbols_address(low)) {
+            symbol_end = symbols_address(i);
             break;
         }
     }
@@ -132,8 +138,8 @@ const char *symbols_lookup(unsigned long
         symbol_end = is_kernel_inittext(addr) ?
             (unsigned long)_einittext : (unsigned long)_etext;
 
-    *symbolsize = symbol_end - symbols_addresses[low];
-    *offset = addr - symbols_addresses[low];
+    *symbolsize = symbol_end - symbols_address(low);
+    *offset = addr - symbols_address(low);
     return namebuf;
 }
 
diff -r c0cb307d927f -r 75e63b73075a xen/include/asm-x86/config.h
--- a/xen/include/asm-x86/config.h      Mon Jul 13 12:35:34 2009 +0100
+++ b/xen/include/asm-x86/config.h      Mon Jul 13 16:49:50 2009 +0100
@@ -122,10 +122,12 @@ extern unsigned int video_mode, video_fl
 #define PML4_ADDR(_slot)                             \
     ((((_slot ## UL) >> 8) * 0xffff000000000000UL) | \
      (_slot ## UL << PML4_ENTRY_BITS))
+#define GB(_gb) (_gb ## UL << 30)
 #else
 #define PML4_ENTRY_BYTES (1 << PML4_ENTRY_BITS)
 #define PML4_ADDR(_slot)                             \
     (((_slot >> 8) * 0xffff000000000000) | (_slot << PML4_ENTRY_BITS))
+#define GB(_gb) (_gb << 30)
 #endif
 
 /*
@@ -210,22 +212,22 @@ extern unsigned int video_mode, video_fl
 #define PERDOMAIN_MBYTES        (PML4_ENTRY_BYTES >> (20 + PAGETABLE_ORDER))
 /* Slot 261: machine-to-phys conversion table (16GB). */
 #define RDWR_MPT_VIRT_START     (PML4_ADDR(261))
-#define RDWR_MPT_VIRT_END       (RDWR_MPT_VIRT_START + (16UL<<30))
+#define RDWR_MPT_VIRT_END       (RDWR_MPT_VIRT_START + GB(16))
 /* Slot 261: page-frame information array (16GB). */
 #define FRAMETABLE_VIRT_START   (RDWR_MPT_VIRT_END)
-#define FRAMETABLE_VIRT_END     (FRAMETABLE_VIRT_START + (16UL<<30))
+#define FRAMETABLE_VIRT_END     (FRAMETABLE_VIRT_START + GB(16))
 /* Slot 261: ioremap()/fixmap area (16GB). */
 #define IOREMAP_VIRT_START      (FRAMETABLE_VIRT_END)
-#define IOREMAP_VIRT_END        (IOREMAP_VIRT_START + (16UL<<30))
+#define IOREMAP_VIRT_END        (IOREMAP_VIRT_START + GB(16))
 /* Slot 261: compatibility machine-to-phys conversion table (1GB). */
 #define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END
-#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + (1UL << 30))
+#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + GB(1))
 /* Slot 261: high read-only compat machine-to-phys conversion table (1GB). */
 #define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END
-#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + (1UL << 30))
+#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + GB(1))
 /* Slot 261: xen text, static data and bss (1GB). */
 #define XEN_VIRT_START          (HIRO_COMPAT_MPT_VIRT_END)
-#define XEN_VIRT_END            (XEN_VIRT_START + (1UL << 30))
+#define XEN_VIRT_END            (XEN_VIRT_START + GB(1))
 /* Slot 262-263: A direct 1:1 mapping of all of physical memory. */
 #define DIRECTMAP_VIRT_START    (PML4_ADDR(262))
 #define DIRECTMAP_VIRT_END      (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*2)
@@ -258,6 +260,8 @@ extern unsigned int video_mode, video_fl
 #define __HYPERVISOR_DS64 0x0000
 #define __HYPERVISOR_DS32 0xe010
 #define __HYPERVISOR_DS   __HYPERVISOR_DS64
+
+#define SYMBOLS_ORIGIN XEN_VIRT_START
 
 /* For generic assembly code: use macros to define operation/operand sizes. */
 #define __OS          "q"  /* Operation Suffix */
diff -r c0cb307d927f -r 75e63b73075a xen/tools/symbols.c
--- a/xen/tools/symbols.c       Mon Jul 13 12:35:34 2009 +0100
+++ b/xen/tools/symbols.c       Mon Jul 13 16:49:50 2009 +0100
@@ -108,10 +108,7 @@ static int read_symbol(FILE *in, struct 
        else if (toupper((uint8_t)stype) == 'A')
        {
                /* Keep these useful absolute symbols */
-               if (strcmp(sym, "__kernel_syscall_via_break") &&
-                   strcmp(sym, "__kernel_syscall_via_epc") &&
-                   strcmp(sym, "__kernel_sigtramp") &&
-                   strcmp(sym, "__gp"))
+               if (strcmp(sym, "__gp"))
                        return -1;
 
        }
@@ -134,24 +131,6 @@ static int read_symbol(FILE *in, struct 
 
 static int symbol_valid(struct sym_entry *s)
 {
-       /* Symbols which vary between passes.  Passes 1 and 2 must have
-        * identical symbol lists.  The symbols_* symbols below are only added
-        * after pass 1, they would be included in pass 2 when --all-symbols is
-        * specified so exclude them to get a stable symbol list.
-        */
-       static char *special_symbols[] = {
-               "symbols_addresses",
-               "symbols_num_syms",
-               "symbols_names",
-               "symbols_markers",
-               "symbols_token_table",
-               "symbols_token_index",
-
-       /* Exclude linker generated symbols which vary between passes */
-               "_SDA_BASE_",           /* ppc */
-               "_SDA2_BASE_",          /* ppc */
-               NULL };
-       int i;
        int offset = 1;
 
        /* skip prefix char */
@@ -181,10 +160,6 @@ static int symbol_valid(struct sym_entry
        if (strstr((char *)s->sym + offset, "_compiled."))
                return 0;
 
-       for (i = 0; special_symbols[i]; i++)
-               if( strcmp((char *)s->sym + offset, special_symbols[i]) == 0 )
-                       return 0;
-
        return 1;
 }
 
@@ -251,8 +226,9 @@ static void write_src(void)
        unsigned int *markers;
        char buf[KSYM_NAME_LEN+1];
 
+       printf("#include <xen/config.h>\n");
        printf("#include <asm/types.h>\n");
-       printf("#if BITS_PER_LONG == 64\n");
+       printf("#if BITS_PER_LONG == 64 && !defined(SYMBOLS_ORIGIN)\n");
        printf("#define PTR .quad\n");
        printf("#define ALGN .align 8\n");
        printf("#else\n");
@@ -260,16 +236,21 @@ static void write_src(void)
        printf("#define ALGN .align 4\n");
        printf("#endif\n");
 
-       printf(".data\n");
-
+       printf("\t.section .rodata, \"a\"\n");
+
+       printf("#ifndef SYMBOLS_ORIGIN\n");
+       printf("#define SYMBOLS_ORIGIN 0\n");
        output_label("symbols_addresses");
-       for (i = 0; i < table_cnt; i++) {
-               printf("\tPTR\t%#llx\n", table[i].addr);
+       printf("#else\n");
+       output_label("symbols_offsets");
+       printf("#endif\n");
+       for (i = 0; i < table_cnt; i++) {
+               printf("\tPTR\t%#llx - SYMBOLS_ORIGIN\n", table[i].addr);
        }
        printf("\n");
 
        output_label("symbols_num_syms");
-       printf("\tPTR\t%d\n", table_cnt);
+       printf("\t.long\t%d\n", table_cnt);
        printf("\n");
 
        /* table of offset markers, that give the offset in the compressed 
stream
@@ -293,7 +274,7 @@ static void write_src(void)
 
        output_label("symbols_markers");
        for (i = 0; i < ((table_cnt + 255) >> 8); i++)
-               printf("\tPTR\t%d\n", markers[i]);
+               printf("\t.long\t%d\n", markers[i]);
        printf("\n");
 
        free(markers);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.