bug-hurd
[Top][All Lists]
Advanced

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

[PATCH hurd 7/8] ext2fs: annotate objects managed by libports


From: Justus Winter
Subject: [PATCH hurd 7/8] ext2fs: annotate objects managed by libports
Date: Thu, 23 Oct 2014 17:16:45 +0200

Install a specialized version of libpagers format_debug_info which
prints more detailed information, like the nodes inode number for file
pager objects.  Also label both pager buckets.

* ext2fs/pager-create.c (format_debug_info): New function.
(create_disk_pager): Install our own format_debug_info function.
Label both pager buckets.
---
 ext2fs/pager.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 39cf1c7..2d4a0d1 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -19,10 +19,12 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 #include <unistd.h>
+#include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <error.h>
 #include <hurd/store.h>
+#include <inttypes.h>
 #include "ext2fs.h"
 
 /* XXX */
@@ -1207,6 +1209,43 @@ service_paging_requests (void *arg)
   return NULL;
 }
 
+/* Provide a human-readable description of the given pager object.  */
+static error_t
+format_debug_info (const void *port, char *buffer, size_t size)
+{
+  const struct pager *pager = port;
+  const struct port_info *pi = port;
+
+  if (pager->upi->type == FILE_DATA)
+    {
+      int hard, weak;
+
+      pthread_spin_lock (&diskfs_node_refcnt_lock);
+      hard = pager->upi->node->references;
+      weak = pager->upi->node->light_references;
+      pthread_spin_unlock (&diskfs_node_refcnt_lock);
+
+      snprintf (buffer, size,
+               "bucket: %s, class: %s"
+               ", node{inode: %"PRIu64", hard: %u, weak: %u}",
+               pi->bucket->label,
+               pi->class->label,
+               pager->upi->node->cache_id,
+               hard,
+               weak);
+    }
+  else
+    snprintf (buffer, size,
+             "bucket: %s, class: %s, may_cache: %d",
+             pi->bucket->label,
+             pi->class->label,
+             /* XXX I have no idea what might be interesting to print
+                here, but it is straight forward to add stuff.  */
+             pager->may_cache);
+
+  return 0;
+}
+
 /* Create the disk pager, and the file pager.  */
 void
 create_disk_pager (void)
@@ -1215,12 +1254,15 @@ create_disk_pager (void)
   pthread_attr_t attr;
   error_t err;
 
+  ports_label_class (_pager_class, "_pager_class", format_debug_info);
+
   /* The disk pager.  */
   struct user_pager_info *upi = malloc (sizeof (struct user_pager_info));
   if (!upi)
     ext2_panic ("can't create disk pager: %s", strerror (errno));
   upi->type = DISK;
   disk_pager_bucket = ports_create_bucket ();
+  ports_label_bucket (disk_pager_bucket, "disk_pager_bucket");
   get_hypermetadata ();
   disk_cache_blocks = DISK_CACHE_BLOCKS;
   disk_cache_size = disk_cache_blocks << log2_block_size;
@@ -1230,6 +1272,7 @@ create_disk_pager (void)
 
   /* The file pager.  */
   file_pager_bucket = ports_create_bucket ();
+  ports_label_bucket (file_pager_bucket, "file_pager_bucket");
 
 #define STACK_SIZE (64 * 1024)
   pthread_attr_init (&attr);
-- 
2.1.1




reply via email to

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