Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump Don't use __weak_alias where the component ...



details:   https://anonhg.NetBSD.org/src/rev/34e01d0a7394
branches:  trunk
changeset: 783998:34e01d0a7394
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Jan 14 16:45:47 2013 +0000

description:
Don't use __weak_alias where the component framework is sufficient.

diffstat:

 sys/rump/librump/rumpdev/rump_dev.c         |   7 +--
 sys/rump/librump/rumpkern/rump.c            |  45 ++++++++++++----------------
 sys/rump/librump/rumpkern/rump_private.h    |   8 ++++-
 sys/rump/librump/rumpkern/vm.c              |   7 ++-
 sys/rump/librump/rumpnet/rump_net.c         |   7 +--
 sys/rump/librump/rumpnet/rump_net_private.h |   3 +-
 sys/rump/librump/rumpvfs/rump_vfs.c         |  43 ++++++++++++++------------
 sys/rump/librump/rumpvfs/rump_vfs_private.h |   8 +---
 8 files changed, 64 insertions(+), 64 deletions(-)

diffs (truncated from 328 to 300 lines):

diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpdev/rump_dev.c
--- a/sys/rump/librump/rumpdev/rump_dev.c       Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpdev/rump_dev.c       Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_dev.c,v 1.20 2012/10/27 17:18:40 chs Exp $        */
+/*     $NetBSD: rump_dev.c,v 1.21 2013/01/14 16:45:47 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.20 2012/10/27 17:18:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.21 2013/01/14 16:45:47 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -41,8 +41,7 @@
 
 const char *rootspec = "rump0a"; /* usually comes from config */
 
-void
-rump_dev_init(void)
+RUMP_COMPONENT(RUMP__FACTION_DEV)
 {
        extern int cold;
 
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.248 2013/01/14 16:35:06 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.249 2013/01/14 16:45:47 pooka Exp $ */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.248 2013/01/14 16:35:06 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.249 2013/01/14 16:45:47 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -126,31 +126,15 @@
 
 static int rump_inited;
 
-/*
- * Make sure pnbuf_cache is available even without vfs
- */
-int rump_initpnbufpool(void);
-int rump_initpnbufpool(void)
-{
-
-        pnbuf_cache = pool_cache_init(MAXPATHLEN, 0, 0, 0, "pnbufpl",
-           NULL, IPL_NONE, NULL, NULL, NULL);
-       return EOPNOTSUPP;
-}
+void (*rump_vfs_drainbufs)(int);
+void (*rump_vfs_fini)(void);
 
 int rump__unavailable(void);
 int rump__unavailable() {return EOPNOTSUPP;}
-__weak_alias(rump_net_init,rump__unavailable);
-__weak_alias(rump_vfs_init,rump_initpnbufpool);
-__weak_alias(rump_dev_init,rump__unavailable);
-
-__weak_alias(rump_vfs_fini,rump__unavailable);
 
 __weak_alias(biodone,rump__unavailable);
 __weak_alias(sopoll,rump__unavailable);
 
-__weak_alias(rump_vfs_drainbufs,rump__unavailable);
-
 void rump__unavailable_vfs_panic(void);
 void rump__unavailable_vfs_panic() {panic("vfs component not available");}
 __weak_alias(usermount_common_policy,rump__unavailable_vfs_panic);
@@ -403,10 +387,18 @@
 
        rump_component_init(RUMP_COMPONENT_KERN);
 
-       /* these do nothing if not present */
-       rump_vfs_init();
-       rump_net_init();
-       rump_dev_init();
+       /* initialize factions, if present */
+       rump_component_init(RUMP__FACTION_VFS);
+       /* pnbuf_cache is used even without vfs */
+       if (rump_component_count(RUMP__FACTION_VFS) == 0) {
+               pnbuf_cache = pool_cache_init(MAXPATHLEN, 0, 0, 0, "pnbufpl",
+                   NULL, IPL_NONE, NULL, NULL, NULL);
+       }
+       rump_component_init(RUMP__FACTION_NET);
+       rump_component_init(RUMP__FACTION_DEV);
+       KASSERT(rump_component_count(RUMP__FACTION_VFS) <= 1
+           && rump_component_count(RUMP__FACTION_NET) <= 1
+           && rump_component_count(RUMP__FACTION_DEV) <= 1);
 
        rump_component_init(RUMP_COMPONENT_KERN_VFS);
 
@@ -508,6 +500,8 @@
                }
        }
 
+       rump_component_init(RUMP_COMPONENT_POSTBOOT);
+
        /* release cpu */
        rump_unschedule();
 
@@ -542,7 +536,8 @@
 
        /* try to sync */
        if (!((howto & RB_NOSYNC) || panicstr)) {
-               rump_vfs_fini();
+               if (rump_vfs_fini)
+                       rump_vfs_fini();
        }
 
        /* your wish is my command */
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpkern/rump_private.h
--- a/sys/rump/librump/rumpkern/rump_private.h  Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpkern/rump_private.h  Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_private.h,v 1.71 2012/10/09 13:35:50 pooka Exp $  */
+/*     $NetBSD: rump_private.h,v 1.72 2013/01/14 16:45:47 pooka Exp $  */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -61,6 +61,12 @@
        RUMP_COMPONENT_VFS,
        RUMP_COMPONENT_KERN,
                RUMP_COMPONENT_KERN_VFS,
