All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH 2/2] Report registry slot usage via /proc
Date: Tue, 19 Aug 2008 18:14:07 +0200	[thread overview]
Message-ID: <48AAF14F.2020204@domain.hid> (raw)

Some customer ran into the problem of lacking registry slots without
prior warning. We are lacking some report mechanism, specifically for
unexported entries (every user object requires one for its handle).

This patch introduces /proc/xenomai/registry_usage in the form

slots=512:used=1:exported=0

to address the deficit.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
 ksrc/nucleus/registry.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -60,6 +60,8 @@ static int registry_hash_entries;
 
 static xnsynch_t registry_hash_synch;
 
+static unsigned registry_exported_objects;
+
 #ifdef CONFIG_XENO_EXPORT_REGISTRY
 
 #include <linux/workqueue.h>
@@ -82,6 +84,35 @@ static int registry_proc_apc;
 
 #endif /* CONFIG_XENO_EXPORT_REGISTRY */
 
+#ifdef CONFIG_PROC_FS
+static int
+registry_usage_read_proc(char *page, char **start, off_t off,
+			 int count, int *eof, void *data)
+{
+	int len;
+
+	if (!xnpod_active_p())
+		return -ESRCH;
+
+	len = sprintf(page, "slots=%u:used=%u:exported=%u\n",
+		      CONFIG_XENO_OPT_REGISTRY_NRSLOTS,
+		      CONFIG_XENO_OPT_REGISTRY_NRSLOTS -
+		      countq(&registry_obj_freeq),
+		      registry_exported_objects);
+
+	len -= off;
+	if (len <= off + count)
+		*eof = 1;
+	*start = page + off;
+	if (len > count)
+		len = count;
+	if (len < 0)
+		len = 0;
+
+	return len;
+}
+#endif /* CONFIG_PROC_FS */
+
 int xnregistry_init(void)
 {
 	static const int primes[] = {
@@ -117,6 +148,11 @@ int xnregistry_init(void)
 	initq(&registry_obj_procq);
 #endif /* CONFIG_XENO_EXPORT_REGISTRY */
 
+#ifdef CONFIG_PROC_FS
+	rthal_add_proc_leaf("registry_usage", registry_usage_read_proc,
+			    NULL, NULL, rthal_proc_root);
+#endif /* CONFIG_PROC_FS */
+
 	initq(&registry_obj_freeq);
 	initq(&registry_obj_busyq);
 	registry_obj_stamp = 0;
@@ -136,6 +172,9 @@ int xnregistry_init(void)
 					     registry_hash_entries);
 
 	if (!registry_hash_table) {
+#ifdef CONFIG_PROC_FS
+		remove_proc_entry("registry_usage", rthal_proc_root);
+#endif /* CONFIG_PROC_FS */
 #ifdef CONFIG_XENO_EXPORT_REGISTRY
 		rthal_apc_free(registry_proc_apc);
 		remove_proc_entry("registry", rthal_proc_root);
@@ -272,6 +311,7 @@ static DECLARE_WORK_FUNC(registry_proc_c
 		if (object->proc != XNOBJECT_PROC_RESERVED1)
 			goto unexport;
 
+		registry_exported_objects++;
 		++pnode->entries;
 		object->proc = XNOBJECT_PROC_RESERVED2;
 		appendq(&registry_obj_busyq, holder);
@@ -329,6 +369,7 @@ static DECLARE_WORK_FUNC(registry_proc_c
 		continue;
 
 	unexport:
+		registry_exported_objects--;
 		entries = --pnode->entries;
 		entry = object->proc;
 		object->proc = NULL;


                 reply	other threads:[~2008-08-19 16:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48AAF14F.2020204@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.