ia64/xen-unstable

changeset 3613:f98fa170a9f4

bitkeeper revision 1.1159.238.2 (4200caf6iFnj85XmiFNAz7VursMGUw)

Slab caches for things allocated only on initialization seems to be
overkill. This patch replaces them with the previous typesafe
allocator.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@labyrinth.cl.cam.ac.uk
date Wed Feb 02 12:43:34 2005 +0000 (2005-02-02)
parents beb0887c54bc
children 10a0f6b0a996
files xen/arch/x86/domain.c xen/arch/x86/setup.c xen/common/sched_atropos.c xen/common/sched_bvt.c xen/common/sched_rrobin.c
line diff
     1.1 --- a/xen/arch/x86/domain.c	Wed Feb 02 12:34:32 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Wed Feb 02 12:43:34 2005 +0000
     1.3 @@ -223,42 +223,24 @@ void dump_pageframe_info(struct domain *
     1.4             page->u.inuse.type_info);
     1.5  }
     1.6  
     1.7 -xmem_cache_t *domain_struct_cachep;
     1.8 -xmem_cache_t *exec_domain_struct_cachep;
     1.9 -
    1.10 -void __init domain_startofday(void)
    1.11 -{
    1.12 -    domain_struct_cachep = xmem_cache_create(
    1.13 -        "domain_cache", sizeof(struct domain),
    1.14 -        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
    1.15 -    if ( domain_struct_cachep == NULL )
    1.16 -        panic("No slab cache for domain structs.");
    1.17 -
    1.18 -    exec_domain_struct_cachep = xmem_cache_create(
    1.19 -        "exec_dom_cache", sizeof(struct exec_domain),
    1.20 -        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
    1.21 -    if ( exec_domain_struct_cachep == NULL )
    1.22 -        BUG();
    1.23 -}
    1.24 -
    1.25  struct domain *arch_alloc_domain_struct(void)
    1.26  {
    1.27 -    return xmem_cache_alloc(domain_struct_cachep);
    1.28 +    return xmalloc(struct domain);
    1.29  }
    1.30  
    1.31  void arch_free_domain_struct(struct domain *d)
    1.32  {
    1.33 -    xmem_cache_free(domain_struct_cachep, d);
    1.34 +    xfree(d);
    1.35  }
    1.36  
    1.37  struct exec_domain *arch_alloc_exec_domain_struct(void)
    1.38  {
    1.39 -    return xmem_cache_alloc(exec_domain_struct_cachep);
    1.40 +    return xmalloc(struct exec_domain);
    1.41  }
    1.42  
    1.43  void arch_free_exec_domain_struct(struct exec_domain *ed)
    1.44  {
    1.45 -    xmem_cache_free(exec_domain_struct_cachep, ed);
    1.46 +    xfree(ed);
    1.47  }
    1.48  
    1.49  void free_perdomain_pt(struct domain *d)
     2.1 --- a/xen/arch/x86/setup.c	Wed Feb 02 12:34:32 2005 +0000
     2.2 +++ b/xen/arch/x86/setup.c	Wed Feb 02 12:43:34 2005 +0000
     2.3 @@ -602,8 +602,6 @@ void __init __start_xen(multiboot_info_t
     2.4      xmem_cache_init();
     2.5      xmem_cache_sizes_init(max_page);
     2.6  
     2.7 -    domain_startofday();
     2.8 -
     2.9      start_of_day();
    2.10  
    2.11      grant_table_init();
     3.1 --- a/xen/common/sched_atropos.c	Wed Feb 02 12:34:32 2005 +0000
     3.2 +++ b/xen/common/sched_atropos.c	Wed Feb 02 12:43:34 2005 +0000
     3.3 @@ -69,8 +69,6 @@ struct at_cpu_info
     3.4  
     3.5  static void at_dump_cpu_state(int cpu);
     3.6  
     3.7 -static xmem_cache_t *dom_info_cache;
     3.8 -
     3.9  static inline void __add_to_runqueue_head(struct domain *d)
    3.10  {
    3.11      list_add(RUNLIST(d), RUNQ(d->processor));
    3.12 @@ -558,10 +556,6 @@ static int at_init_scheduler()
    3.13          INIT_LIST_HEAD(RUNQ(i));
    3.14      }
    3.15  
    3.16 -    dom_info_cache = xmem_cache_create("Atropos dom info",
    3.17 -                                       sizeof(struct at_dom_info),
    3.18 -                                       0, 0, NULL, NULL);
    3.19 -
    3.20      return 0;
    3.21  }
    3.22  
    3.23 @@ -649,7 +643,7 @@ static int at_adjdom(struct domain *p, s
    3.24  /* free memory associated with a task */
    3.25  static void at_free_task(struct domain *p)
    3.26  {
    3.27 -    xmem_cache_free( dom_info_cache, DOM_INFO(p) );
    3.28 +    xfree( DOM_INFO(p) );
    3.29  }
    3.30  
    3.31  
     4.1 --- a/xen/common/sched_bvt.c	Wed Feb 02 12:34:32 2005 +0000
     4.2 +++ b/xen/common/sched_bvt.c	Wed Feb 02 12:43:34 2005 +0000
     4.3 @@ -71,8 +71,6 @@ struct bvt_cpu_info
     4.4  #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
     4.5  static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
     4.6  
     4.7 -static xmem_cache_t *dom_info_cache;
     4.8 -
     4.9  static inline void __add_to_runqueue_head(struct exec_domain *d)
    4.10  {
    4.11      list_add(RUNLIST(d), RUNQUEUE(d->processor));
    4.12 @@ -173,7 +171,7 @@ int bvt_alloc_task(struct exec_domain *e
    4.13  {
    4.14      struct domain *d = ed->domain;
    4.15      if ( (d->sched_priv == NULL) ) {
    4.16 -        if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
    4.17 +        if ( (d->sched_priv = new(struct bvt_dom_info)) == NULL )
    4.18              return -1;
    4.19          memset(d->sched_priv, 0, sizeof(struct bvt_dom_info));
    4.20      }
    4.21 @@ -295,7 +293,7 @@ static void bvt_sleep(struct exec_domain
    4.22  void bvt_free_task(struct domain *d)
    4.23  {
    4.24      ASSERT(d->sched_priv != NULL);
    4.25 -    xmem_cache_free(dom_info_cache, d->sched_priv);
    4.26 +    xfree(d->sched_priv);
    4.27  }
    4.28  
    4.29  /* Control the scheduler. */
    4.30 @@ -570,14 +568,6 @@ int bvt_init_scheduler()
    4.31          CPU_SVT(i) = 0; /* XXX do I really need to do this? */
    4.32      }
    4.33  
    4.34 -    dom_info_cache = xmem_cache_create(
    4.35 -        "BVT dom info", sizeof(struct bvt_dom_info), 0, 0, NULL, NULL);
    4.36 -    if ( dom_info_cache == NULL )
    4.37 -    {
    4.38 -        printk("BVT: Failed to allocate domain info SLAB cache");
    4.39 -        return -1;
    4.40 -    }
    4.41 -
    4.42      return 0;
    4.43  }
    4.44  
     5.1 --- a/xen/common/sched_rrobin.c	Wed Feb 02 12:34:32 2005 +0000
     5.2 +++ b/xen/common/sched_rrobin.c	Wed Feb 02 12:43:34 2005 +0000
     5.3 @@ -27,8 +27,6 @@ struct rrobin_dom_info
     5.4  #define RUNLIST(d)      ((struct list_head *)&(RR_INFO(d)->run_list))
     5.5  #define RUNQUEUE(cpu)   RUNLIST(schedule_data[cpu].idle)
     5.6  
     5.7 -static xmem_cache_t *dom_info_cache;
     5.8 -
     5.9  static inline void __add_to_runqueue_head(struct domain *d)
    5.10  {
    5.11      list_add(RUNLIST(d), RUNQUEUE(d->processor));
    5.12 @@ -59,21 +57,12 @@ static int rr_init_scheduler()
    5.13      for ( i = 0; i < NR_CPUS; i++ )
    5.14          INIT_LIST_HEAD(RUNQUEUE(i));
    5.15     
    5.16 -    dom_info_cache = xmem_cache_create(
    5.17 -        "RR dom info", sizeof(struct rrobin_dom_info), 0, 0, 0, NULL);
    5.18 -    if ( dom_info_cache == NULL )
    5.19 -    {
    5.20 -        printk("Could not allocate SLAB cache.\n");
    5.21 -        return -1;
    5.22 -    }
    5.23 -
    5.24      return 0;                                                                
    5.25  }
    5.26 -
    5.27  /* Allocates memory for per domain private scheduling data*/
    5.28  static int rr_alloc_task(struct domain *d)
    5.29  {
    5.30 -    if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
    5.31 +    if ( (d->sched_priv = new(struct rrobin_dom_info) == NULL )
    5.32          return -1;
    5.33      memset(d->sched_priv, 0, sizeof(struct rrobin_dom_info));
    5.34      return 0;
    5.35 @@ -91,7 +80,7 @@ static void rr_add_task(struct domain *d
    5.36  static void rr_free_task(struct domain *d)
    5.37  {
    5.38      ASSERT(d->sched_priv != NULL);
    5.39 -    xmem_cache_free(dom_info_cache, d->sched_priv);
    5.40 +    xfree(d->sched_priv);
    5.41  }
    5.42  
    5.43  /* Initialises idle task */