+       RUMP_COMPONENT_POSTINIT,
+
+       RUMP__FACTION_DEV,
+       RUMP__FACTION_VFS,
+       RUMP__FACTION_NET,
+
        RUMP_COMPONENT_MAX,
 };
 struct rump_component {
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c    Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpkern/vm.c    Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm.c,v 1.131 2012/11/13 20:10:02 pooka Exp $   */
+/*     $NetBSD: vm.c,v 1.132 2013/01/14 16:45:47 pooka Exp $   */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.131 2012/11/13 20:10:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.132 2013/01/14 16:45:47 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -1106,7 +1106,8 @@
                 * And then drain the pools.  Wipe them out ... all of them.
                 */
                for (pp_first = NULL;;) {
-                       rump_vfs_drainbufs(10 /* XXX: estimate better */);
+                       if (rump_vfs_drainbufs)
+                               rump_vfs_drainbufs(10 /* XXX: estimate! */);
 
                        succ = pool_drain(&pp);
                        if (succ || pp == pp_first)
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpnet/rump_net.c
--- a/sys/rump/librump/rumpnet/rump_net.c       Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpnet/rump_net.c       Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_net.c,v 1.13 2011/01/11 09:22:33 pooka Exp $      */
+/*     $NetBSD: rump_net.c,v 1.14 2013/01/14 16:45:47 pooka Exp $      */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_net.c,v 1.13 2011/01/11 09:22:33 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_net.c,v 1.14 2013/01/14 16:45:47 pooka Exp $");
 
 #include <sys/param.h>
 
@@ -45,8 +45,7 @@
 void nocomponent() {}
 __weak_alias(rump_net_components,nocomponent);
 
-void
-rump_net_init(void)
+RUMP_COMPONENT(RUMP__FACTION_NET)
 {
 
        bpf_setops();
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpnet/rump_net_private.h
--- a/sys/rump/librump/rumpnet/rump_net_private.h       Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpnet/rump_net_private.h       Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_net_private.h,v 1.5 2010/03/01 13:12:20 pooka Exp $       */
+/*     $NetBSD: rump_net_private.h,v 1.6 2013/01/14 16:45:47 pooka Exp $       */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,6 @@
 #ifndef _SYS_RUMP_NET_PRIVATE_H_
 #define _SYS_RUMP_NET_PRIVATE_H_
 
-void           rump_net_init(void);
 void           rump_netisr_init(void);
 
 #define DOMAINADD(dom)                                                 \
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c       Mon Jan 14 16:36:15 2013 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c       Mon Jan 14 16:45:47 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_vfs.c,v 1.70 2012/11/22 21:23:08 pooka Exp $      */
+/*     $NetBSD: rump_vfs.c,v 1.71 2013/01/14 16:45:47 pooka Exp $      */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.70 2012/11/22 21:23:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.71 2013/01/14 16:45:47 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -73,8 +73,23 @@
        cwdfree(p->p_cwdi);
 }
 
-void
-rump_vfs_init(void)
+static void
+fini(void)
+{
+
+       vfs_shutdown();
+}
+
+static void
+drainbufs(int npages)
+{
+
+       mutex_enter(&bufcache_lock);
+       buf_drain(npages);
+       mutex_exit(&bufcache_lock);
+}
+
+RUMP_COMPONENT(RUMP__FACTION_VFS)
 {
        extern struct devsw_conv devsw_conv0[];
        extern int max_devsw_convs;
@@ -83,6 +98,10 @@
        int error;
        int rv, i;
 
+       /* initialize indirect interfaces */
+       rump_vfs_fini = fini;
+       rump_vfs_drainbufs = drainbufs;
+
        if (rumpuser_getenv("RUMP_NVNODES", buf, sizeof(buf), &error) == 0) {
                desiredvnodes = strtoul(buf, NULL, 10);
        } else {
@@ -166,13 +185,6 @@
        rump_component_init(RUMP_COMPONENT_VFS);
 }
 
-void
-rump_vfs_fini(void)
-{
-
-       vfs_shutdown();
-}
-
 struct rumpcn {
        struct componentname rcn_cn;
        char *rcn_path;
@@ -485,12 +497,3 @@
 
        biodone(bp);
 }
-
-void
-rump_vfs_drainbufs(int npages)
-{
-
-       mutex_enter(&bufcache_lock);
-       buf_drain(npages);
-       mutex_exit(&bufcache_lock);
-}
diff -r 671fdd37d6bf -r 34e01d0a7394 sys/rump/librump/rumpvfs/rump_vfs_private.h



Home | Main Index | Thread Index | Old Index