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 2/3] Replace slab caches with typesafe allocs...

To: Xen Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/3] Replace slab caches with typesafe allocs...
From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Date: Wed, 02 Feb 2005 16:09:24 +1100
Delivery-date: Wed, 02 Feb 2005 05:11:13 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
Slab caches for things allocated only on initialization seems to be
overkill.  This patch replaces them with the previous typesafe
allocator.

(Oops, forgot to sign off previous patch: please consider this to apply
to both).

Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx> (authored)

diff -urpN --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
xen-unstable-typesafe/xen/arch/x86/domain.c 
xen-unstable-working/xen/arch/x86/domain.c
--- xen-unstable-typesafe/xen/arch/x86/domain.c 2005-01-30 15:28:47.000000000 
+1100
+++ xen-unstable-working/xen/arch/x86/domain.c  2005-01-31 18:05:15.000000000 
+1100
@@ -223,42 +223,24 @@ void dump_pageframe_info(struct domain *
            page->u.inuse.type_info);
 }
 
-xmem_cache_t *domain_struct_cachep;
-xmem_cache_t *exec_domain_struct_cachep;
-
-void __init domain_startofday(void)
-{
-    domain_struct_cachep = xmem_cache_create(
-        "domain_cache", sizeof(struct domain),
-        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-    if ( domain_struct_cachep == NULL )
-        panic("No slab cache for domain structs.");
-
-    exec_domain_struct_cachep = xmem_cache_create(
-        "exec_dom_cache", sizeof(struct exec_domain),
-        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-    if ( exec_domain_struct_cachep == NULL )
-        BUG();
-}
-
 struct domain *arch_alloc_domain_struct(void)
 {
-    return xmem_cache_alloc(domain_struct_cachep);
+    return new(struct domain);
 }
 
 void arch_free_domain_struct(struct domain *d)
 {
-    xmem_cache_free(domain_struct_cachep, d);
+    xfree(d);
 }
 
 struct exec_domain *arch_alloc_exec_domain_struct(void)
 {
-    return xmem_cache_alloc(exec_domain_struct_cachep);
+    return new(struct exec_domain);
 }
 
 void arch_free_exec_domain_struct(struct exec_domain *ed)
 {
-    xmem_cache_free(exec_domain_struct_cachep, ed);
+    xfree(ed);
 }
 
 void free_perdomain_pt(struct domain *d)
diff -urpN --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
xen-unstable-typesafe/xen/arch/x86/setup.c 
xen-unstable-working/xen/arch/x86/setup.c
--- xen-unstable-typesafe/xen/arch/x86/setup.c  2005-01-30 15:28:50.000000000 
+1100
+++ xen-unstable-working/xen/arch/x86/setup.c   2005-01-31 18:05:41.000000000 
+1100
@@ -598,8 +598,6 @@ void __init __start_xen(multiboot_info_t
     xmem_cache_init();
     xmem_cache_sizes_init(max_page);
 
-    domain_startofday();
-
     start_of_day();
 
     grant_table_init();
diff -urpN --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
xen-unstable-typesafe/xen/common/sched_atropos.c 
xen-unstable-working/xen/common/sched_atropos.c
--- xen-unstable-typesafe/xen/common/sched_atropos.c    2005-01-31 
18:14:24.000000000 +1100
+++ xen-unstable-working/xen/common/sched_atropos.c     2005-01-31 
17:36:49.000000000 +1100
@@ -69,8 +69,6 @@ struct at_cpu_info
 
 static void at_dump_cpu_state(int cpu);
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct domain *d)
 {
     list_add(RUNLIST(d), RUNQ(d->processor));
@@ -558,10 +556,6 @@ static int at_init_scheduler()
         INIT_LIST_HEAD(RUNQ(i));
     }
 
-    dom_info_cache = xmem_cache_create("Atropos dom info",
-                                       sizeof(struct at_dom_info),
-                                       0, 0, NULL, NULL);
-
     return 0;
 }
 
@@ -649,7 +643,7 @@ static int at_adjdom(struct domain *p, s
 /* free memory associated with a task */
 static void at_free_task(struct domain *p)
 {
-    xmem_cache_free( dom_info_cache, DOM_INFO(p) );
+    xfree( DOM_INFO(p) );
 }
 
 
diff -urpN --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
xen-unstable-typesafe/xen/common/sched_bvt.c 
xen-unstable-working/xen/common/sched_bvt.c
--- xen-unstable-typesafe/xen/common/sched_bvt.c        2005-01-31 
18:14:24.000000000 +1100
+++ xen-unstable-working/xen/common/sched_bvt.c 2005-01-31 18:05:05.000000000 
+1100
@@ -71,8 +71,6 @@ struct bvt_cpu_info
 #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
 static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct exec_domain *d)
 {
     list_add(RUNLIST(d), RUNQUEUE(d->processor));
@@ -173,7 +171,7 @@ int bvt_alloc_task(struct exec_domain *e
 {
     struct domain *d = ed->domain;
     if ( (d->sched_priv == NULL) ) {
-        if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
+        if ( (d->sched_priv = new(struct bvt_dom_info)) == NULL )
             return -1;
         memset(d->sched_priv, 0, sizeof(struct bvt_dom_info));
     }
@@ -295,7 +293,7 @@ static void bvt_sleep(struct exec_domain
 void bvt_free_task(struct domain *d)
 {
     ASSERT(d->sched_priv != NULL);
-    xmem_cache_free(dom_info_cache, d->sched_priv);
+    xfree(d->sched_priv);
 }
 
 /* Control the scheduler. */
@@ -570,14 +568,6 @@ int bvt_init_scheduler()
         CPU_SVT(i) = 0; /* XXX do I really need to do this? */
     }
 
-    dom_info_cache = xmem_cache_create(
-        "BVT dom info", sizeof(struct bvt_dom_info), 0, 0, NULL, NULL);
-    if ( dom_info_cache == NULL )
-    {
-        printk("BVT: Failed to allocate domain info SLAB cache");
-        return -1;
-    }
-
     return 0;
 }
 
diff -urpN --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
xen-unstable-typesafe/xen/common/sched_rrobin.c 
xen-unstable-working/xen/common/sched_rrobin.c
--- xen-unstable-typesafe/xen/common/sched_rrobin.c     2005-01-30 
15:28:39.000000000 +1100
+++ xen-unstable-working/xen/common/sched_rrobin.c      2005-01-31 
17:36:49.000000000 +1100
@@ -27,8 +27,6 @@ struct rrobin_dom_info
 #define RUNLIST(d)      ((struct list_head *)&(RR_INFO(d)->run_list))
 #define RUNQUEUE(cpu)   RUNLIST(schedule_data[cpu].idle)
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct domain *d)
 {
     list_add(RUNLIST(d), RUNQUEUE(d->processor));
@@ -59,21 +57,12 @@ static int rr_init_scheduler()
     for ( i = 0; i < NR_CPUS; i++ )
         INIT_LIST_HEAD(RUNQUEUE(i));
    
-    dom_info_cache = xmem_cache_create(
-        "RR dom info", sizeof(struct rrobin_dom_info), 0, 0, 0, NULL);
-    if ( dom_info_cache == NULL )
-    {
-        printk("Could not allocate SLAB cache.\n");
-        return -1;
-    }
-
     return 0;                                                                
 }
-
 /* Allocates memory for per domain private scheduling data*/
 static int rr_alloc_task(struct domain *d)
 {
-    if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
+    if ( (d->sched_priv = new(struct rrobin_dom_info) == NULL )
         return -1;
     memset(d->sched_priv, 0, sizeof(struct rrobin_dom_info));
     return 0;
@@ -91,7 +80,7 @@ static void rr_add_task(struct domain *d
 static void rr_free_task(struct domain *d)
 {
     ASSERT(d->sched_priv != NULL);
-    xmem_cache_free(dom_info_cache, d->sched_priv);
+    xfree(d->sched_priv);
 }
 
 /* Initialises idle task */

-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/3] Replace slab caches with typesafe allocs..., Rusty Russell <=