commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 08/10: New upstream snapshot


From: Samuel Thibault
Subject: [hurd] 08/10: New upstream snapshot
Date: Tue, 27 May 2014 08:32:07 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch master
in repository hurd.

commit 175837580a92b70cbb5e63a201df7727df0354b2
Author: Samuel Thibault <address@hidden>
Date:   Mon May 26 18:55:22 2014 +0000

    New upstream snapshot
---
 console-client/xkb/xkb.c                |  3 +-
 exec/exec.c                             |  1 +
 exec/main.c                             |  1 +
 ext2fs/pager.c                          |  2 +-
 include/Makefile                        |  2 +-
 libdiskfs/diskfs.h                      |  7 ++--
 libdiskfs/name-cache.c                  |  3 +-
 libdiskfs/peropen-make.c                |  2 +-
 libdiskfs/peropen-rele.c                | 21 +++++-----
 libdiskfs/protid-make.c                 |  8 ++--
 libihash/ihash.c                        | 22 ++--------
 libpager/priv.h                         |  2 -
 libpipe/pipe.c                          |  4 +-
 libtrivfs/cntl-create.c                 |  1 -
 libtrivfs/io-reauthenticate.c           |  5 +--
 libtrivfs/io-restrict-auth.c            |  4 +-
 libtrivfs/open.c                        |  2 +-
 libtrivfs/protid-clean.c                | 29 ++++++++-----
 libtrivfs/protid-dup.c                  |  5 +--
 libtrivfs/trivfs.h                      |  4 +-
 mach-defpager/default_pager.c           |  4 +-
 pfinet/linux-src/include/net/addrconf.h |  2 +
 pfinet/linux-src/net/ipv4/fib_hash.c    |  2 +-
 pflocal/connq.c                         |  2 +-
 pflocal/socket.c                        |  4 +-
 procfs/Makefile                         | 22 +++++++++-
 procfs/rootdir.c                        | 73 +++++++++++++++++++++++++++++++++
 term/users.c                            |  4 +-
 trans/mtab.c                            |  2 +-
 29 files changed, 163 insertions(+), 80 deletions(-)

