* [Xenomai-core] [PATCH 1/6] Remove / shorten critical sections in registry code
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
@ 2008-08-26 11:49 ` Jan Kiszka
2008-08-26 11:51 ` [Xenomai-core] [PATCH 2/6] Allow key-less registry entries Jan Kiszka
` (6 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:49 UTC (permalink / raw)
To: xenomai-core
See Changelog.
---
ChangeLog | 6 ++++++
ksrc/nucleus/registry.c | 44 +++++++++++++-------------------------------
2 files changed, 19 insertions(+), 31 deletions(-)
Index: b/ChangeLog
===================================================================
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-26 Jan Kiszka <jan.kiszka@domain.hid>
+
+ * ksrc/nucleus/registry.c (xnregistry_fetch/get/put): Remove
+ pointless locking, move XNOBJECT_SELF lookups out of critical
+ sections.
+
2008-08-25 Jan Kiszka <jan.kiszka@domain.hid>
* include/asm-generic/wrappers.h: Provide atomic_long wrappings.
Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -1024,16 +1024,14 @@ void *xnregistry_get(xnhandle_t handle)
void *objaddr;
spl_t s;
- xnlock_get_irqsave(&nklock, s);
-
if (handle == XNOBJECT_SELF) {
- if (!xnpod_primary_p()) {
- objaddr = NULL;
- goto unlock_and_exit;
- }
+ if (!xnpod_primary_p())
+ return NULL;
handle = xnpod_current_thread()->registry.handle;
}
+ xnlock_get_irqsave(&nklock, s);
+
object = registry_validate(handle);
if (object) {
@@ -1042,8 +1040,6 @@ void *xnregistry_get(xnhandle_t handle)
} else
objaddr = NULL;
- unlock_and_exit:
-
xnlock_put_irqrestore(&nklock, s);
return objaddr;
@@ -1087,17 +1083,14 @@ u_long xnregistry_put(xnhandle_t handle)
u_long newlock;
spl_t s;
- xnlock_get_irqsave(&nklock, s);
-
if (handle == XNOBJECT_SELF) {
- if (!xnpod_primary_p()) {
- newlock = 0;
- goto unlock_and_exit;
- }
-
+ if (!xnpod_primary_p())
+ return 0;
handle = xnpod_current_thread()->registry.handle;
}
+ xnlock_get_irqsave(&nklock, s);
+
object = registry_validate(handle);
if (!object) {
@@ -1150,28 +1143,17 @@ u_long xnregistry_put(xnhandle_t handle)
void *xnregistry_fetch(xnhandle_t handle)
{
xnobject_t *object;
- void *objaddr;
- spl_t s;
-
- xnlock_get_irqsave(&nklock, s);
- if (handle == XNOBJECT_SELF) {
- objaddr = xnpod_primary_p()? xnpod_current_thread() : NULL;
- goto unlock_and_exit;
- }
+ if (handle == XNOBJECT_SELF)
+ return xnpod_primary_p()? xnpod_current_thread() : NULL;
object = registry_validate(handle);
- if (object)
- objaddr = object->objaddr;
- else
- objaddr = NULL;
-
- unlock_and_exit:
+ if (!object)
+ return NULL;
- xnlock_put_irqrestore(&nklock, s);
+ return object->objaddr;
- return objaddr;
}
/*@}*/
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [PATCH 2/6] Allow key-less registry entries
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 ` Jan Kiszka
2008-08-26 11:53 ` [Xenomai-core] [PATCH 3/6] Native skin: Use " Jan Kiszka
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:51 UTC (permalink / raw)
To: xenomai-core
No need to add anonymous registry entries with pseudo names to the hash
table - no one will look them up anyway. Reduces hash key collisions for
named objects.
---
ChangeLog | 3 +++
ksrc/nucleus/registry.c | 34 ++++++++++++++++++++++------------
2 files changed, 25 insertions(+), 12 deletions(-)
Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -542,7 +542,9 @@ static inline unsigned registry_wakeup_s
* @param key A valid NULL-terminated string by which the object will
* be indexed and later retrieved in the registry. Since it is assumed
* that such key is stored into the registered object, it will *not*
- * be copied but only kept by reference in the registry.
+ * be copied but only kept by reference in the registry. Pass an empty
+ * string if the object shall only occupy a registry slot
+ * for handle-based lookups.
*
* @param objaddr An opaque pointer to the object to index by @a
* key.
@@ -560,8 +562,8 @@ static inline unsigned registry_wakeup_s
*
* @return 0 is returned upon success. Otherwise:
*
- * - -EINVAL is returned if @a key or @a objaddr are NULL, or if @a
- * key constains an invalid '/' character.
+ * - -EINVAL is returned if @a objaddr are NULL, or if @a key constains
+ * an invalid '/' character.
*
* - -ENOMEM is returned if the system fails to get enough dynamic
* memory from the global real-time heap in order to register the
@@ -601,6 +603,18 @@ int xnregistry_enter(const char *key,
object = link2xnobj(holder);
+ xnsynch_init(&object->safesynch, XNSYNCH_FIFO);
+ object->objaddr = objaddr;
+ object->cstamp = ++registry_obj_stamp;
+ object->safelock = 0;
+ object->pnode = NULL;
+
+ if (!*key) {
+ object->key = NULL;
+ *phandle = object - registry_obj_slots;
+ return 0;
+ }
+
err = registry_hash_enter(key, object);
if (err) {
@@ -608,10 +622,6 @@ int xnregistry_enter(const char *key,
goto unlock_and_exit;
}
- xnsynch_init(&object->safesynch, XNSYNCH_FIFO);
- object->objaddr = objaddr;
- object->cstamp = ++registry_obj_stamp;
- object->safelock = 0;
appendq(®istry_obj_busyq, holder);
/* <!> Make sure the handle is written back before the
@@ -621,10 +631,6 @@ int xnregistry_enter(const char *key,
#ifdef CONFIG_XENO_EXPORT_REGISTRY
if (pnode)
registry_proc_export(object, pnode);
- else {
- object->proc = NULL;
- object->pnode = NULL;
- }
#endif /* CONFIG_XENO_EXPORT_REGISTRY */
if (registry_wakeup_sleepers(key))
@@ -831,10 +837,14 @@ int xnregistry_remove(xnhandle_t handle)
object->pnode->type);
#endif
- registry_hash_remove(object);
object->objaddr = NULL;
object->cstamp = 0;
+ if (!object->key)
+ goto unlock_and_exit;
+
+ registry_hash_remove(object);
+
#ifdef CONFIG_XENO_EXPORT_REGISTRY
if (object->pnode) {
registry_proc_unexport(object);
Index: b/ChangeLog
===================================================================
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2008-08-26 Jan Kiszka <jan.kiszka@domain.hid>
+ * ksrc/nucleus/registry.c (xnregistry_enter/remove): Allow for
+ key-less anonymous object registration.
+
* ksrc/nucleus/registry.c (xnregistry_fetch/get/put): Remove
pointless locking, move XNOBJECT_SELF lookups out of critical
sections.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [PATCH 3/6] Native skin: Use key-less registry entries
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 ` Jan Kiszka
2008-08-26 11:55 ` [Xenomai-core] [PATCH 4/6] Eliminate xnobjhash Jan Kiszka
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:53 UTC (permalink / raw)
To: xenomai-core
Make use of the new key-less property of xnregistry_enter, cleaning up
most pointless pseudo name creations for anonymous objects.
---
ksrc/skins/native/alarm.c | 22 +++++++++-------------
ksrc/skins/native/buffer.c | 15 ++-------------
ksrc/skins/native/cond.c | 14 ++------------
ksrc/skins/native/event.c | 15 ++-------------
ksrc/skins/native/heap.c | 14 ++------------
ksrc/skins/native/intr.c | 17 +++--------------
ksrc/skins/native/mutex.c | 15 ++-------------
ksrc/skins/native/pipe.c | 14 ++------------
ksrc/skins/native/queue.c | 12 +-----------
ksrc/skins/native/sem.c | 14 ++------------
ksrc/skins/native/task.c | 16 ++--------------
11 files changed, 29 insertions(+), 139 deletions(-)
Index: b/ksrc/skins/native/alarm.c
===================================================================
--- a/ksrc/skins/native/alarm.c
+++ b/ksrc/skins/native/alarm.c
@@ -212,24 +212,20 @@ int rt_alarm_create(RT_ALARM *alarm,
#endif /* CONFIG_XENO_OPT_PERVASIVE */
if (name) {
-#ifdef CONFIG_XENO_OPT_REGISTRY
- /* <!> Since xnregister_enter() may reschedule, only register
- complete objects, so that the registry cannot return
- handles to half-baked objects... */
-
- xnpnode_t *pnode = &__alarm_pnode;
-
if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
+ /* To improve readability in timer_base /proc
+ output. */
xnobject_create_name(alarm->name, sizeof(alarm->name),
(void *)alarm);
- pnode = NULL;
}
- err =
- xnregistry_enter(alarm->name, alarm, &alarm->handle, pnode);
+#ifdef CONFIG_XENO_OPT_REGISTRY
+ /* <!> Since xnregister_enter() may reschedule, only register
+ complete objects, so that the registry cannot return
+ handles to half-baked objects... */
+
+ err = xnregistry_enter((*name) ? alarm->name : "", alarm,
+ &alarm->handle, &__alarm_pnode);
if (err)
rt_alarm_delete(alarm);
Index: b/ksrc/skins/native/buffer.c
===================================================================
--- a/ksrc/skins/native/buffer.c
+++ b/ksrc/skins/native/buffer.c
@@ -221,20 +221,9 @@ int rt_buffer_create(RT_BUFFER *bf, cons
* handles to half-baked objects...
*/
if (name) {
- xnpnode_t *pnode = &__buffer_pnode;
+ ret = xnregistry_enter(bf->name, bf, &bf->handle,
+ &__buffer_pnode);
- if (!*name) {
- /*
- * Since this is an anonymous object (empty
- * name on entry) from user-space, it gets
- * registered under an unique internal name
- * but is not exported through /proc.
- */
- xnobject_create_name(bf->name, sizeof(bf->name), bf);
- pnode = NULL;
- }
-
- ret = xnregistry_enter(bf->name, bf, &bf->handle, pnode);
if (ret)
rt_buffer_delete(bf);
}
Index: b/ksrc/skins/native/cond.c
===================================================================
--- a/ksrc/skins/native/cond.c
+++ b/ksrc/skins/native/cond.c
@@ -180,18 +180,8 @@ int rt_cond_create(RT_COND *cond, const
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__cond_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(cond->name, sizeof(cond->name),
- (void *)cond);
- pnode = NULL;
- }
-
- err = xnregistry_enter(cond->name, cond, &cond->handle, pnode);
+ err = xnregistry_enter(cond->name, cond, &cond->handle,
+ &__cond_pnode);
if (err)
rt_cond_delete(cond);
Index: b/ksrc/skins/native/event.c
===================================================================
--- a/ksrc/skins/native/event.c
+++ b/ksrc/skins/native/event.c
@@ -204,19 +204,8 @@ int rt_event_create(RT_EVENT *event,
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__event_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(event->name, sizeof(event->name),
- (void *)event);
- pnode = NULL;
- }
-
- err =
- xnregistry_enter(event->name, event, &event->handle, pnode);
+ err = xnregistry_enter(event->name, event, &event->handle,
+ &__event_pnode);
if (err)
rt_event_delete(event);
Index: b/ksrc/skins/native/heap.c
===================================================================
--- a/ksrc/skins/native/heap.c
+++ b/ksrc/skins/native/heap.c
@@ -310,18 +310,8 @@ int rt_heap_create(RT_HEAP *heap, const
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__heap_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(heap->name, sizeof(heap->name),
- (void *)heap);
- pnode = NULL;
- }
-
- err = xnregistry_enter(heap->name, heap, &heap->handle, pnode);
+ err = xnregistry_enter(heap->name, heap, &heap->handle,
+ &__heap_pnode);
if (err)
rt_heap_delete(heap);
Index: b/ksrc/skins/native/intr.c
===================================================================
--- a/ksrc/skins/native/intr.c
+++ b/ksrc/skins/native/intr.c
@@ -284,20 +284,9 @@ int rt_intr_create(RT_INTR *intr,
/* <!> Since xnregister_enter() may reschedule, only register
complete objects, so that the registry cannot return handles to
half-baked objects... */
- if (!err && name) {
- xnpnode_t *pnode = &__intr_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- * from user-space, it gets registered under an unique
- * internal name but is not exported through /proc. */
- xnobject_create_name(intr->name, sizeof(intr->name),
- (void *)intr);
- pnode = NULL;
- }
-
- err = xnregistry_enter(intr->name, intr, &intr->handle, pnode);
- }
+ if (!err && name)
+ err = xnregistry_enter(intr->name, intr, &intr->handle,
+ &__intr_pnode);
#endif /* CONFIG_XENO_OPT_REGISTRY */
Index: b/ksrc/skins/native/mutex.c
===================================================================
--- a/ksrc/skins/native/mutex.c
+++ b/ksrc/skins/native/mutex.c
@@ -191,19 +191,8 @@ int rt_mutex_create(RT_MUTEX *mutex, con
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__mutex_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(mutex->name, sizeof(mutex->name),
- (void *)mutex);
- pnode = NULL;
- }
-
- err =
- xnregistry_enter(mutex->name, mutex, &mutex->handle, pnode);
+ err = xnregistry_enter(mutex->name, mutex, &mutex->handle,
+ &__mutex_pnode);
if (err)
rt_mutex_delete(mutex);
Index: b/ksrc/skins/native/pipe.c
===================================================================
--- a/ksrc/skins/native/pipe.c
+++ b/ksrc/skins/native/pipe.c
@@ -338,18 +338,8 @@ int rt_pipe_create(RT_PIPE *pipe, const
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__pipe_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(pipe->name, sizeof(pipe->name),
- (void *)pipe);
- pnode = NULL;
- }
-
- err = xnregistry_enter(pipe->name, pipe, &pipe->handle, pnode);
+ err = xnregistry_enter(pipe->name, pipe, &pipe->handle,
+ &__pipe_pnode);
if (err)
rt_pipe_delete(pipe);
Index: b/ksrc/skins/native/queue.c
===================================================================
--- a/ksrc/skins/native/queue.c
+++ b/ksrc/skins/native/queue.c
@@ -274,17 +274,7 @@ int rt_queue_create(RT_QUEUE *q,
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__queue_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(q->name, sizeof(q->name), q);
- pnode = NULL;
- }
-
- err = xnregistry_enter(q->name, q, &q->handle, pnode);
+ err = xnregistry_enter(q->name, q, &q->handle, &__queue_pnode);
if (err)
rt_queue_delete(q);
Index: b/ksrc/skins/native/sem.c
===================================================================
--- a/ksrc/skins/native/sem.c
+++ b/ksrc/skins/native/sem.c
@@ -203,18 +203,8 @@ int rt_sem_create(RT_SEM *sem, const cha
half-baked objects... */
if (name) {
- xnpnode_t *pnode = &__sem_pnode;
-
- if (!*name) {
- /* Since this is an anonymous object (empty name on entry)
- from user-space, it gets registered under an unique
- internal name but is not exported through /proc. */
- xnobject_create_name(sem->name, sizeof(sem->name),
- (void *)sem);
- pnode = NULL;
- }
-
- err = xnregistry_enter(sem->name, sem, &sem->handle, pnode);
+ err = xnregistry_enter(sem->name, sem, &sem->handle,
+ &__sem_pnode);
if (err)
rt_sem_delete(sem);
Index: b/ksrc/skins/native/task.c
===================================================================
--- a/ksrc/skins/native/task.c
+++ b/ksrc/skins/native/task.c
@@ -248,15 +248,8 @@ int rt_task_create(RT_TASK *task,
bflags = mode & (XNFPU | XNSHADOW | XNSHIELD | XNSUSP);
- if (name) {
- if (!*name)
- /* i.e. Anonymous object which must be accessible from
- user-space. */
- xnobject_create_name(task->rname, sizeof(task->rname),
- task);
- else
- xnobject_copy_name(task->rname, name);
- }
+ if (name)
+ xnobject_copy_name(task->rname, name);
if (xnpod_init_thread(&task->thread_base, __native_tbase,
name, prio, bflags, stksize, &__xeno_task_ops) != 0)
@@ -304,11 +297,6 @@ int rt_task_create(RT_TASK *task,
NULL);
if (err)
xnpod_delete_thread(&task->thread_base);
- else if (!*name)
- /* /proc/xenomai/sched will dump no name for the anonymous
- task, but the registry still has a stable reference
- into the TCB to set up a handle for the task. */
- xnthread_clear_name(&task->thread_base);
}
#endif /* CONFIG_XENO_OPT_REGISTRY */
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [PATCH 4/6] Eliminate xnobjhash
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
` (2 preceding siblings ...)
2008-08-26 11:53 ` [Xenomai-core] [PATCH 3/6] Native skin: Use " Jan Kiszka
@ 2008-08-26 11:55 ` Jan Kiszka
2008-08-26 11:56 ` [Xenomai-core] [RESEND][PATCH 5/6] Avoid add_proc_leaf duplicates Jan Kiszka
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:55 UTC (permalink / raw)
To: xenomai-core
Hook up xnobject directly to the hash table instead of establishing
dynamically created xnobjhash redirections.
---
include/nucleus/registry.h | 10 +-----
ksrc/nucleus/registry.c | 73 +++++++++++++++++++--------------------------
2 files changed, 33 insertions(+), 50 deletions(-)
Index: b/include/nucleus/registry.h
===================================================================
--- a/include/nucleus/registry.h
+++ b/include/nucleus/registry.h
@@ -55,6 +55,8 @@ typedef struct xnobject {
u_long cstamp; /* !< Creation stamp. */
+ struct xnobject *hnext; /* !< Next in h-table */
+
#ifdef CONFIG_PROC_FS
struct xnpnode *pnode; /* !< /proc information class. */
@@ -65,14 +67,6 @@ typedef struct xnobject {
} xnobject_t;
-typedef struct xnobjhash {
-
- xnobject_t *object;
-
- struct xnobjhash *next; /* !< Next in h-table */
-
-} xnobjhash_t;
-
#ifdef __cplusplus
extern "C" {
#endif
Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -54,7 +54,7 @@ static xnqueue_t registry_obj_busyq; /*
static u_long registry_obj_stamp;
-static xnobjhash_t **registry_hash_table;
+static xnobject_t **registry_hash_table;
static int registry_hash_entries;
@@ -132,8 +132,8 @@ int xnregistry_init(void)
registry_hash_entries =
primes[obj_hash_max(CONFIG_XENO_OPT_REGISTRY_NRSLOTS / 100)];
registry_hash_table =
- (xnobjhash_t **) xnarch_alloc_host_mem(sizeof(xnobjhash_t *) *
- registry_hash_entries);
+ (xnobject_t **) xnarch_alloc_host_mem(sizeof(xnobject_t *) *
+ registry_hash_entries);
if (!registry_hash_table) {
#ifdef CONFIG_XENO_EXPORT_REGISTRY
@@ -153,45 +153,42 @@ int xnregistry_init(void)
void xnregistry_cleanup(void)
{
- xnobjhash_t *ecurr, *enext;
+ xnobject_t *ecurr, *enext;
int n;
+#ifdef CONFIG_XENO_EXPORT_REGISTRY
for (n = 0; n < registry_hash_entries; n++) {
for (ecurr = registry_hash_table[n]; ecurr; ecurr = enext) {
- enext = ecurr->next;
+ enext = ecurr->hnext;
-#ifdef CONFIG_XENO_EXPORT_REGISTRY
- if (ecurr->object && ecurr->object->pnode) {
- remove_proc_entry(ecurr->object->key,
- ecurr->object->pnode->dir);
+ if (ecurr->pnode) {
+ remove_proc_entry(ecurr->key,
+ ecurr->pnode->dir);
- if (--ecurr->object->pnode->entries <= 0) {
- remove_proc_entry(ecurr->object->pnode->
+ if (--ecurr->pnode->entries <= 0) {
+ remove_proc_entry(ecurr->pnode->
type,
- ecurr->object->pnode->
+ ecurr->pnode->
root->dir);
- ecurr->object->pnode->dir = NULL;
+ ecurr->pnode->dir = NULL;
- if (--ecurr->object->pnode->root->
+ if (--ecurr->pnode->root->
entries <= 0) {
remove_proc_entry(ecurr->
- object->
pnode->root->
name,
registry_proc_root);
- ecurr->object->pnode->root->
+ ecurr->pnode->root->
dir = NULL;
}
}
}
-#endif /* CONFIG_XENO_EXPORT_REGISTRY */
-
- xnfree(ecurr);
}
}
+#endif /* CONFIG_XENO_EXPORT_REGISTRY */
xnarch_free_host_mem(registry_hash_table,
- sizeof(xnobjhash_t *) * registry_hash_entries);
+ sizeof(xnobject_t *) * registry_hash_entries);
xnsynch_destroy(®istry_hash_synch);
@@ -448,25 +445,19 @@ static unsigned registry_hash_crunch(con
static inline int registry_hash_enter(const char *key, xnobject_t *object)
{
- xnobjhash_t *enew, *ecurr;
+ xnobject_t *ecurr;
unsigned s;
object->key = key;
s = registry_hash_crunch(key);
- for (ecurr = registry_hash_table[s]; ecurr != NULL; ecurr = ecurr->next) {
- if (ecurr->object == object || !strcmp(key, ecurr->object->key))
+ for (ecurr = registry_hash_table[s]; ecurr != NULL; ecurr = ecurr->hnext) {
+ if (ecurr == object || !strcmp(key, ecurr->key))
return -EEXIST;
}
- enew = (xnobjhash_t *) xnmalloc(sizeof(*enew));
-
- if (!enew)
- return -ENOMEM;
-
- enew->object = object;
- enew->next = registry_hash_table[s];
- registry_hash_table[s] = enew;
+ object->hnext = registry_hash_table[s];
+ registry_hash_table[s] = object;
return 0;
}
@@ -474,17 +465,15 @@ static inline int registry_hash_enter(co
static inline int registry_hash_remove(xnobject_t *object)
{
unsigned s = registry_hash_crunch(object->key);
- xnobjhash_t *ecurr, *eprev;
+ xnobject_t *ecurr, *eprev;
for (ecurr = registry_hash_table[s], eprev = NULL;
- ecurr != NULL; eprev = ecurr, ecurr = ecurr->next) {
- if (ecurr->object == object) {
+ ecurr != NULL; eprev = ecurr, ecurr = ecurr->hnext) {
+ if (ecurr == object) {
if (eprev)
- eprev->next = ecurr->next;
+ eprev->hnext = ecurr->hnext;
else
- registry_hash_table[s] = ecurr->next;
-
- xnfree(ecurr);
+ registry_hash_table[s] = ecurr->hnext;
return 0;
}
@@ -495,12 +484,12 @@ static inline int registry_hash_remove(x
static xnobject_t *registry_hash_find(const char *key)
{
- xnobjhash_t *ecurr;
+ xnobject_t *ecurr;
for (ecurr = registry_hash_table[registry_hash_crunch(key)];
- ecurr != NULL; ecurr = ecurr->next) {
- if (!strcmp(key, ecurr->object->key))
- return ecurr->object;
+ ecurr != NULL; ecurr = ecurr->hnext) {
+ if (!strcmp(key, ecurr->key))
+ return ecurr;
}
return NULL;
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [RESEND][PATCH 5/6] Avoid add_proc_leaf duplicates
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
` (3 preceding siblings ...)
2008-08-26 11:55 ` [Xenomai-core] [PATCH 4/6] Eliminate xnobjhash Jan Kiszka
@ 2008-08-26 11:56 ` Jan Kiszka
2008-08-26 11:58 ` [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc Jan Kiszka
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:56 UTC (permalink / raw)
To: xenomai-core
For unknown (historical?) reasons, there are 3 identical implementations
of add_proc_leaf services in Xenomai right now. This patch switches them
all to the rthal provided version.
---
include/asm-generic/hal.h | 10 +++----
ksrc/arch/generic/hal.c | 18 +++++++-------
ksrc/arch/generic/nmi.c | 6 ++--
ksrc/arch/x86/nmi_32.c | 6 ++--
ksrc/nucleus/module.c | 58 +++++++++++++++-------------------------------
ksrc/nucleus/registry.c | 31 +++---------------------
6 files changed, 44 insertions(+), 85 deletions(-)
Index: b/include/asm-generic/hal.h
===================================================================
--- a/include/asm-generic/hal.h
+++ b/include/asm-generic/hal.h
@@ -459,11 +459,11 @@ void rthal_timer_release(int cpu);
extern struct proc_dir_entry *rthal_proc_root;
-struct proc_dir_entry *__rthal_add_proc_leaf(const char *name,
- read_proc_t rdproc,
- write_proc_t wrproc,
- void *data,
- struct proc_dir_entry *parent);
+struct proc_dir_entry *rthal_add_proc_leaf(const char *name,
+ read_proc_t rdproc,
+ write_proc_t wrproc,
+ void *data,
+ struct proc_dir_entry *parent);
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_IPIPE_TRACE
Index: b/ksrc/arch/generic/hal.c
===================================================================
--- a/ksrc/arch/generic/hal.c
+++ b/ksrc/arch/generic/hal.c
@@ -723,11 +723,11 @@ static int apc_read_proc(char *page,
return len;
}
-struct proc_dir_entry *__rthal_add_proc_leaf(const char *name,
- read_proc_t rdproc,
- write_proc_t wrproc,
- void *data,
- struct proc_dir_entry *parent)
+struct proc_dir_entry *rthal_add_proc_leaf(const char *name,
+ read_proc_t rdproc,
+ write_proc_t wrproc,
+ void *data,
+ struct proc_dir_entry *parent)
{
int mode = wrproc ? 0644 : 0444;
struct proc_dir_entry *entry;
@@ -756,12 +756,12 @@ static int rthal_proc_register(void)
rthal_proc_root->owner = THIS_MODULE;
- __rthal_add_proc_leaf("hal", &hal_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("hal", &hal_read_proc, NULL, NULL, rthal_proc_root);
- __rthal_add_proc_leaf("faults",
- &faults_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("faults",
+ &faults_read_proc, NULL, NULL, rthal_proc_root);
- __rthal_add_proc_leaf("apc", &apc_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("apc", &apc_read_proc, NULL, NULL, rthal_proc_root);
rthal_nmi_proc_register();
Index: b/ksrc/arch/generic/nmi.c
===================================================================
--- a/ksrc/arch/generic/nmi.c
+++ b/ksrc/arch/generic/nmi.c
@@ -108,9 +108,9 @@ static int maxlat_write_proc(struct file
void rthal_nmi_proc_register(void)
{
- __rthal_add_proc_leaf("nmi_maxlat",
- &maxlat_read_proc,
- &maxlat_write_proc, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("nmi_maxlat",
+ &maxlat_read_proc,
+ &maxlat_write_proc, NULL, rthal_proc_root);
}
void rthal_nmi_proc_unregister(void)
Index: b/ksrc/arch/x86/nmi_32.c
===================================================================
--- a/ksrc/arch/x86/nmi_32.c
+++ b/ksrc/arch/x86/nmi_32.c
@@ -232,9 +232,9 @@ int rthal_nmi_request(void (*emergency)
nmi_watchdog_tick = &rthal_nmi_watchdog_tick;
#ifdef CONFIG_PROC_FS
- __rthal_add_proc_leaf("nmi_early_shots",
- &earlyshots_read_proc,
- NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("nmi_early_shots",
+ &earlyshots_read_proc,
+ NULL, NULL, rthal_proc_root);
#endif /* CONFIG_PROC_FS */
return 0;
Index: b/ksrc/nucleus/module.c
===================================================================
--- a/ksrc/nucleus/module.c
+++ b/ksrc/nucleus/module.c
@@ -987,29 +987,6 @@ static int affinity_write_proc(struct fi
return count;
}
-static struct proc_dir_entry *add_proc_leaf(const char *name,
- read_proc_t rdproc,
- write_proc_t wrproc,
- void *data,
- struct proc_dir_entry *parent)
-{
- int mode = wrproc ? 0644 : 0444;
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry(name, mode, parent);
-
- if (!entry)
- return NULL;
-
- entry->nlink = 1;
- entry->data = data;
- entry->read_proc = rdproc;
- entry->write_proc = wrproc;
- entry->owner = THIS_MODULE;
-
- return entry;
-}
-
static struct proc_dir_entry *add_proc_fops(const char *name,
struct file_operations *fops,
size_t size,
@@ -1046,26 +1023,31 @@ void xnpod_init_proc(void)
#endif /* CONFIG_XENO_OPT_STATS */
#if defined(CONFIG_SMP) && XENO_DEBUG(NUCLEUS)
- add_proc_leaf("lock", &lock_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("lock", &lock_read_proc, NULL, NULL,
+ rthal_proc_root);
#endif /* CONFIG_SMP && XENO_DEBUG(NUCLEUS) */
- add_proc_leaf("latency",
- &latency_read_proc,
- &latency_write_proc, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("latency",
+ &latency_read_proc,
+ &latency_write_proc, NULL, rthal_proc_root);
- add_proc_leaf("version", &version_read_proc, NULL, NULL,
- rthal_proc_root);
+ rthal_add_proc_leaf("version", &version_read_proc, NULL, NULL,
+ rthal_proc_root);
- add_proc_leaf("timer", &timer_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("timer", &timer_read_proc, NULL, NULL,
+ rthal_proc_root);
- add_proc_leaf("timebases", &timebase_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("timebases", &timebase_read_proc, NULL, NULL,
+ rthal_proc_root);
- add_proc_leaf("irq", &irq_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("irq", &irq_read_proc, NULL, NULL,
+ rthal_proc_root);
- add_proc_leaf("heap", &heap_read_proc, NULL, NULL, rthal_proc_root);
+ rthal_add_proc_leaf("heap", &heap_read_proc, NULL, NULL,
+ rthal_proc_root);
- add_proc_leaf("affinity", &affinity_read_proc, &affinity_write_proc,
- NULL, rthal_proc_root);
+ rthal_add_proc_leaf("affinity", &affinity_read_proc,
+ &affinity_write_proc, NULL, rthal_proc_root);
#ifdef CONFIG_XENO_OPT_PERVASIVE
iface_proc_root =
@@ -1129,9 +1111,9 @@ static int iface_read_proc(char *page,
void xnpod_declare_iface_proc(struct xnskin_slot *iface)
{
- add_proc_leaf(iface->props->name,
- &iface_read_proc, NULL, iface,
- iface_proc_root);
+ rthal_add_proc_leaf(iface->props->name,
+ &iface_read_proc, NULL, iface,
+ iface_proc_root);
}
void xnpod_discard_iface_proc(const char *iface_name)
Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -225,29 +225,6 @@ static inline xnobject_t *registry_valid
like are hopefully properly handled due to a careful
synchronization of operations across domains. */
-static struct proc_dir_entry *add_proc_leaf(const char *name,
- read_proc_t rdproc,
- write_proc_t wrproc,
- void *data,
- struct proc_dir_entry *parent)
-{
- int mode = wrproc ? 0644 : 0444;
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry(name, mode, parent);
-
- if (!entry)
- return NULL;
-
- entry->nlink = 1;
- entry->data = data;
- entry->read_proc = rdproc;
- entry->write_proc = wrproc;
- entry->owner = THIS_MODULE;
-
- return entry;
-}
-
static struct proc_dir_entry *add_proc_link(const char *name,
link_proc_t *link_proc,
void *data,
@@ -332,10 +309,10 @@ static DECLARE_WORK_FUNC(registry_proc_c
object->objaddr, dir);
else
/* Entry allows to get/set object properties. */
- object->proc = add_proc_leaf(object->key,
- pnode->read_proc,
- pnode->write_proc,
- object->objaddr, dir);
+ object->proc = rthal_add_proc_leaf(object->key,
+ pnode->read_proc,
+ pnode->write_proc,
+ object->objaddr, dir);
fail:
xnlock_get_irqsave(&nklock, s);
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
` (4 preceding siblings ...)
2008-08-26 11:56 ` [Xenomai-core] [RESEND][PATCH 5/6] Avoid add_proc_leaf duplicates Jan Kiszka
@ 2008-08-26 11:58 ` Jan Kiszka
2008-08-26 16:08 ` Philippe Gerum
2008-08-26 13:40 ` [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Gilles Chanteperdrix
2008-08-27 9:35 ` Philippe Gerum
7 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 11:58 UTC (permalink / raw)
To: xenomai-core
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
slots=512:used=1:exported=0
to address this deficit.
---
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(®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[] = {
@@ -117,6 +148,11 @@ int xnregistry_init(void)
initq(®istry_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(®istry_obj_freeq);
initq(®istry_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);
@@ -269,6 +308,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 +366,7 @@ static DECLARE_WORK_FUNC(registry_proc_c
continue;
unexport:
+ registry_exported_objects--;
entries = --pnode->entries;
entry = object->proc;
object->proc = NULL;
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements
@ 2008-08-26 12:08 Jan Kiszka
2008-08-26 11:49 ` [Xenomai-core] [PATCH 1/6] Remove / shorten critical sections in registry code Jan Kiszka
` (7 more replies)
0 siblings, 8 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 12:08 UTC (permalink / raw)
To: xenomai-core
Here comes the complete series of patches to improve the Xenomai
registry. #1, #5, and #6 are resends of already posted patches, the
middle part is fresh from the editor. The series reduces overhead
and simplifies the registry code. Overall diffstat:
include/asm-generic/hal.h | 10 +-
include/nucleus/registry.h | 10 --
ksrc/arch/generic/hal.c | 18 +--
ksrc/arch/generic/nmi.c | 6 -
ksrc/arch/x86/nmi_32.c | 6 -
ksrc/nucleus/module.c | 58 ++++-------
ksrc/nucleus/registry.c | 223 ++++++++++++++++++++++-----------------------
ksrc/skins/native/alarm.c | 22 +---
ksrc/skins/native/buffer.c | 15 ---
ksrc/skins/native/cond.c | 14 --
ksrc/skins/native/event.c | 15 ---
ksrc/skins/native/heap.c | 14 --
ksrc/skins/native/intr.c | 17 ---
ksrc/skins/native/mutex.c | 15 ---
ksrc/skins/native/pipe.c | 14 --
ksrc/skins/native/queue.c | 12 --
ksrc/skins/native/sem.c | 14 --
ksrc/skins/native/task.c | 16 ---
18 files changed, 182 insertions(+), 317 deletions(-)
So a net gain of more than 130 LOC.
The series passed basic tests on my virtual target.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
` (5 preceding siblings ...)
2008-08-26 11:58 ` [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc Jan Kiszka
@ 2008-08-26 13:40 ` Gilles Chanteperdrix
2008-08-26 16:03 ` Philippe Gerum
2008-08-27 9:35 ` Philippe Gerum
7 siblings, 1 reply; 14+ messages in thread
From: Gilles Chanteperdrix @ 2008-08-26 13:40 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Jan Kiszka wrote:
> Here comes the complete series of patches to improve the Xenomai
> registry. #1, #5, and #6 are resends of already posted patches, the
> middle part is fresh from the editor. The series reduces overhead
> and simplifies the registry code. Overall diffstat:
>
> include/asm-generic/hal.h | 10 +-
> include/nucleus/registry.h | 10 --
> ksrc/arch/generic/hal.c | 18 +--
> ksrc/arch/generic/nmi.c | 6 -
> ksrc/arch/x86/nmi_32.c | 6 -
> ksrc/nucleus/module.c | 58 ++++-------
> ksrc/nucleus/registry.c | 223 ++++++++++++++++++++++-----------------------
> ksrc/skins/native/alarm.c | 22 +---
> ksrc/skins/native/buffer.c | 15 ---
> ksrc/skins/native/cond.c | 14 --
> ksrc/skins/native/event.c | 15 ---
> ksrc/skins/native/heap.c | 14 --
> ksrc/skins/native/intr.c | 17 ---
> ksrc/skins/native/mutex.c | 15 ---
> ksrc/skins/native/pipe.c | 14 --
> ksrc/skins/native/queue.c | 12 --
> ksrc/skins/native/sem.c | 14 --
> ksrc/skins/native/task.c | 16 ---
> 18 files changed, 182 insertions(+), 317 deletions(-)
>
> So a net gain of more than 130 LOC.
>
> The series passed basic tests on my virtual target.
Ok. Now that we have discussed the potential xnsynch issue, the patches
are Ok for me.
--
Gilles.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements
2008-08-26 13:40 ` [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Gilles Chanteperdrix
@ 2008-08-26 16:03 ` Philippe Gerum
0 siblings, 0 replies; 14+ messages in thread
From: Philippe Gerum @ 2008-08-26 16:03 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: Jan Kiszka, xenomai-core
Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> Here comes the complete series of patches to improve the Xenomai
>> registry. #1, #5, and #6 are resends of already posted patches, the
>> middle part is fresh from the editor. The series reduces overhead
>> and simplifies the registry code. Overall diffstat:
>>
>> include/asm-generic/hal.h | 10 +-
>> include/nucleus/registry.h | 10 --
>> ksrc/arch/generic/hal.c | 18 +--
>> ksrc/arch/generic/nmi.c | 6 -
>> ksrc/arch/x86/nmi_32.c | 6 -
>> ksrc/nucleus/module.c | 58 ++++-------
>> ksrc/nucleus/registry.c | 223 ++++++++++++++++++++++-----------------------
>> ksrc/skins/native/alarm.c | 22 +---
>> ksrc/skins/native/buffer.c | 15 ---
>> ksrc/skins/native/cond.c | 14 --
>> ksrc/skins/native/event.c | 15 ---
>> ksrc/skins/native/heap.c | 14 --
>> ksrc/skins/native/intr.c | 17 ---
>> ksrc/skins/native/mutex.c | 15 ---
>> ksrc/skins/native/pipe.c | 14 --
>> ksrc/skins/native/queue.c | 12 --
>> ksrc/skins/native/sem.c | 14 --
>> ksrc/skins/native/task.c | 16 ---
>> 18 files changed, 182 insertions(+), 317 deletions(-)
>>
>> So a net gain of more than 130 LOC.
>>
>> The series passed basic tests on my virtual target.
>
> Ok. Now that we have discussed the potential xnsynch issue, the patches
> are Ok for me.
>
Ok, I'll merge then.
--
Philippe.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
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
0 siblings, 1 reply; 14+ messages in thread
From: Philippe Gerum @ 2008-08-26 16:08 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
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.
> slots=512:used=1:exported=0
>
> to address this deficit.
>
> ---
> 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(®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[] = {
> @@ -117,6 +148,11 @@ int xnregistry_init(void)
> initq(®istry_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(®istry_obj_freeq);
> initq(®istry_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);
> @@ -269,6 +308,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 +366,7 @@ static DECLARE_WORK_FUNC(registry_proc_c
> continue;
>
> unexport:
> + registry_exported_objects--;
> entries = --pnode->entries;
> entry = object->proc;
> object->proc = NULL;
>
>
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core
>
--
Philippe.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
2008-08-26 16:08 ` Philippe Gerum
@ 2008-08-26 16:19 ` Jan Kiszka
2008-08-26 16:22 ` Philippe Gerum
0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 16:19 UTC (permalink / raw)
To: rpm; +Cc: xenomai-core
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... :-]
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
2008-08-26 16:19 ` Jan Kiszka
@ 2008-08-26 16:22 ` Philippe Gerum
2008-08-26 17:08 ` Jan Kiszka
0 siblings, 1 reply; 14+ messages in thread
From: Philippe Gerum @ 2008-08-26 16:22 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
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.
--
Philippe.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
2008-08-26 16:22 ` Philippe Gerum
@ 2008-08-26 17:08 ` Jan Kiszka
0 siblings, 0 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-08-26 17:08 UTC (permalink / raw)
To: rpm; +Cc: xenomai-core
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;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
` (6 preceding siblings ...)
2008-08-26 13:40 ` [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Gilles Chanteperdrix
@ 2008-08-27 9:35 ` Philippe Gerum
7 siblings, 0 replies; 14+ messages in thread
From: Philippe Gerum @ 2008-08-27 9:35 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Jan Kiszka wrote:
> Here comes the complete series of patches to improve the Xenomai
> registry. #1, #5, and #6 are resends of already posted patches, the
> middle part is fresh from the editor. The series reduces overhead
> and simplifies the registry code. Overall diffstat:
>
Merged, thanks.
> include/asm-generic/hal.h | 10 +-
> include/nucleus/registry.h | 10 --
> ksrc/arch/generic/hal.c | 18 +--
> ksrc/arch/generic/nmi.c | 6 -
> ksrc/arch/x86/nmi_32.c | 6 -
> ksrc/nucleus/module.c | 58 ++++-------
> ksrc/nucleus/registry.c | 223 ++++++++++++++++++++++-----------------------
> ksrc/skins/native/alarm.c | 22 +---
> ksrc/skins/native/buffer.c | 15 ---
> ksrc/skins/native/cond.c | 14 --
> ksrc/skins/native/event.c | 15 ---
> ksrc/skins/native/heap.c | 14 --
> ksrc/skins/native/intr.c | 17 ---
> ksrc/skins/native/mutex.c | 15 ---
> ksrc/skins/native/pipe.c | 14 --
> ksrc/skins/native/queue.c | 12 --
> ksrc/skins/native/sem.c | 14 --
> ksrc/skins/native/task.c | 16 ---
> 18 files changed, 182 insertions(+), 317 deletions(-)
>
> So a net gain of more than 130 LOC.
>
> The series passed basic tests on my virtual target.
>
> Jan
>
--
Philippe.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-08-27 9:35 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.