debuggers.hg

changeset 19971:75e63b73075a

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@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 13 16:49:50 2009 +0100 (2009-07-13)
parents c0cb307d927f
children 82c6d0b8852e
files xen/common/symbols-dummy.c xen/common/symbols.c xen/include/asm-x86/config.h xen/tools/symbols.c
line diff
     1.1 --- a/xen/common/symbols-dummy.c	Mon Jul 13 12:35:34 2009 +0100
     1.2 +++ b/xen/common/symbols-dummy.c	Mon Jul 13 16:49:50 2009 +0100
     1.3 @@ -6,11 +6,15 @@
     1.4  #include <xen/config.h>
     1.5  #include <xen/types.h>
     1.6  
     1.7 -unsigned long symbols_addresses[1];
     1.8 -unsigned long symbols_num_syms;
     1.9 -u8 symbols_names[1];
    1.10 +#ifdef SYMBOLS_ORIGIN
    1.11 +const unsigned int symbols_offsets[1];
    1.12 +#else
    1.13 +const unsigned long symbols_addresses[1];
    1.14 +#endif
    1.15 +const unsigned int symbols_num_syms;
    1.16 +const u8 symbols_names[1];
    1.17  
    1.18 -u8 symbols_token_table[1];
    1.19 -u16 symbols_token_index[1];
    1.20 +const u8 symbols_token_table[1];
    1.21 +const u16 symbols_token_index[1];
    1.22  
    1.23 -unsigned long symbols_markers[1];
    1.24 +const unsigned int symbols_markers[1];
     2.1 --- a/xen/common/symbols.c	Mon Jul 13 12:35:34 2009 +0100
     2.2 +++ b/xen/common/symbols.c	Mon Jul 13 16:49:50 2009 +0100
     2.3 @@ -18,21 +18,27 @@
     2.4  #include <xen/string.h>
     2.5  #include <xen/spinlock.h>
     2.6  
     2.7 -extern unsigned long symbols_addresses[];
     2.8 -extern unsigned long symbols_num_syms;
     2.9 -extern u8 symbols_names[];
    2.10 +#ifdef SYMBOLS_ORIGIN
    2.11 +extern const unsigned int symbols_offsets[1];
    2.12 +#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n])
    2.13 +#else
    2.14 +extern const unsigned long symbols_addresses[];
    2.15 +#define symbols_address(n) symbols_addresses[n]
    2.16 +#endif
    2.17 +extern const unsigned int symbols_num_syms;
    2.18 +extern const u8 symbols_names[];
    2.19  
    2.20 -extern u8 symbols_token_table[];
    2.21 -extern u16 symbols_token_index[];
    2.22 +extern const u8 symbols_token_table[];
    2.23 +extern const u16 symbols_token_index[];
    2.24  
    2.25 -extern unsigned long symbols_markers[];
    2.26 +extern const unsigned int symbols_markers[];
    2.27  
    2.28  /* expand a compressed symbol data into the resulting uncompressed string,
    2.29     given the offset to where the symbol is in the compressed stream */
    2.30  static unsigned int symbols_expand_symbol(unsigned int off, char *result)
    2.31  {
    2.32      int len, skipped_first = 0;
    2.33 -    u8 *tptr, *data;
    2.34 +    const u8 *tptr, *data;
    2.35  
    2.36      /* get the compressed symbol length from the first symbol byte */
    2.37      data = &symbols_names[off];
    2.38 @@ -70,7 +76,7 @@ static unsigned int symbols_expand_symbo
    2.39   * symbols array */
    2.40  static unsigned int get_symbol_offset(unsigned long pos)
    2.41  {
    2.42 -    u8 *name;
    2.43 +    const u8 *name;
    2.44      int i;
    2.45  
    2.46      /* use the closest marker we have. We have markers every 256 positions,
    2.47 @@ -107,13 +113,13 @@ const char *symbols_lookup(unsigned long
    2.48  
    2.49      while (high-low > 1) {
    2.50          mid = (low + high) / 2;
    2.51 -        if (symbols_addresses[mid] <= addr) low = mid;
    2.52 +        if (symbols_address(mid) <= addr) low = mid;
    2.53          else high = mid;
    2.54      }
    2.55  
    2.56      /* search for the first aliased symbol. Aliased symbols are
    2.57             symbols with the same address */
    2.58 -    while (low && symbols_addresses[low - 1] == symbols_addresses[low])
    2.59 +    while (low && symbols_address(low - 1) == symbols_address(low))
    2.60          --low;
    2.61  
    2.62          /* Grab name */
    2.63 @@ -121,8 +127,8 @@ const char *symbols_lookup(unsigned long
    2.64  
    2.65      /* Search for next non-aliased symbol */
    2.66      for (i = low + 1; i < symbols_num_syms; i++) {
    2.67 -        if (symbols_addresses[i] > symbols_addresses[low]) {
    2.68 -            symbol_end = symbols_addresses[i];
    2.69 +        if (symbols_address(i) > symbols_address(low)) {
    2.70 +            symbol_end = symbols_address(i);
    2.71              break;
    2.72          }
    2.73      }
    2.74 @@ -132,8 +138,8 @@ const char *symbols_lookup(unsigned long
    2.75          symbol_end = is_kernel_inittext(addr) ?
    2.76              (unsigned long)_einittext : (unsigned long)_etext;
    2.77  
    2.78 -    *symbolsize = symbol_end - symbols_addresses[low];
    2.79 -    *offset = addr - symbols_addresses[low];
    2.80 +    *symbolsize = symbol_end - symbols_address(low);
    2.81 +    *offset = addr - symbols_address(low);
    2.82      return namebuf;
    2.83  }
    2.84  
     3.1 --- a/xen/include/asm-x86/config.h	Mon Jul 13 12:35:34 2009 +0100
     3.2 +++ b/xen/include/asm-x86/config.h	Mon Jul 13 16:49:50 2009 +0100
     3.3 @@ -122,10 +122,12 @@ extern unsigned int video_mode, video_fl
     3.4  #define PML4_ADDR(_slot)                             \
     3.5      ((((_slot ## UL) >> 8) * 0xffff000000000000UL) | \
     3.6       (_slot ## UL << PML4_ENTRY_BITS))
     3.7 +#define GB(_gb) (_gb ## UL << 30)
     3.8  #else
     3.9  #define PML4_ENTRY_BYTES (1 << PML4_ENTRY_BITS)
    3.10  #define PML4_ADDR(_slot)                             \
    3.11      (((_slot >> 8) * 0xffff000000000000) | (_slot << PML4_ENTRY_BITS))
    3.12 +#define GB(_gb) (_gb << 30)
    3.13  #endif
    3.14  
    3.15  /*
    3.16 @@ -210,22 +212,22 @@ extern unsigned int video_mode, video_fl
    3.17  #define PERDOMAIN_MBYTES        (PML4_ENTRY_BYTES >> (20 + PAGETABLE_ORDER))
    3.18  /* Slot 261: machine-to-phys conversion table (16GB). */
    3.19  #define RDWR_MPT_VIRT_START     (PML4_ADDR(261))
    3.20 -#define RDWR_MPT_VIRT_END       (RDWR_MPT_VIRT_START + (16UL<<30))
    3.21 +#define RDWR_MPT_VIRT_END       (RDWR_MPT_VIRT_START + GB(16))
    3.22  /* Slot 261: page-frame information array (16GB). */
    3.23  #define FRAMETABLE_VIRT_START   (RDWR_MPT_VIRT_END)
    3.24 -#define FRAMETABLE_VIRT_END     (FRAMETABLE_VIRT_START + (16UL<<30))
    3.25 +#define FRAMETABLE_VIRT_END     (FRAMETABLE_VIRT_START + GB(16))
    3.26  /* Slot 261: ioremap()/fixmap area (16GB). */
    3.27  #define IOREMAP_VIRT_START      (FRAMETABLE_VIRT_END)
    3.28 -#define IOREMAP_VIRT_END        (IOREMAP_VIRT_START + (16UL<<30))
    3.29 +#define IOREMAP_VIRT_END        (IOREMAP_VIRT_START + GB(16))
    3.30  /* Slot 261: compatibility machine-to-phys conversion table (1GB). */
    3.31  #define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END
    3.32 -#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + (1UL << 30))
    3.33 +#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + GB(1))
    3.34  /* Slot 261: high read-only compat machine-to-phys conversion table (1GB). */
    3.35  #define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END
    3.36 -#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + (1UL << 30))
    3.37 +#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + GB(1))
    3.38  /* Slot 261: xen text, static data and bss (1GB). */
    3.39  #define XEN_VIRT_START          (HIRO_COMPAT_MPT_VIRT_END)
    3.40 -#define XEN_VIRT_END            (XEN_VIRT_START + (1UL << 30))
    3.41 +#define XEN_VIRT_END            (XEN_VIRT_START + GB(1))
    3.42  /* Slot 262-263: A direct 1:1 mapping of all of physical memory. */
    3.43  #define DIRECTMAP_VIRT_START    (PML4_ADDR(262))
    3.44  #define DIRECTMAP_VIRT_END      (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*2)
    3.45 @@ -259,6 +261,8 @@ extern unsigned int video_mode, video_fl
    3.46  #define __HYPERVISOR_DS32 0xe010
    3.47  #define __HYPERVISOR_DS   __HYPERVISOR_DS64
    3.48  
    3.49 +#define SYMBOLS_ORIGIN XEN_VIRT_START
    3.50 +
    3.51  /* For generic assembly code: use macros to define operation/operand sizes. */
    3.52  #define __OS          "q"  /* Operation Suffix */
    3.53  #define __OP          "r"  /* Operand Prefix */
     4.1 --- a/xen/tools/symbols.c	Mon Jul 13 12:35:34 2009 +0100
     4.2 +++ b/xen/tools/symbols.c	Mon Jul 13 16:49:50 2009 +0100
     4.3 @@ -108,10 +108,7 @@ static int read_symbol(FILE *in, struct 
     4.4  	else if (toupper((uint8_t)stype) == 'A')
     4.5  	{
     4.6  		/* Keep these useful absolute symbols */
     4.7 -		if (strcmp(sym, "__kernel_syscall_via_break") &&
     4.8 -		    strcmp(sym, "__kernel_syscall_via_epc") &&
     4.9 -		    strcmp(sym, "__kernel_sigtramp") &&
    4.10 -		    strcmp(sym, "__gp"))
    4.11 +		if (strcmp(sym, "__gp"))
    4.12  			return -1;
    4.13  
    4.14  	}
    4.15 @@ -134,24 +131,6 @@ static int read_symbol(FILE *in, struct 
    4.16  
    4.17  static int symbol_valid(struct sym_entry *s)
    4.18  {
    4.19 -	/* Symbols which vary between passes.  Passes 1 and 2 must have
    4.20 -	 * identical symbol lists.  The symbols_* symbols below are only added
    4.21 -	 * after pass 1, they would be included in pass 2 when --all-symbols is
    4.22 -	 * specified so exclude them to get a stable symbol list.
    4.23 -	 */
    4.24 -	static char *special_symbols[] = {
    4.25 -		"symbols_addresses",
    4.26 -		"symbols_num_syms",
    4.27 -		"symbols_names",
    4.28 -		"symbols_markers",
    4.29 -		"symbols_token_table",
    4.30 -		"symbols_token_index",
    4.31 -
    4.32 -	/* Exclude linker generated symbols which vary between passes */
    4.33 -		"_SDA_BASE_",		/* ppc */
    4.34 -		"_SDA2_BASE_",		/* ppc */
    4.35 -		NULL };
    4.36 -	int i;
    4.37  	int offset = 1;
    4.38  
    4.39  	/* skip prefix char */
    4.40 @@ -181,10 +160,6 @@ static int symbol_valid(struct sym_entry
    4.41  	if (strstr((char *)s->sym + offset, "_compiled."))
    4.42  		return 0;
    4.43  
    4.44 -	for (i = 0; special_symbols[i]; i++)
    4.45 -		if( strcmp((char *)s->sym + offset, special_symbols[i]) == 0 )
    4.46 -			return 0;
    4.47 -
    4.48  	return 1;
    4.49  }
    4.50  
    4.51 @@ -251,8 +226,9 @@ static void write_src(void)
    4.52  	unsigned int *markers;
    4.53  	char buf[KSYM_NAME_LEN+1];
    4.54  
    4.55 +	printf("#include <xen/config.h>\n");
    4.56  	printf("#include <asm/types.h>\n");
    4.57 -	printf("#if BITS_PER_LONG == 64\n");
    4.58 +	printf("#if BITS_PER_LONG == 64 && !defined(SYMBOLS_ORIGIN)\n");
    4.59  	printf("#define PTR .quad\n");
    4.60  	printf("#define ALGN .align 8\n");
    4.61  	printf("#else\n");
    4.62 @@ -260,16 +236,21 @@ static void write_src(void)
    4.63  	printf("#define ALGN .align 4\n");
    4.64  	printf("#endif\n");
    4.65  
    4.66 -	printf(".data\n");
    4.67 +	printf("\t.section .rodata, \"a\"\n");
    4.68  
    4.69 +	printf("#ifndef SYMBOLS_ORIGIN\n");
    4.70 +	printf("#define SYMBOLS_ORIGIN 0\n");
    4.71  	output_label("symbols_addresses");
    4.72 +	printf("#else\n");
    4.73 +	output_label("symbols_offsets");
    4.74 +	printf("#endif\n");
    4.75  	for (i = 0; i < table_cnt; i++) {
    4.76 -		printf("\tPTR\t%#llx\n", table[i].addr);
    4.77 +		printf("\tPTR\t%#llx - SYMBOLS_ORIGIN\n", table[i].addr);
    4.78  	}
    4.79  	printf("\n");
    4.80  
    4.81  	output_label("symbols_num_syms");
    4.82 -	printf("\tPTR\t%d\n", table_cnt);
    4.83 +	printf("\t.long\t%d\n", table_cnt);
    4.84  	printf("\n");
    4.85  
    4.86  	/* table of offset markers, that give the offset in the compressed stream
    4.87 @@ -293,7 +274,7 @@ static void write_src(void)
    4.88  
    4.89  	output_label("symbols_markers");
    4.90  	for (i = 0; i < ((table_cnt + 255) >> 8); i++)
    4.91 -		printf("\tPTR\t%d\n", markers[i]);
    4.92 +		printf("\t.long\t%d\n", markers[i]);
    4.93  	printf("\n");
    4.94  
    4.95  	free(markers);