diff --git a/console-client/xkb/xkb.c b/console-client/xkb/xkb.c
index 0b43913..0039714 100644
--- a/console-client/xkb/xkb.c
+++ b/console-client/xkb/xkb.c
@@ -606,10 +606,11 @@ clearcontrols (keypress_t key, boolctrls ctrls, int flags)
 static void
 lockcontrols (keypress_t key, boolctrls ctrls, int flags)
 {
+  /* XXX this needs a closer look.  */
   if (!key.rel)
     {
       //setcontrols (key, boolctrls, flags);
-      if (!(flags & noLock));
+      //if (!(flags & noLock))
       //       lboolctrls |= boolctrls;
     }
   else
diff --git a/exec/exec.c b/exec/exec.c
index b068f5e..2fc1e44 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -24,6 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 
02139, USA.  */
 
 
 #include "priv.h"
+#include <mach/gnumach.h>
 #include <hurd.h>
 #include <hurd/exec.h>
 #include <sys/stat.h>
diff --git a/exec/main.c b/exec/main.c
index 27f33b1..78faebd 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -21,6 +21,7 @@
 
 #include "priv.h"
 #include <error.h>
+#include <device/device.h>
 #include <hurd/paths.h>
 #include <hurd/startup.h>
 #include <argp.h>
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 017efcc..ce5bc6d 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -1449,7 +1449,7 @@ diskfs_pager_users ()
 {
   int npagers = ports_count_bucket (file_pager_bucket);
 
-  if (npagers <= 1)
+  if (npagers == 0)
     return 0;
 
   if (MAY_CACHE)
diff --git a/include/Makefile b/include/Makefile
index b8773fe..4de165d 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -22,7 +22,7 @@
 dir := include
 makemode := misc
 
-installhdrs := sys/procfs.h
+installhdrs := sys/procfs.h refcount.h
 
 include ../Makeconf
 
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 8151ddc..ae1a150 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -28,6 +28,7 @@
 #include <hurd/iohelp.h>
 #include <idvec.h>
 #include <features.h>
+#include <refcount.h>
 
 #ifdef DISKFS_DEFINE_EXTERN_INLINE
 #define DISKFS_EXTERN_INLINE
@@ -57,7 +58,7 @@ struct peropen
 {
   int filepointer;
   int lock_status;
-  int refcnt;
+  refcount_t refcnt;
   int openstat;
 
   struct node *np;
@@ -792,12 +793,12 @@ diskfs_create_node (struct node *dir, const char *name, 
mode_t mode,
                    struct dirstat *ds);
 
 /* Create and return a protid for an existing peropen PO in CRED,
-   referring to user USER.  The node PO->np must be locked. */
+   referring to user USER.  */
 error_t diskfs_create_protid (struct peropen *po, struct iouser *user,
                              struct protid **cred);
 
 /* Build and return in CRED a protid which has no user identification, for
-   peropen PO.  The node PO->np must be locked.  */
+   peropen PO.  */
 error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
 
 /* Finish building protid CRED started with diskfs_start_protid;
diff --git a/libdiskfs/name-cache.c b/libdiskfs/name-cache.c
index 8424ffe..a212a6d 100644
--- a/libdiskfs/name-cache.c
+++ b/libdiskfs/name-cache.c
@@ -37,7 +37,7 @@ struct lookup_cache
   /* Used to indentify nodes to the fs dependent code.  0 for NODE_CACHE_ID
      means a `negative' entry -- recording that there's definitely no node with
      this name.  */
-  int dir_cache_id, node_cache_id;
+  ino64_t dir_cache_id, node_cache_id;
 
   /* Name of the node NODE_CACHE_ID in the directory DIR_CACHE_ID.  Entries
      with names too long to fit in this buffer aren't cached at all.  */
@@ -249,6 +249,7 @@ diskfs_check_lookup_cache (struct node *dir, const char 
*name)
                {
                  /* Lose */
                  pthread_mutex_unlock (&np->lock);
+                 diskfs_nrele (np);
                  return 0;
                }
            }
diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
index eba037f..6d5ca01 100644
--- a/libdiskfs/peropen-make.c
+++ b/libdiskfs/peropen-make.c
@@ -31,7 +31,7 @@ diskfs_make_peropen (struct node *np, int flags, struct 
peropen *context,
 
   po->filepointer = 0;
   po->lock_status = LOCK_UN;
-  po->refcnt = 0;
+  refcount_init (&po->refcnt, 0);
   po->openstat = flags;
   po->np = np;
   po->path = NULL;
diff --git a/libdiskfs/peropen-rele.c b/libdiskfs/peropen-rele.c
index d3f7492..877137b 100644
--- a/libdiskfs/peropen-rele.c
+++ b/libdiskfs/peropen-rele.c
@@ -22,13 +22,8 @@
 void
 diskfs_release_peropen (struct peropen *po)
 {
-  pthread_mutex_lock (&po->np->lock);
-
-  if (--po->refcnt)
-    {
-      pthread_mutex_unlock (&po->np->lock);
-      return;
-    }
+  if (refcount_deref (&po->refcnt) > 0)
+    return;
 
   if (po->root_parent)
     mach_port_deallocate (mach_task_self (), po->root_parent);
@@ -40,10 +35,14 @@ diskfs_release_peropen (struct peropen *po)
     mach_port_deallocate (mach_task_self (), po->shadow_root_parent);
 
   if (po->lock_status != LOCK_UN)
-    fshelp_acquire_lock (&po->np->userlock, &po->lock_status,
-                        &po->np->lock, LOCK_UN);
-
-  diskfs_nput (po->np);
+    {
+      pthread_mutex_lock (&po->np->lock);
+      fshelp_acquire_lock (&po->np->userlock, &po->lock_status,
+                           &po->np->lock, LOCK_UN);
+      diskfs_nput (po->np);
+    }
+  else
+    diskfs_nrele (po->np);
 
   free (po->path);
   free (po);
diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c
index b39b92a..22aaa2e 100644
--- a/libdiskfs/protid-make.c
+++ b/libdiskfs/protid-make.c
@@ -20,7 +20,7 @@
 #include <assert.h>
 
 /* Build and return in CRED a protid which has no user identification, for
-   peropen PO.  The node PO->np must be locked.  */
+   peropen PO.  */
 error_t
 diskfs_start_protid (struct peropen *po, struct protid **cred)
 {
@@ -29,7 +29,7 @@ diskfs_start_protid (struct peropen *po, struct protid **cred)
                                 sizeof (struct protid), cred);
   if (! err)
     {
-      po->refcnt++;
+      refcount_ref (&po->refcnt);
       (*cred)->po = po;
       (*cred)->shared_object = MACH_PORT_NULL;
       (*cred)->mapped = 0;
@@ -55,8 +55,8 @@ diskfs_finish_protid (struct protid *cred, struct iouser 
*user)
   assert_perror (err);
 }
 
-/* Create and return a protid for an existing peropen PO in CRED for USER.
-   The node PO->np must be locked. */
+/* Create and return a protid for an existing peropen PO in CRED for
+   USER.  */
 error_t
 diskfs_create_protid (struct peropen *po, struct iouser *user,
                      struct protid **cred)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index 4d9cc18..fa29257 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -32,19 +32,6 @@
 
 #include "ihash.h"
 
-/* This is the integer finalizer from MurmurHash3.  */
-static inline uint32_t
-murmur3_mix32 (uint32_t h, unsigned int bits)
-{
-  h ^= h >> 16;
-  h *= 0x85ebca6b;
-  h ^= h >> 13;
-  h *= 0xc2b2ae35;
-  h ^= h >> 16;
-
-  return h >> (32 - bits);
-}
-
 /* Return 1 if the slot with the index IDX in the hash table HT is
    empty, and 0 otherwise.  */
 static inline int
@@ -74,7 +61,7 @@ find_index (hurd_ihash_t ht, hurd_ihash_key_t key)
   unsigned int up_idx;
   unsigned int mask = ht->size - 1;
 
-  idx = murmur3_mix32 (key, __builtin_ctzl (ht->size));
+  idx = key & mask;
 
   if (ht->items[idx].value == _HURD_IHASH_EMPTY || ht->items[idx].key == key)
     return idx;
@@ -205,20 +192,19 @@ hurd_ihash_set_max_load (hurd_ihash_t ht, unsigned int 
max_load)
    found.  The arguments are identical to hurd_ihash_add.
 
    We are using open address hashing.  As the hash function we use the
-   division method with quadratic probe.  This is guaranteed to try
-   all slots in the hash table if the prime number is 3 mod 4.  */
+   division method with linear probe.  */
 static inline int
 add_one (hurd_ihash_t ht, hurd_ihash_key_t key, hurd_ihash_value_t value)
 {
   unsigned int idx;
   unsigned int first_free;
+  unsigned int mask = ht->size - 1;
 
-  idx = murmur3_mix32 (key, __builtin_ctzl (ht->size));
+  idx = key & mask;
   first_free = idx;
 
   if (ht->items[idx].value != _HURD_IHASH_EMPTY && ht->items[idx].key != key)
     {
-      unsigned int mask = ht->size - 1;
       unsigned int up_idx = idx;
 
       do
diff --git a/libpager/priv.h b/libpager/priv.h
index d49cbb9..1f8405a 100644
--- a/libpager/priv.h
+++ b/libpager/priv.h
@@ -59,8 +59,6 @@ struct pager
 
   int noterm;                  /* number of threads blocking termination */
 
-  struct pager *next, **pprev;
-
   int termwaiting:1;
   int waitingforseqno:1;
 
diff --git a/libpipe/pipe.c b/libpipe/pipe.c
index 1080b5d..f9300e7 100644
--- a/libpipe/pipe.c
+++ b/libpipe/pipe.c
@@ -352,7 +352,9 @@ pipe_send (struct pipe *pipe, int noblock, void *source,
          if (!err)
            err = packet_set_ports (control_packet, ports, num_ports);
          if (err)
-           /* Trash CONTROL_PACKET somehow XXX */;
+           {
+             /* Trash CONTROL_PACKET somehow XXX */
+           }
        }
     }
 
diff --git a/libtrivfs/cntl-create.c b/libtrivfs/cntl-create.c
index 910daf3..eb9a834 100644
--- a/libtrivfs/cntl-create.c
+++ b/libtrivfs/cntl-create.c
@@ -85,7 +85,6 @@ trivfs_create_control (mach_port_t underlying,
        }
 
       (*control)->hook = 0;
-      pthread_mutex_init (&(*control)->lock, NULL);
     }
 
 out:
diff --git a/libtrivfs/io-reauthenticate.c b/libtrivfs/io-reauthenticate.c
index 7677697..df0ed2e 100644
--- a/libtrivfs/io-reauthenticate.c
+++ b/libtrivfs/io-reauthenticate.c
@@ -62,11 +62,8 @@ trivfs_S_io_reauthenticate (struct trivfs_protid *cred,
     newcred->isroot = 1;
 
   newcred->hook = cred->hook;
-
-  pthread_mutex_lock (&cred->po->cntl->lock);
   newcred->po = cred->po;
-  newcred->po->refcnt++;
-  pthread_mutex_unlock (&cred->po->cntl->lock);
+  refcount_ref (&newcred->po->refcnt);
 
   do
     err = io_restrict_auth (newcred->po->cntl->underlying, &newcred->realnode,
diff --git a/libtrivfs/io-restrict-auth.c b/libtrivfs/io-restrict-auth.c
index 65b4fd6..39670fe 100644
--- a/libtrivfs/io-restrict-auth.c
+++ b/libtrivfs/io-restrict-auth.c
@@ -110,10 +110,8 @@ trivfs_S_io_restrict_auth (struct trivfs_protid *cred,
     }
 
   newcred->isroot = 0;
-  pthread_mutex_lock (&cred->po->cntl->lock);
   newcred->po = cred->po;
-  newcred->po->refcnt++;
-  pthread_mutex_unlock (&cred->po->cntl->lock);
+  refcount_ref (&newcred->po->refcnt);
   if (cred->isroot && idvec_contains (user->uids, 0))
     newcred->isroot = 1;
   newcred->user = user;
diff --git a/libtrivfs/open.c b/libtrivfs/open.c
index f64d2ff..97e70a1 100644
--- a/libtrivfs/open.c
+++ b/libtrivfs/open.c
@@ -40,7 +40,7 @@ trivfs_open (struct trivfs_control *cntl,
 
   ports_port_ref (cntl);
 
-  po->refcnt = 1;
+  refcount_init (&po->refcnt, 1);
   po->cntl = cntl;
   po->openmodes = flags;
   po->hook = 0;
diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c
index f98da6a..86fbc19 100644
--- a/libtrivfs/protid-clean.c
+++ b/libtrivfs/protid-clean.c
@@ -31,19 +31,26 @@ trivfs_clean_protid (void *arg)
     (*trivfs_protid_destroy_hook) (cred);
 
   /* If we hold the only reference to the peropen, try to get rid of it. */
-  pthread_mutex_lock (&cntl->lock);
-  if (cred->po->refcnt == 1 && trivfs_peropen_destroy_hook)
+  if (trivfs_peropen_destroy_hook)
     {
-      pthread_mutex_unlock (&cntl->lock);
-      (*trivfs_peropen_destroy_hook) (cred->po);
-      pthread_mutex_lock (&cntl->lock);
+      if (refcount_deref (&cred->po->refcnt) == 0)
+        {
+          /* Reaquire a reference while we call the hook.  */
+          refcount_ref (&cred->po->refcnt);
+          (*trivfs_peropen_destroy_hook) (cred->po);
+          if (refcount_deref (&cred->po->refcnt) == 0)
+            {
+              ports_port_deref (cntl);
+              free (cred->po);
+            }
+        }
     }
-  if (--cred->po->refcnt == 0)
-    {
-      ports_port_deref (cntl);
-      free (cred->po);
-    }
-  pthread_mutex_unlock (&cntl->lock);
+  else
+    if (refcount_deref (&cred->po->refcnt) == 0)
+      {
+        ports_port_deref (cntl);
+        free (cred->po);
+      }
 
   iohelp_free_iouser (cred->user);
 
diff --git a/libtrivfs/protid-dup.c b/libtrivfs/protid-dup.c
index 6169603..75f3ca8 100644
--- a/libtrivfs/protid-dup.c
+++ b/libtrivfs/protid-dup.c
@@ -35,11 +35,8 @@ trivfs_protid_dup (struct trivfs_protid *cred, struct 
trivfs_protid **dup)
 
   if (! err)
     {
-      pthread_mutex_lock (&cred->po->cntl->lock);
       new->po = cred->po;
-      new->po->refcnt++;
-      pthread_mutex_unlock (&cred->po->cntl->lock);
-
+      refcount_ref (&new->po->refcnt);
       new->isroot = cred->isroot;
 
       err = iohelp_dup_iouser (&new->user, cred->user);
diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h
index bb456ff..8902338 100644
--- a/libtrivfs/trivfs.h
+++ b/libtrivfs/trivfs.h
@@ -24,6 +24,7 @@
 #include <mach/mach.h>
 #include <hurd/ports.h>
 #include <hurd/iohelp.h>
+#include <refcount.h>
 
 struct trivfs_protid
 {
@@ -41,14 +42,13 @@ struct trivfs_peropen
 {
   void *hook;                  /* for user use */
   int openmodes;
-  int refcnt;
+  refcount_t refcnt;
   struct trivfs_control *cntl;
 };
 
 struct trivfs_control
 {
   struct port_info pi;
-  pthread_mutex_t lock;
   struct port_class *protid_class;
   struct port_bucket *protid_bucket;
   mach_port_t filesys_id;
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index f514ea6..380c724 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -88,13 +88,13 @@ synchronized_printf (const char *fmt, ...)
 #if 0
 #define dprintf(f, x...)       synchronized_printf (f, ##x)
 #else
-#define dprintf(f, x...)
+#define dprintf(f, x...)       (void) 0
 #endif
 
 #if 0
 #define ddprintf(f, x...)      synchronized_printf (f, ##x)
 #else
-#define ddprintf(f, x...)
+#define ddprintf(f, x...)      (void) 0
 #endif
 
 /*
diff --git a/pfinet/linux-src/include/net/addrconf.h 
b/pfinet/linux-src/include/net/addrconf.h
index d711d0d..4b27077 100644
--- a/pfinet/linux-src/include/net/addrconf.h
+++ b/pfinet/linux-src/include/net/addrconf.h
@@ -1,6 +1,8 @@
 #ifndef _ADDRCONF_H
 #define _ADDRCONF_H
 
+#include "ipv6.h"
+
 #define RETRANS_TIMER  HZ
 
 #define MAX_RTR_SOLICITATIONS          3
diff --git a/pfinet/linux-src/net/ipv4/fib_hash.c 
b/pfinet/linux-src/net/ipv4/fib_hash.c
index d9e029c..e3987ea 100644
--- a/pfinet/linux-src/net/ipv4/fib_hash.c
+++ b/pfinet/linux-src/net/ipv4/fib_hash.c
@@ -406,7 +406,7 @@ static void rtmsg_fib(int, struct fib_node*, int, int,
                      struct nlmsghdr *n,
                      struct netlink_skb_parms *);
 #else
-#define rtmsg_fib(a, b, c, d, e, f)
+#define rtmsg_fib(a, b, c, d, e, f)    (void) 0
 #endif
 
 
diff --git a/pflocal/connq.c b/pflocal/connq.c
index d88711e..d86f9a2 100644
--- a/pflocal/connq.c
+++ b/pflocal/connq.c
@@ -212,7 +212,7 @@ connq_listen (struct connq *cq, struct timespec *tsp, 
struct sock **sock)
        request and another listener (should) eventually come along.
        (In fact it is very probably as the caller has likely done a
        select and will now follow up with an accept.)  */
-    ;
+    { /* Do nothing.  */ }
 
  out:
   pthread_mutex_unlock (&cq->lock);
diff --git a/pflocal/socket.c b/pflocal/socket.c
index 7142c6e..792c637 100644
--- a/pflocal/socket.c
+++ b/pflocal/socket.c
@@ -198,7 +198,9 @@ S_socket_accept (struct sock_user *user,
              ports_port_deref (peer_addr);
            }
          else
-           /* TEAR DOWN THE CONNECTION XXX */;
+           {
+             /* TEAR DOWN THE CONNECTION XXX */
+           }
        }
     }
 
diff --git a/procfs/Makefile b/procfs/Makefile
index 5c51c1d..2820596 100644
--- a/procfs/Makefile
+++ b/procfs/Makefile
@@ -1,6 +1,6 @@
 TARGET = procfs
 OBJS = procfs.o netfs.o procfs_dir.o \
-       process.o proclist.o rootdir.o dircat.o main.o
+       process.o proclist.o rootdir.o dircat.o main.o mach_debugUser.o
 LIBS = -lnetfs -lps -lfshelp -lpthread
 
 CC = gcc
@@ -19,8 +19,28 @@ CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 
 all: $(TARGET)
 
+rootdir.o: rootdir.c mach_debug_U.h
+
 $(TARGET): $(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 clean:
        $(RM) $(TARGET) $(OBJS)
+
+# This is the gist of the MIG user stub handling from Hurd's build
+# system:
+
+# Where to find .defs files.
+vpath %.defs /usr/include/mach_debug
+
+MIG = mig
+MIGCOM = $(MIG) -cc cat - /dev/null
+MIGCOMFLAGS := -subrprefix __
+
+%.udefsi: %.defs
+       $(CPP) -x c $(CPPFLAGS) $(MIGUFLAGS) $($*-MIGUFLAGS) \
+         $< -o $*.udefsi
+
+%_U.h %User.c: %.udefsi
+       $(MIGCOM) $(MIGCOMFLAGS) $(MIGCOMUFLAGS) $($*-MIGCOMUFLAGS) < $< \
+                 -user $*User.c -server /dev/null -header $*_U.h
diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index 94b0ddb..076885c 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -22,6 +22,7 @@
 #include <mach/vm_statistics.h>
 #include <mach/vm_cache_statistics.h>
 #include <mach/default_pager.h>
+#include <mach_debug/mach_debug_types.h>
 #include <hurd/paths.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -35,6 +36,8 @@
 #include "procfs_dir.h"
 #include "main.h"
 
+#include "mach_debug_U.h"
+
 /* This implements a directory node with the static files in /proc.
    NB: the libps functions for host information return static storage;
    using them would require locking and as a consequence it would be
@@ -470,6 +473,69 @@ rootdir_mounts_exists (void *dir_hook, const void 
*entry_hook)
     translator_exists = access (MTAB_TRANSLATOR, F_OK|X_OK) == 0;
   return translator_exists;
 }
+
+static error_t
+rootdir_gc_slabinfo (void *hook, char **contents, ssize_t *contents_len)
+{
+  error_t err;
+  FILE *m;
+  const char header[] =
+    "cache                          obj slab  bufs   objs   bufs"
+    "    total reclaimable\n"
+    "name                  flags   size size /slab  usage  count"
+    "   memory      memory\n";
+  cache_info_array_t cache_info;
+  size_t mem_usage, mem_reclaimable, mem_total, mem_total_reclaimable;
+  mach_msg_type_number_t cache_info_count;
+  int i;
+
+  cache_info = NULL;
+  cache_info_count = 0;
+
+  err = host_slab_info (mach_host_self(), &cache_info, &cache_info_count);
+  if (err)
+    return err;
+
+  m = open_memstream (contents, contents_len);
+  if (m == NULL)
+    {
+      err = ENOMEM;
+      goto out;
+    }
+
+  fprintf (m, "%s", header);
+
+  mem_total = 0;
+  mem_total_reclaimable = 0;
+
+  for (i = 0; i < cache_info_count; i++)
+    {
+      mem_usage = (cache_info[i].nr_slabs * cache_info[i].slab_size)
+       >> 10;
+      mem_total += mem_usage;
+      mem_reclaimable = (cache_info[i].flags & CACHE_FLAGS_NO_RECLAIM)
+       ? 0 : (cache_info[i].nr_free_slabs
+              * cache_info[i].slab_size) >> 10;
+      mem_total_reclaimable += mem_reclaimable;
+      fprintf (m,
+               "%-21s %04x %7zu %3zuk  %4lu %6lu %6lu %7zuk %10zuk\n",
+               cache_info[i].name, cache_info[i].flags,
+               cache_info[i].obj_size, cache_info[i].slab_size >> 10,
+               cache_info[i].bufs_per_slab, cache_info[i].nr_objs,
+               cache_info[i].nr_bufs, mem_usage, mem_reclaimable);
+    }
+
+  fprintf (m, "total: %zuk, reclaimable: %zuk\n",
+           mem_total, mem_total_reclaimable);
+
+  fclose (m);
+  *contents_len += 1;  /* For the terminating 0.  */
+
+ out:
+  vm_deallocate (mach_task_self (),
+                 cache_info, cache_info_count * sizeof *cache_info);
+  return err;
+}
 
 /* Glue logic and entries table */
 
@@ -563,6 +629,13 @@ static const struct procfs_dir_entry rootdir_entries[] = {
       .exists = rootdir_mounts_exists,
     }
   },
+  {
+    .name = "slabinfo",
+    .hook = & (struct procfs_node_ops) {
+      .get_contents = rootdir_gc_slabinfo,
+      .cleanup_contents = procfs_cleanup_contents_with_free,
+    },
+  },
 #ifdef PROFILE
   /* In order to get a usable gmon.out file, we must apparently use exit(). */
   {
diff --git a/term/users.c b/term/users.c
index 97bc22c..9bd51d0 100644
--- a/term/users.c
+++ b/term/users.c
@@ -259,9 +259,7 @@ pi_destroy_hook (struct trivfs_protid *cred)
     {
       assert (((struct protid_hook *)cred->hook)->refcnt > 0);
       if (--((struct protid_hook *)cred->hook)->refcnt == 0)
-       /* XXX don't free for now, so we can try and catch a multiple-freeing
-          bug.  */
-       /* free (cred->hook) */;
+       free (cred->hook);
     }
   pthread_mutex_unlock (&global_lock);
 }
diff --git a/trans/mtab.c b/trans/mtab.c
index 8c9f8d3..df03b1d 100644
--- a/trans/mtab.c
+++ b/trans/mtab.c
@@ -255,7 +255,7 @@ main (int argc, char *argv[])
   else
     {
       /* One-shot mode.         */
-      struct mtab mtab = { NULL, 0, 0 };
+      struct mtab mtab = { .lock = PTHREAD_MUTEX_INITIALIZER };
       err = mtab_populate (&mtab, target_path, insecure);
       if (err)
        error (5, err, "%s", target_path);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]