From: Jan Kiszka <jan.kiszka@domain.hid>
To: rpm@xenomai.org
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
Date: Tue, 26 Aug 2008 19:08:13 +0200 [thread overview]
Message-ID: <48B4387D.7060701@domain.hid> (raw)
In-Reply-To: <48B42DB6.4050704@domain.hid>
Philippe Gerum wrote:
> Jan Kiszka wrote:
>> Philippe Gerum wrote:
>>> Jan Kiszka wrote:
>>>> Some customer ran into the problem of lacking registry slots without
>>>> prior warning. We are lacking some report mechanism, specifically for
>>>> unexported (anonymous) entries (every native user object requires one
>>>> for its handle).
>>>>
>>>> This patch introduces /proc/xenomai/registry_usage in the form
>>>>
>>> Eeek. /proc/xenomai/registry/status or /usage. Otherwise, ok.
>> There was a reason, there was a reason... Ah! That subdir depends on
>> CONFIG_XENO_EXPORT_REGISTRY. Needs more refactoring then... :-]
>>
>
> Ok, I'm freezing this one, waiting for next iteration.
Here it comes (previous version was also lacking a cleanup):
---
ksrc/nucleus/registry.c | 68 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 57 insertions(+), 11 deletions(-)
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>
@@ -76,12 +78,41 @@ static xnqueue_t registry_obj_procq; /*
static DECLARE_WORK_NODATA(registry_proc_work, ®istry_proc_callback);
#endif /* !CONFIG_PREEMPT_RT */
-static struct proc_dir_entry *registry_proc_root;
-
static int registry_proc_apc;
#endif /* CONFIG_XENO_EXPORT_REGISTRY */
+#ifdef CONFIG_PROC_FS
+static struct proc_dir_entry *registry_proc_root;
+
+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(®istry_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[] = {
@@ -100,22 +131,28 @@ int xnregistry_init(void)
if (registry_obj_slots == NULL)
return -ENOMEM;
+#ifdef CONFIG_PROC_FS
+ registry_proc_root = create_proc_entry("registry",
+ S_IFDIR, rthal_proc_root);
+ if (!registry_proc_root)
+ return -ENOMEM;
+
+ rthal_add_proc_leaf("usage", registry_usage_read_proc,
+ NULL, NULL, registry_proc_root);
+
#ifdef CONFIG_XENO_EXPORT_REGISTRY
registry_proc_apc =
rthal_apc_alloc("registry_export", ®istry_proc_schedule, NULL);
- if (registry_proc_apc < 0)
+ if (registry_proc_apc < 0) {
+ remove_proc_entry("usage", registry_proc_root);
+ remove_proc_entry("registry", rthal_proc_root);
return registry_proc_apc;
-
- registry_proc_root = create_proc_entry("registry",
- S_IFDIR, rthal_proc_root);
- if (!registry_proc_root) {
- rthal_apc_free(registry_proc_apc);
- return -ENOMEM;
}
initq(®istry_obj_procq);
#endif /* CONFIG_XENO_EXPORT_REGISTRY */
+#endif /* CONFIG_PROC_FS */
initq(®istry_obj_freeq);
initq(®istry_obj_busyq);
@@ -136,10 +173,13 @@ int xnregistry_init(void)
registry_hash_entries);
if (!registry_hash_table) {
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("usage", registry_proc_root);
+ remove_proc_entry("registry", rthal_proc_root);
#ifdef CONFIG_XENO_EXPORT_REGISTRY
rthal_apc_free(registry_proc_apc);
- remove_proc_entry("registry", rthal_proc_root);
#endif /* CONFIG_XENO_EXPORT_REGISTRY */
+#endif /* CONFIG_PROC_FS */
return -ENOMEM;
}
@@ -195,9 +235,13 @@ void xnregistry_cleanup(void)
#ifdef CONFIG_XENO_EXPORT_REGISTRY
rthal_apc_free(registry_proc_apc);
flush_scheduled_work();
- remove_proc_entry("registry", rthal_proc_root);
#endif /* CONFIG_XENO_EXPORT_REGISTRY */
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("usage", registry_proc_root);
+ remove_proc_entry("registry", rthal_proc_root);
+#endif /* CONFIG_PROC_FS */
+
xnarch_free_host_mem(registry_obj_slots,
CONFIG_XENO_OPT_REGISTRY_NRSLOTS * sizeof(xnobject_t));
}
@@ -269,6 +313,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(®istry_obj_busyq, holder);
@@ -326,6 +371,7 @@ static DECLARE_WORK_FUNC(registry_proc_c
continue;
unexport:
+ registry_exported_objects--;
entries = --pnode->entries;
entry = object->proc;
object->proc = NULL;
next prev parent reply other threads:[~2008-08-26 17:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
2008-08-26 11:49 ` [Xenomai-core] [PATCH 1/6] Remove / shorten critical sections in registry code Jan Kiszka
2008-08-26 11:51 ` [Xenomai-core] [PATCH 2/6] Allow key-less registry entries Jan Kiszka
2008-08-26 11:53 ` [Xenomai-core] [PATCH 3/6] Native skin: Use " Jan Kiszka
2008-08-26 11:55 ` [Xenomai-core] [PATCH 4/6] Eliminate xnobjhash Jan Kiszka
2008-08-26 11:56 ` [Xenomai-core] [RESEND][PATCH 5/6] Avoid add_proc_leaf duplicates Jan Kiszka
2008-08-26 11:58 ` [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc Jan Kiszka
2008-08-26 16:08 ` Philippe Gerum
2008-08-26 16:19 ` Jan Kiszka
2008-08-26 16:22 ` Philippe Gerum
2008-08-26 17:08 ` Jan Kiszka [this message]
2008-08-26 13:40 ` [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Gilles Chanteperdrix
2008-08-26 16:03 ` Philippe Gerum
2008-08-27 9:35 ` Philippe Gerum
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=48B4387D.7060701@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=rpm@xenomai.org \
--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.