Registry-related cleanups and improvements
cover Registry-related cleanups and improvements
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
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
PATCH 1/6 Remove / shorten critical sections in registry code
See Changelog.
--- ChangeLog | 6 ++++++ ksrc/nucleus/registry.c | 44 +++++++++++++------------------------------- 2 files changed, 19 insertions(+), 31 deletions(-)
ChangeLog +6 -0
@@ -1,3 +1,9 @@ +2008-08-26 Jan Kiszka <[email protected]> + + * ksrc/nucleus/registry.c (xnregistry_fetch/get/put): Remove + pointless locking, move XNOBJECT_SELF lookups out of critical + sections. + 2008-08-25 Jan Kiszka <[email protected]> * include/asm-generic/wrappers.h: Provide atomic_long wrappings.
ksrc/nucleus/registry.c +13 -31
82 lines not on this page · raw message
PATCH 2/6 Allow key-less registry entries
In reply to Jan KiszkaNo 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(-)
ksrc/nucleus/registry.c +22 -12
@@ -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);
ChangeLog +3 -0
@@ -1,5 +1,8 @@ 2008-08-26 Jan Kiszka <[email protected]> + * 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.
PATCH 3/6 Native skin: Use key-less registry entries
In reply to Jan KiszkaMake 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(-)
ksrc/skins/native/alarm.c +9 -13
@@ -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);
ksrc/skins/native/buffer.c +2 -13
@@ -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); }
ksrc/skins/native/cond.c +2 -12
@@ -180,18 +180,8 @@ int rt_cond_create(RT_COND *cond, consthalf-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);
ksrc/skins/native/event.c +2 -13
@@ -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);
ksrc/skins/native/heap.c +2 -12
@@ -310,18 +310,8 @@ int rt_heap_create(RT_HEAP *heap, consthalf-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);
ksrc/skins/native/intr.c +3 -14
@@ -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 */
ksrc/skins/native/mutex.c +2 -13
@@ -191,19 +191,8 @@ int rt_mutex_create(RT_MUTEX *mutex, conhalf-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);
ksrc/skins/native/pipe.c +2 -12
@@ -338,18 +338,8 @@ int rt_pipe_create(RT_PIPE *pipe, consthalf-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);
ksrc/skins/native/queue.c +1 -11
@@ -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);
ksrc/skins/native/sem.c +2 -12
@@ -203,18 +203,8 @@ int rt_sem_create(RT_SEM *sem, const chahalf-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);
ksrc/skins/native/task.c +2 -14
@@ -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 */
PATCH 4/6 Eliminate xnobjhash
In reply to Jan KiszkaHook 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(-)
include/nucleus/registry.h +2 -8
@@ -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 __cplusplusextern "C" {#endif
ksrc/nucleus/registry.c +31 -42
145 lines not on this page · raw message
PATCH RESEND 5/6 Avoid add_proc_leaf duplicates
In reply to Jan KiszkaFor 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(-)
include/asm-generic/hal.h +5 -5
@@ -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
ksrc/arch/generic/hal.c +9 -9
@@ -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 ();
ksrc/arch/generic/nmi.c +3 -3
@@ -108,9 +108,9 @@ static int maxlat_write_proc(struct filevoid 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 )
ksrc/arch/x86/nmi_32.c +3 -3
@@ -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 ;
ksrc/nucleus/module.c +20 -38
84 lines not on this page · raw message
ksrc/nucleus/registry.c +4 -27
@@ -225,29 +225,6 @@ static inline xnobject_t *registry_validlike 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);
PATCH RESEND 6/6 Report registry slot usage via /proc
In reply to Jan KiszkaSome 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(+)
ksrc/nucleus/registry.c +41 -0
@@ -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_cif (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_ccontinue ; unexport: + registry_exported_objects--; entries = --pnode->entries; entry = object->proc; object->proc =NULL ;
Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
Quoted 7 lines · Jan Kiszka
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_usagein the form
Eeek. /proc/xenomai/registry/status or /usage. Otherwise, ok.
Quoted 102 lines
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
===================================================================ksrc/nucleus/registry.c +41
-0@@ -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_cif (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_ccontinue ; unexport: + registry_exported_objects--; entries = --pnode->entries; entry = object->proc; object->proc =NULL ;_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
Philippe.
Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
Quoted 10 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka
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_usagein the formEeek.
/proc/xenomai/registry/statusor /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
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Jan Kiszka
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).
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
This patch introduces
/proc/xenomai/registry_usagein the formEeek.
/proc/xenomai/registry/statusor /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.
Signature · 1 line
Philippe.
Re: [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc
Quoted 8 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Jan Kiszka
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).
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
This patch introduces
/proc/xenomai/registry_usagein the formEeek.
/proc/xenomai/registry/statusor /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(-)
ksrc/nucleus/registry.c +57 -11
@@ -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_cif (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_ccontinue ; unexport: + registry_exported_objects--; entries = --pnode->entries; entry = object->proc; object->proc =NULL ;
Quoted 25 lines · Jan Kiszka
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(-)
Quoted 3 lines
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.
Signature · 1 line
Gilles.
Quoted 26 lines · Gilles Chanteperdrix
Quoted 25 lines · Jan Kiszka
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(-)
Quoted 7 lines
Quoted 3 lines
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.
Signature · 1 line
Philippe.
Philippe Gerum
AppliedQuoted 5 lines · Jan Kiszka
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.
Quoted 26 lines
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
Signature · 1 line
Philippe.