[Xenomai-git] Philippe Gerum : boilerplate/shavl: remove private memory references from shared data
Module: xenomai-3 Branch: next Commit: 7e3d69ae6c9235289a8984b609ae2400ab950f17 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7e3d69ae6c9235289a8984b609ae2400ab950f17 Author: Philippe Gerum Date: Thu Jun 14 17:15:04 2018 +0200 boilerplate/shavl: remove private memory references from shared data The node search and comparison function addresses are process-local in essence, do not share them. Since some changes in this recent API were required, the few existing users were converted to use the new API in the process. --- include/boilerplate/avl-inner.h | 83 ++--- lib/boilerplate/avl.c | 60 +++ lib/boilerplate/heapmem.c | 40 +- lib/copperplate/heapobj-pshared.c | 40 +- 4 files changed, 142 insertions(+), 81 deletions(-) diff --git a/include/boilerplate/avl-inner.h b/include/boilerplate/avl-inner.h index ced7715..10c9114 100644 --- a/include/boilerplate/avl-inner.h +++ b/include/boilerplate/avl-inner.h @@ -72,10 +72,13 @@ __AVL_T(avl_search_t)(const struct __AVL_T(avl) *, typedef int __AVL_T(avlh_prn_t)(char *, size_t, const struct __AVL_T(avlh) *const); -struct __AVL_T(avl) { - struct __AVL_T(avlh) anchor; +struct __AVL_T(avl_searchops) { __AVL_T(avl_search_t) *search; __AVL_T(avlh_cmp_t) *cmp; +}; + +struct __AVL_T(avl) { + struct __AVL_T(avlh) anchor; union { ptrdiff_t offset; struct __AVL_T(avlh) *ptr; @@ -123,8 +126,6 @@ shavl_set_end(struct shavl *const avl, int dir, struct shavlh *holder) avl->end[avl_type2index(dir)].offset = (void *)holder - (void *)avl; } -#define shavl_searchfn(avl)((avl)->search) -#define shavl_cmp(avl) ((avl)->cmp) #define shavl_count(avl) ((avl)->count) #define shavl_height(avl) ((avl)->height) #define shavl_anchor(avl) (&(avl)->anchor) @@ -202,8 +203,6 @@ avl_set_end(struct avl *const avl, int dir, struct avlh *holder) avl_end(avl, dir) = holder; } -#define avl_searchfn(avl) ((avl)->search) -#define avl_cmp(avl) ((avl)->cmp) #define avl_count(avl) ((avl)->count) #define avl_height(avl) ((avl)->height) #define avl_anchor(avl) (&(avl)->anchor) @@ -280,9 +279,10 @@ avl_set_end(struct avl *const avl, int dir, struct avlh *holder) static inline struct __AVL_T(avlh) * __AVL(search_inner)(const struct __AVL_T(avl) *const avl, - const struct __AVL_T(avlh) *n, int *delta) + const struct __AVL_T(avlh) *n, int *delta, + const struct __AVL_T(avl_searchops) *ops) { - return __AVL(searchfn)(avl)(avl, n, delta, 0); + return ops->search(avl, n, delta, 0); } static inline @@ -371,12 +371,13 @@ static inline void __AVLH(init)(struct __AVL_T(avlh) *const holder) static inline struct __AVL_T(avlh) * __AVL(search)(const struct __AVL_T(avl) *const avl, - const struct __AVL_T(avlh) *node) + const struct __AVL_T(avlh) *node, + const struct __AVL_T(avl_searchops) *ops) { struct __AVL_T(avlh) *holder; int delta; - holder = __AVL(search_inner)(avl, node, ); + holder = __AVL(search_inner)(avl, node, , ops); if (!delta) return holder; @@ -385,12 +386,13 @@ __AVL(search)(const struct __AVL_T(avl) *const avl, static inline struct __AVL_T(avlh) * __AVL(search_nearest)(const struct __AVL_T(avl) *const avl, - const struct __AVL_T(avlh) *node, int dir) + const struct __AVL_T(avlh) *node, int dir, + const struct __AVL_T(avl_searchops) *ops) { struct __AVL_T(avlh) *holder; int delta; - holder = __AVL(search_inner)(avl, node, ); + holder = __AVL(search_inner)(avl, node, , ops); if (!holder || delta != dir) return holder; @@ -399,26 +401,29 @@ __AVL(search_nearest)(const struct __AVL_T(avl) *const avl, static inline struct __AVL_T(avlh) * __AVL(search_le)(const struct __AVL_T(avl) *const avl, -const struct __AVL_T(avlh) *node) +const struct __AVL_T(avlh) *node, +const struct __AVL_T(avl_searchops) *ops) { - return __AVL(search_nearest)(avl, node, AVL_LEFT); + return __AVL(search_nearest)(avl, node, AVL_LEFT, ops); } static inline struct __AVL_T(avlh) * __AVL(search_ge)(const struct __AVL_T(avl) *const avl, -const struct __AVL_T(avlh) *node) +const struct __AVL_T(avlh) *node, +const struct __AVL_T(avl_searchops) *ops) { - return __AVL(search_nearest)(avl, node, AVL_RIGHT); + return __AVL(search_nearest)(avl, node, AVL_RIGHT, ops); } static inline struct __AVL_T(avlh) * __AVL(search_multi)(const struct __AVL_T(avl) *const avl, - const struct
[Xenomai-git] Philippe Gerum : include/copperplate: heapobj: make heapmem section C++-friendly
Module: xenomai-3 Branch: next Commit: 5c48d328880b13e8ad3c59f71f97a53eccd398f4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5c48d328880b13e8ad3c59f71f97a53eccd398f4 Author: Philippe Gerum Date: Wed Jun 13 08:50:54 2018 +0200 include/copperplate: heapobj: make heapmem section C++-friendly --- include/copperplate/heapobj.h | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index c8a7773..ade7e75 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -148,38 +148,39 @@ extern struct heap_memory heapmem_main; static inline void pvheapobj_destroy(struct heapobj *hobj) { - heapmem_destroy(hobj->pool); + heapmem_destroy((struct heap_memory *)hobj->pool); } static inline int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) { - return heapmem_extend(hobj->pool, mem, size); + return heapmem_extend((struct heap_memory *)hobj->pool, + mem, size); } static inline void *pvheapobj_alloc(struct heapobj *hobj, size_t size) { - return heapmem_alloc(hobj->pool, size); + return heapmem_alloc((struct heap_memory *)hobj->pool, size); } static inline void pvheapobj_free(struct heapobj *hobj, void *ptr) { - heapmem_free(hobj->pool, ptr); + heapmem_free((struct heap_memory *)hobj->pool, ptr); } static inline size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) { - ssize_t size = heapmem_check(hobj->pool, ptr); + ssize_t size = heapmem_check((struct heap_memory *)hobj->pool, ptr); return size < 0 ? 0 : size; } static inline size_t pvheapobj_inquire(struct heapobj *hobj) { - return heapmem_used_size(hobj->pool); + return heapmem_used_size((struct heap_memory *)hobj->pool); } static inline void *pvmalloc(size_t size) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/regd: convert to shared heapmem
Module: xenomai-3 Branch: next Commit: 833dfc8defb8f2b855b4cd13d62c016cb9e584e0 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=833dfc8defb8f2b855b4cd13d62c016cb9e584e0 Author: Philippe Gerum Date: Tue Jun 12 08:40:43 2018 +0200 copperplate/regd: convert to shared heapmem --- lib/copperplate/regd/fs-common.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/copperplate/regd/fs-common.c b/lib/copperplate/regd/fs-common.c index ef2e6da..e0bdd3d 100644 --- a/lib/copperplate/regd/fs-common.c +++ b/lib/copperplate/regd/fs-common.c @@ -211,8 +211,8 @@ int open_heaps(struct fsobj *fsobj, void *priv) { struct sysgroup_memspec *obj, *tmp; struct heap_data *heap_data, *p; + struct shared_heap_memory *heap; struct fsobstack *o = priv; - struct shared_heap *heap; int ret, count, len = 0; ret = heapobj_bind_session(__copperplate_setup_data.session_label); @@ -244,10 +244,10 @@ int open_heaps(struct fsobj *fsobj, void *priv) for_each_sysgroup(obj, tmp, heap) { if (p - heap_data >= count) break; - heap = container_of(obj, struct shared_heap, memspec); + heap = container_of(obj, struct shared_heap_memory, memspec); namecpy(p->name, heap->name); - p->used = heap->ubytes; - p->total = heap->total; + p->used = heap->used_size; + p->total = heap->usable_size; p++; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=03e00e09bf36fdb24483512de949919e30022ade Author: Philippe Gerum Date: Fri Jun 8 12:52:23 2018 +0200 testsuite/xeno-test: reduce rounds of memory allocation checks The tests exercizing the memory allocator may run for several minutes each depending on the platform, in order to obtain reliable performance figures. Reduce this amount of runtime for a basic functional validation of those allocators. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5c53acb2a36602bcc8b6985507cd1d96b0a284f3 Author: Philippe Gerum Date: Thu May 17 19:42:17 2018 +0200 copperplate/heapobj-pshared: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the shared memory allocator, using a variant of the McKusick scheme significantly improving the performance figures, especially regarding memory release operations. As a by-product of this overhaul, the shared memory allocator can now manage heaps up to (4GB - PAGE_SIZE). [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=db05d86624398802892659077bc4d7dacf1f538c Author: Philippe Gerum Date: Thu May 17 20:11:56 2018 +0200 boilerplate/avl: dissociate private/shared mode implementations So that we may have both coexisting in a single executable. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=32eb1bee4f3e859e813b44b50bd13744e61b326a Author: Philippe Gerum Date: Mon May 21 12:54:59 2018 +0200 scripts/prepare-kernel.sh: drop left overs from obsolete ports URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8d4139294c308f590b9081a1f5b93f872af08c34 Author: Philippe Gerum Date: Mon May 21 12:42:46 2018 +0200 powerpc64: drop architecture support The powerpc64 architecture does not seem to have any active Xenomai user, at least none who may be concerned enough to be willing to help in maintaining this Xenomai port. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a809bbd2592ef76b20eff32cde91c776fd7622f5 Author: Philippe Gerum Date: Mon May 21 12:42:46 2018 +0200 blackfin: drop architecture support The blackfin architecture is not supported by the mainline kernel anymore since 4.17, and no concerned user showed up, willing to help in maintaining this Xenomai port. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eb391d39b29cfa3e960f577868df60da78d8a30f Author: Philippe Gerum Date: Sat May 19 11:18:53 2018 +0200 testsuite/smokey: add core heap test URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=aa22cefb313f0047e13366250a4f40b59246c744 Author: Philippe Gerum Date: Sun May 13 19:00:50 2018 +0200 drivers/testing: add core heap test module URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6d20c7025dba012557a3999677b492c4b29a531f Author: Philippe Gerum Date: Sat May 19 12:01:49 2018 +0200 lib/smokey: enable test filtering with --list[=expr] URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ddc616e26ac10fb7a67dd4cc71f40d41a65c8e57 Author: Philippe Gerum Date: Sat May 19 15:04:06 2018 +0200 cobalt/heap: add accessor to usage counter URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=36f3dd16593c9a2a06bfb34d64c285865d192b06 Author: Philippe Gerum Date: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ...
[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Fix sem_open for preexisting semaphores
Module: xenomai-jki Branch: for-forge Commit: 1d7bccbc6aaa4454c98ecf11694e2cc2d7d150e2 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=1d7bccbc6aaa4454c98ecf11694e2cc2d7d150e2 Author: Jan KiszkaDate: Thu May 24 19:34:26 2018 +0200 cobalt/posix/sem: Fix sem_open for preexisting semaphores We missed to create and copy the shadow into userspace in case a preexisting semaphore was opened in process that didn't created it. Was biting us in pshared setups, but also when the previous owner died before destroying a named semaphore. Reported-by: Paal Tamas Signed-off-by: Jan Kiszka --- kernel/cobalt/posix/nsem.c | 11 +++ kernel/cobalt/posix/sem.c | 23 ++- kernel/cobalt/posix/sem.h |3 +++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c index bf2157d..89cf62b 100644 --- a/kernel/cobalt/posix/nsem.c +++ b/kernel/cobalt/posix/nsem.c @@ -95,6 +95,8 @@ sem_open(struct cobalt_process *process, xnlock_put_irqrestore(, s); goto retry_bind; } + + __cobalt_sem_shadow_init(sem, COBALT_NAMED_SEM_MAGIC, ); break; case -EWOULDBLOCK: @@ -112,10 +114,6 @@ sem_open(struct cobalt_process *process, return ERR_PTR(rc); } - if (cobalt_copy_to_user(ushadow, , sizeof(shadow))) { - __cobalt_sem_destroy(shadow.handle); - return ERR_PTR(-EFAULT); - } sem->pathname = filename; handle = shadow.handle; break; @@ -124,6 +122,11 @@ sem_open(struct cobalt_process *process, return ERR_PTR(rc); } + if (cobalt_copy_to_user(ushadow, , sizeof(shadow))) { + __cobalt_sem_destroy(handle); + return ERR_PTR(-EFAULT); + } + u = xnmalloc(sizeof(*u)); if (u == NULL) { __cobalt_sem_destroy(handle); diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c index dc7ff0d..ab075bb 100644 --- a/kernel/cobalt/posix/sem.c +++ b/kernel/cobalt/posix/sem.c @@ -153,13 +153,11 @@ __cobalt_sem_init(const char *name, struct cobalt_sem_shadow *sm, sem->refs = name ? 2 : 1; sem->pathname = NULL; - sm->magic = name ? COBALT_NAMED_SEM_MAGIC : COBALT_SEM_MAGIC; - sm->handle = sem->resnode.handle; - sm->state_offset = cobalt_umm_offset(_ppd->umm, state); - if (flags & SEM_PSHARED) - sm->state_offset = -sm->state_offset; xnlock_put_irqrestore(, s); + __cobalt_sem_shadow_init(sem, + name ? COBALT_NAMED_SEM_MAGIC : COBALT_SEM_MAGIC, sm); + trace_cobalt_psem_init(name ?: "anon", sem->resnode.handle, flags, value); @@ -176,6 +174,21 @@ out: return ERR_PTR(ret); } +void __cobalt_sem_shadow_init(struct cobalt_sem *sem, __u32 magic, + struct cobalt_sem_shadow *sm) +{ + __u32 flags = sem->state->flags; + struct cobalt_ppd *sys_ppd; + + sys_ppd = cobalt_ppd_get(!!(flags & SEM_PSHARED)); + + sm->magic = magic; + sm->handle = sem->resnode.handle; + sm->state_offset = cobalt_umm_offset(_ppd->umm, sem->state); + if (sem->state->flags & SEM_PSHARED) + sm->state_offset = -sm->state_offset; +} + static int sem_destroy(struct cobalt_sem_shadow *sm) { struct cobalt_sem *sem; diff --git a/kernel/cobalt/posix/sem.h b/kernel/cobalt/posix/sem.h index a95b6c4..1723807 100644 --- a/kernel/cobalt/posix/sem.h +++ b/kernel/cobalt/posix/sem.h @@ -76,6 +76,9 @@ struct cobalt_sem * __cobalt_sem_init(const char *name, struct cobalt_sem_shadow *sem, int flags, unsigned value); +void __cobalt_sem_shadow_init(struct cobalt_sem *sem, __u32 magic, + struct cobalt_sem_shadow *sm); + COBALT_SYSCALL_DECL(sem_init, (struct cobalt_sem_shadow __user *u_sem, int flags, unsigned value)); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Fix semaphore leak on failing xnmalloc
Module: xenomai-jki Branch: for-forge Commit: 3426c8aa475b8c006b7a38f685a98e3dd40cc98c URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=3426c8aa475b8c006b7a38f685a98e3dd40cc98c Author: Jan KiszkaDate: Thu May 24 19:32:10 2018 +0200 cobalt/posix/sem: Fix semaphore leak on failing xnmalloc Properly destroy the semaphore in case we cannot allocate a cobalt_named_sem struct. Signed-off-by: Jan Kiszka --- kernel/cobalt/posix/nsem.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c index 0cc6860..bf2157d 100644 --- a/kernel/cobalt/posix/nsem.c +++ b/kernel/cobalt/posix/nsem.c @@ -125,8 +125,10 @@ sem_open(struct cobalt_process *process, } u = xnmalloc(sizeof(*u)); - if (u == NULL) + if (u == NULL) { + __cobalt_sem_destroy(handle); return ERR_PTR(-ENOMEM); + } u->sem = sem; u->usem = ushadow; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : scripts/prepare-kernel.sh: drop left overs from obsolete ports
Module: xenomai-3 Branch: next Commit: ffb68112e2342a62a1f70916a35a3d68e875b12c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ffb68112e2342a62a1f70916a35a3d68e875b12c Author: Philippe GerumDate: Mon May 21 12:54:59 2018 +0200 scripts/prepare-kernel.sh: drop left overs from obsolete ports --- scripts/prepare-kernel.sh |6 -- 1 file changed, 6 deletions(-) diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh index 5e6e3b1..123b7b4 100755 --- a/scripts/prepare-kernel.sh +++ b/scripts/prepare-kernel.sh @@ -275,18 +275,12 @@ while : ; do powerpc*|ppc*) linux_arch=powerpc ;; - nios2) - linux_arch=nios2 - ;; arm) linux_arch=arm ;; arm64) linux_arch=arm64 ;; - sh|sh4) - linux_arch=sh - ;; *) echo "$me: unsupported architecture: $linux_arch" >&2 linux_arch= ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : powerpc64: drop architecture support
Module: xenomai-3 Branch: next Commit: 3d5f73472d668b8eb442d6026aaa2c3397859ff1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3d5f73472d668b8eb442d6026aaa2c3397859ff1 Author: Philippe GerumDate: Mon May 21 12:42:46 2018 +0200 powerpc64: drop architecture support The powerpc64 architecture does not seem to have any active Xenomai user, at least none who may be concerned enough to be willing to help in maintaining this Xenomai port. --- configure.ac |2 +- doc/asciidoc/README.INSTALL.adoc | 18 ++- doc/asciidoc/TROUBLESHOOTING.COBALT.adoc | 10 -- .../arch/powerpc/include/asm/xenomai/calibration.h |4 --- .../arch/powerpc/include/asm/xenomai/machine.h |5 --- .../arch/powerpc/include/asm/xenomai/uapi/arith.h | 32 lib/cobalt/arch/powerpc/include/asm/xenomai/tsc.h |7 - 7 files changed, 3 insertions(+), 75 deletions(-) diff --git a/configure.ac b/configure.ac index a6b1200..e2a2d47 100644 --- a/configure.ac +++ b/configure.ac @@ -126,7 +126,7 @@ case "$build_for" in target_cpu_arch=x86 CONFIG_XENO_DEFAULT_PERIOD=10 ;; - ppc-*|powerpc-*|powerpc64-*|ppc64-*) + ppc-*|powerpc-*) use_tls=yes target_cpu_arch=powerpc CONFIG_XENO_DEFAULT_PERIOD=10 diff --git a/doc/asciidoc/README.INSTALL.adoc b/doc/asciidoc/README.INSTALL.adoc index 4fe6867..cbd2adc 100644 --- a/doc/asciidoc/README.INSTALL.adoc +++ b/doc/asciidoc/README.INSTALL.adoc @@ -248,8 +248,8 @@ have to install the proper cross-compilation toolchain for the target system first. [[cobalt-core-powerpc]] -Building a _Cobalt/powerpc_ kernel (32/64bit) -^ +Building a _Cobalt/powerpc_ kernel +^^ A typical cross-compilation setup, in order to build Xenomai for a ppc-6xx architecture running a 3.10.32 kernel. We use the DENX ELDK @@ -758,20 +758,6 @@ $ $xenomai_root/configure --host=powerpc-linux --with-core=cobalt \ $ make DESTDIR=$staging_dir install -- -Building the PPC64 libraries - - -Same process than for a 32bit PowerPC target, using a crosstool-built -toolchain for ppc64/SMP. - --- -$ cd $build_root -$ $xenomai_root/configure --host=powerpc64-unknown-linux-gnu \ - --with-core=cobalt --enable-smp -$ make DESTDIR=$staging_dir install --- - - Building the ARM libraries ~~ diff --git a/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc b/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc index db5673a..778e74f 100644 --- a/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc +++ b/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc @@ -125,16 +125,6 @@ article] from the Knowledge Base. See < >. - system init failed, code -22 - -On the ppc64 platform, check whether +CONFIG_PPC_64K_PAGES+ is defined -in your kernel configuration. If so, then you likely need to raise all -Xenomai parameters defining the size of internal heaps, such as -+CONFIG_XENO_OPT_SYS_HEAPSZ+, +CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ+ and -+CONFIG_XENO_OPT_SEM_HEAPSZ+, so that (size / 64k) > 2. The default -values for these parameters are currently based on the assumption that -PAGE_SIZE = 4k. - Local APIC absent or disabled! The Xenomai 2.x _nucleus_ issues this warning if the kernel diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h index 07dee5f..9f06c3f 100644 --- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h +++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h @@ -94,12 +94,8 @@ static inline void xnarch_get_latencies(struct xnclock_gravity *p) #ifndef __sched_latency /* Platform is unknown: pick a default value. */ -#ifdef CONFIG_PPC64 -#define __sched_latency 1000 -#else #define __sched_latency 4000 #endif -#endif p->user = xnclock_ns_to_ticks(, __sched_latency); p->kernel = xnclock_ns_to_ticks(, CONFIG_XENO_OPT_TIMING_KSCHEDLAT); p->irq = xnclock_ns_to_ticks(, CONFIG_XENO_OPT_TIMING_IRQLAT); diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h b/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h index 6737ddc..0e41fd6 100644 --- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h +++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h @@ -29,13 +29,8 @@ static inline __attribute_const__ unsigned long ffnz(unsigned long ul) { -#ifdef CONFIG_PPC64 - __asm__ ("cntlzd %0, %1" : "=r" (ul) : "r" (ul & (-ul))); - return 63 - ul; -#else __asm__ ("cntlzw %0, %1":"=r"(ul):"r"(ul & (-ul))); return
[Xenomai-git] Philippe Gerum : blackfin: drop architecture support
Module: xenomai-3 Branch: next Commit: 58e1e65b7f4008692118633dad6ded988d4c2066 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=58e1e65b7f4008692118633dad6ded988d4c2066 Author: Philippe GerumDate: Mon May 21 12:42:46 2018 +0200 blackfin: drop architecture support The blackfin architecture is not supported by the mainline kernel anymore since 4.17, and no concerned user showed up, willing to help in maintaining this Xenomai port. --- configure.ac |8 -- doc/asciidoc/README.INSTALL.adoc | 43 doc/asciidoc/TROUBLESHOOTING.COBALT.adoc |2 +- kernel/cobalt/arch/blackfin/Kconfig|8 -- kernel/cobalt/arch/blackfin/Makefile |5 - kernel/cobalt/arch/blackfin/README |3 - .../blackfin/include/asm/xenomai/calibration.h | 56 -- .../arch/blackfin/include/asm/xenomai/features.h | 27 - .../arch/blackfin/include/asm/xenomai/fptest.h | 44 .../arch/blackfin/include/asm/xenomai/machine.h| 36 --- .../arch/blackfin/include/asm/xenomai/syscall.h| 70 .../arch/blackfin/include/asm/xenomai/syscall32.h | 24 - .../arch/blackfin/include/asm/xenomai/thread.h | 69 .../arch/blackfin/include/asm/xenomai/uapi/arith.h | 43 .../blackfin/include/asm/xenomai/uapi/features.h | 40 --- .../blackfin/include/asm/xenomai/uapi/fptest.h | 31 -- .../blackfin/include/asm/xenomai/uapi/syscall.h| 29 - .../arch/blackfin/include/asm/xenomai/wrappers.h | 27 - kernel/cobalt/arch/blackfin/machine.c | 90 kernel/cobalt/arch/blackfin/mayday.c | 112 kernel/cobalt/arch/blackfin/switch.S | 98 - kernel/cobalt/arch/blackfin/syscall.c | 41 --- kernel/cobalt/arch/blackfin/thread.c | 106 -- lib/cobalt/arch/Makefile.am|2 +- lib/cobalt/arch/blackfin/Makefile.am | 13 --- lib/cobalt/arch/blackfin/features.c| 24 - lib/cobalt/arch/blackfin/include/Makefile.am |2 - lib/cobalt/arch/blackfin/include/asm/Makefile.am |2 - .../arch/blackfin/include/asm/xenomai/Makefile.am |5 - .../arch/blackfin/include/asm/xenomai/features.h | 30 -- .../arch/blackfin/include/asm/xenomai/syscall.h| 58 -- lib/cobalt/arch/blackfin/include/asm/xenomai/tsc.h | 44 scripts/prepare-kernel.sh |3 - 33 files changed, 2 insertions(+), 1193 deletions(-) diff --git a/configure.ac b/configure.ac index 6c94301..a6b1200 100644 --- a/configure.ac +++ b/configure.ac @@ -131,10 +131,6 @@ case "$build_for" in target_cpu_arch=powerpc CONFIG_XENO_DEFAULT_PERIOD=10 ;; - bfin-*|bfinnommu-*|blackfin-*) - target_cpu_arch=blackfin - CONFIG_XENO_DEFAULT_PERIOD=10 - ;; arm*-*) target_cpu_arch=arm CONFIG_XENO_DEFAULT_PERIOD=100 @@ -928,10 +924,6 @@ AC_CONFIG_FILES([ \ lib/cobalt/arch/powerpc/include/Makefile \ lib/cobalt/arch/powerpc/include/asm/Makefile \ lib/cobalt/arch/powerpc/include/asm/xenomai/Makefile \ - lib/cobalt/arch/blackfin/Makefile \ - lib/cobalt/arch/blackfin/include/Makefile \ - lib/cobalt/arch/blackfin/include/asm/Makefile \ - lib/cobalt/arch/blackfin/include/asm/xenomai/Makefile \ lib/cobalt/arch/x86/Makefile \ lib/cobalt/arch/x86/include/Makefile \ lib/cobalt/arch/x86/include/asm/Makefile \ diff --git a/doc/asciidoc/README.INSTALL.adoc b/doc/asciidoc/README.INSTALL.adoc index d32d710..4fe6867 100644 --- a/doc/asciidoc/README.INSTALL.adoc +++ b/doc/asciidoc/README.INSTALL.adoc @@ -119,7 +119,6 @@ In order to cross-compile the Linux kernel, pass an ARCH and CROSS_COMPILE variable on make command line. See sections < >, < >, -< >, < >, for examples. @@ -268,27 +267,6 @@ $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux- uImage modules -- ...manually install the kernel image and modules to the proper location -[[cobalt-core-blackfin]] -Building a _Cobalt/blackfin_ kernel -^^^ - -The Blackfin is a MMU-less, DSP-type architecture running uClinux. - --- -$ cd $linux_tree -$ $xenomai_root/scripts/prepare-kernel.sh --arch=blackfin \ - --ipipe=ipipe-core-X.Y.Z-x86-NN.patch -$ make ARCH=blackfin CROSS_COMPILE=bfin-uclinux-
[Xenomai-git] Philippe Gerum : testsuite/smokey: add core heap test
Module: xenomai-3 Branch: next Commit: 20387bcddf5e4413e41770ce4043e632b33d0905 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20387bcddf5e4413e41770ce4043e632b33d0905 Author: Philippe GerumDate: Sat May 19 11:18:53 2018 +0200 testsuite/smokey: add core heap test --- configure.ac |1 + testsuite/smokey/Makefile.am |1 + testsuite/smokey/memcheck/memcheck.c | 250 +- testsuite/smokey/memcheck/memcheck.h | 22 ++- testsuite/smokey/memory-coreheap/Makefile.am |9 + testsuite/smokey/memory-coreheap/coreheap.c | 108 +++ 6 files changed, 267 insertions(+), 124 deletions(-) diff --git a/configure.ac b/configure.ac index b670206..6c94301 100644 --- a/configure.ac +++ b/configure.ac @@ -971,6 +971,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-coreheap/Makefile \ testsuite/smokey/memory-heapmem/Makefile \ testsuite/smokey/memory-tlsf/Makefile \ testsuite/smokey/memory-pshared/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index d7a71fe..601331e 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -16,6 +16,7 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-coreheap \ memory-heapmem \ memory-tlsf \ memcheck\ diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c index 7f97218..a33700f 100644 --- a/testsuite/smokey/memcheck/memcheck.c +++ b/testsuite/smokey/memcheck/memcheck.c @@ -24,27 +24,45 @@ struct chunk { enum pattern pattern; }; -struct runstats { - size_t heap_size; - size_t user_size; - size_t block_size; - int nrblocks; - long alloc_avg_ns; - long alloc_max_ns; - long free_avg_ns; - long free_max_ns; - int flags; - double overhead; - double fragmentation; - struct runstats *next; -}; - -static struct runstats *statistics; +static struct memcheck_stat *statistics; static int nrstats; static int max_results = 4; +#ifdef CONFIG_XENO_COBALT + +#include + +static inline void breathe(int loops) +{ + struct timespec idle = { + .tv_sec = 0, + .tv_nsec = 30, + }; + + /* +* There is not rt throttling over Cobalt, so we may need to +* keep the host kernel breathing by napping during the test +* sequences. +*/ + if ((loops % 1000) == 0) + __RT(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + +static inline void harden(void) +{ + cobalt_thread_harden(); +} + +#else + +static inline void breathe(int loops) { } + +static inline void harden(void) { } + +#endif + static inline long diff_ts(struct timespec *left, struct timespec *right) { return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION @@ -69,6 +87,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) double u; for(j = nmemb; j > 0; j--) { + breathe(j); u = (double)random() / RAND_MAX; k = (unsigned int)(j * u) + 1; if (j == k) @@ -88,37 +107,39 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) static int sort_by_heap_size(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->heap_size, ls->heap_size); } static int sort_by_alloc_time(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->alloc_max_ns, ls->alloc_max_ns); } static int sort_by_free_time(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->free_max_ns, ls->free_max_ns); } static int sort_by_frag(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; - return compare_values(rs->fragmentation, ls->fragmentation); + return compare_values(rs->maximum_free - rs->largest_free, + ls->maximum_free - ls->largest_free); } static int sort_by_overhead(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; - return compare_values(rs->overhead, ls->overhead); + return compare_values(rs->heap_size - rs->user_size, + ls->heap_size - ls->user_size); } static
[Xenomai-git] Philippe Gerum : lib/smokey: enable test filtering with --list[=expr]
Module: xenomai-3 Branch: next Commit: d404b2c060ddc3300856c4491b36e5fe083410a9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d404b2c060ddc3300856c4491b36e5fe083410a9 Author: Philippe GerumDate: Sat May 19 12:01:49 2018 +0200 lib/smokey: enable test filtering with --list[=expr] --- lib/smokey/init.c | 91 +++-- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/lib/smokey/init.c b/lib/smokey/init.c index 9df9a55..e1a133e 100644 --- a/lib/smokey/init.c +++ b/lib/smokey/init.c @@ -143,11 +143,13 @@ * Any program linked against the Smokey API implicitly recognizes the * following options: * - * - --list dumps the list of tests implemented in the program to - * stdout. The information given includes the description strings - * provided in the plugin declarators (smokey_test_plugin()). The - * position and symbolic name of each test is also issued, which may - * be used in id specifications with the --run option (see below). + * - --list[= ] dumps the list of tests implemented in the + * program to stdout. This list may be restricted to the tests + * matching the optional regular expression (see --run). The + * information given includes the description strings provided in + * the plugin declarators (smokey_test_plugin()). The position and + * symbolic name of each test is also issued, which may be used in + * id specifications with the --run option (see below). * * @note Test positions may vary depending on changes to the host * program like adding or removing other tests, the symbolic name @@ -297,7 +299,7 @@ static const struct option smokey_options[] = { { #define list_opt 2 .name = "list", - .has_arg = no_argument, + .has_arg = optional_argument, .flag = _list, .val = 1, }, @@ -319,13 +321,13 @@ static const struct option smokey_options[] = { static void smokey_help(void) { fprintf(stderr, "--keep-going don't stop upon test error\n"); - fprintf(stderr, "--list list all tests\n"); + fprintf(stderr, "--list[= ]] list [matching] tests\n"); fprintf(stderr, "--run[= ]] run [portion of] the test list\n"); fprintf(stderr, "--exclude= ]exclude test(s) from the run list\n"); fprintf(stderr, "--vm hint about running in a virtual environment\n"); } -static void pick_test_range(int start, int end) +static void pick_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -336,7 +338,7 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _test_list); + pvlist_append(>__reserved.next, dst); } } } else { @@ -344,13 +346,13 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= end && t->__reserved.id <= start) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _test_list); + pvlist_append(>__reserved.next, dst); } } } } -static void drop_test_range(int start, int end) +static void drop_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -363,7 +365,7 @@ static void drop_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _list); + pvlist_append(>__reserved.next, dst); } } } @@ -376,8 +378,8 @@ static int resolve_id(const char *s) return atoi(s); /* -* CAUTION: as we transfer items from register_list to -* smokey_test_list, we may end up with an empty source list, +* CAUTION: as we transfer items from register_list to a +* destination list, we may end up with an empty source list, * which is a perfectly valid situation. Unlike having an * empty registration list at startup, which would mean that * no test is available from the current program. @@ -392,7 +394,7 @@ static int resolve_id(const char *s) return -1; } -static int do_glob_match(const char *s, struct pvlistobj *list) +static int glob_match(struct pvlistobj *dst, const char *s) {
[Xenomai-git] Philippe Gerum : powerpc64: drop architecture support
Module: xenomai-3 Branch: next Commit: eb314853e93b81da595b79061dabb7d2c55351fe URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eb314853e93b81da595b79061dabb7d2c55351fe Author: Philippe GerumDate: Mon May 21 12:42:46 2018 +0200 powerpc64: drop architecture support The powerpc64 architecture does not seem to have any active Xenomai user, at least none who may be concerned enough to be willing to help in maintaining this Xenomai port. --- configure.ac |2 +- doc/asciidoc/README.INSTALL.adoc | 18 ++- doc/asciidoc/TROUBLESHOOTING.COBALT.adoc | 10 -- .../arch/powerpc/include/asm/xenomai/calibration.h |4 --- .../arch/powerpc/include/asm/xenomai/machine.h |5 --- .../arch/powerpc/include/asm/xenomai/uapi/arith.h | 32 lib/cobalt/arch/powerpc/include/asm/xenomai/tsc.h |7 - 7 files changed, 3 insertions(+), 75 deletions(-) diff --git a/configure.ac b/configure.ac index a6b1200..e2a2d47 100644 --- a/configure.ac +++ b/configure.ac @@ -126,7 +126,7 @@ case "$build_for" in target_cpu_arch=x86 CONFIG_XENO_DEFAULT_PERIOD=10 ;; - ppc-*|powerpc-*|powerpc64-*|ppc64-*) + ppc-*|powerpc-*) use_tls=yes target_cpu_arch=powerpc CONFIG_XENO_DEFAULT_PERIOD=10 diff --git a/doc/asciidoc/README.INSTALL.adoc b/doc/asciidoc/README.INSTALL.adoc index 4fe6867..cbd2adc 100644 --- a/doc/asciidoc/README.INSTALL.adoc +++ b/doc/asciidoc/README.INSTALL.adoc @@ -248,8 +248,8 @@ have to install the proper cross-compilation toolchain for the target system first. [[cobalt-core-powerpc]] -Building a _Cobalt/powerpc_ kernel (32/64bit) -^ +Building a _Cobalt/powerpc_ kernel +^^ A typical cross-compilation setup, in order to build Xenomai for a ppc-6xx architecture running a 3.10.32 kernel. We use the DENX ELDK @@ -758,20 +758,6 @@ $ $xenomai_root/configure --host=powerpc-linux --with-core=cobalt \ $ make DESTDIR=$staging_dir install -- -Building the PPC64 libraries - - -Same process than for a 32bit PowerPC target, using a crosstool-built -toolchain for ppc64/SMP. - --- -$ cd $build_root -$ $xenomai_root/configure --host=powerpc64-unknown-linux-gnu \ - --with-core=cobalt --enable-smp -$ make DESTDIR=$staging_dir install --- - - Building the ARM libraries ~~ diff --git a/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc b/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc index db5673a..778e74f 100644 --- a/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc +++ b/doc/asciidoc/TROUBLESHOOTING.COBALT.adoc @@ -125,16 +125,6 @@ article] from the Knowledge Base. See < >. - system init failed, code -22 - -On the ppc64 platform, check whether +CONFIG_PPC_64K_PAGES+ is defined -in your kernel configuration. If so, then you likely need to raise all -Xenomai parameters defining the size of internal heaps, such as -+CONFIG_XENO_OPT_SYS_HEAPSZ+, +CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ+ and -+CONFIG_XENO_OPT_SEM_HEAPSZ+, so that (size / 64k) > 2. The default -values for these parameters are currently based on the assumption that -PAGE_SIZE = 4k. - Local APIC absent or disabled! The Xenomai 2.x _nucleus_ issues this warning if the kernel diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h index 07dee5f..9f06c3f 100644 --- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h +++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h @@ -94,12 +94,8 @@ static inline void xnarch_get_latencies(struct xnclock_gravity *p) #ifndef __sched_latency /* Platform is unknown: pick a default value. */ -#ifdef CONFIG_PPC64 -#define __sched_latency 1000 -#else #define __sched_latency 4000 #endif -#endif p->user = xnclock_ns_to_ticks(, __sched_latency); p->kernel = xnclock_ns_to_ticks(, CONFIG_XENO_OPT_TIMING_KSCHEDLAT); p->irq = xnclock_ns_to_ticks(, CONFIG_XENO_OPT_TIMING_IRQLAT); diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h b/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h index 6737ddc..0e41fd6 100644 --- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h +++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/machine.h @@ -29,13 +29,8 @@ static inline __attribute_const__ unsigned long ffnz(unsigned long ul) { -#ifdef CONFIG_PPC64 - __asm__ ("cntlzd %0, %1" : "=r" (ul) : "r" (ul & (-ul))); - return 63 - ul; -#else __asm__ ("cntlzw %0, %1":"=r"(ul):"r"(ul & (-ul))); return
[Xenomai-git] Philippe Gerum : blackfin: drop architecture support
Module: xenomai-3 Branch: next Commit: c58fe890afd12b9833837ac1cd1190435352d95e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c58fe890afd12b9833837ac1cd1190435352d95e Author: Philippe GerumDate: Mon May 21 12:42:46 2018 +0200 blackfin: drop architecture support The blackfin architecture is not supported by the mainline kernel anymore since 4.17, and no concerned user showed up, willing to help in maintaining this Xenomai port. --- configure.ac |8 -- doc/asciidoc/README.INSTALL.adoc | 43 doc/asciidoc/TROUBLESHOOTING.COBALT.adoc |2 +- kernel/cobalt/arch/blackfin/Kconfig|8 -- kernel/cobalt/arch/blackfin/Makefile |5 - kernel/cobalt/arch/blackfin/README |3 - .../blackfin/include/asm/xenomai/calibration.h | 56 -- .../arch/blackfin/include/asm/xenomai/features.h | 27 - .../arch/blackfin/include/asm/xenomai/fptest.h | 44 .../arch/blackfin/include/asm/xenomai/machine.h| 36 --- .../arch/blackfin/include/asm/xenomai/syscall.h| 70 .../arch/blackfin/include/asm/xenomai/syscall32.h | 24 - .../arch/blackfin/include/asm/xenomai/thread.h | 69 .../arch/blackfin/include/asm/xenomai/uapi/arith.h | 43 .../blackfin/include/asm/xenomai/uapi/features.h | 40 --- .../blackfin/include/asm/xenomai/uapi/fptest.h | 31 -- .../blackfin/include/asm/xenomai/uapi/syscall.h| 29 - .../arch/blackfin/include/asm/xenomai/wrappers.h | 27 - kernel/cobalt/arch/blackfin/machine.c | 90 kernel/cobalt/arch/blackfin/mayday.c | 112 kernel/cobalt/arch/blackfin/switch.S | 98 - kernel/cobalt/arch/blackfin/syscall.c | 41 --- kernel/cobalt/arch/blackfin/thread.c | 106 -- lib/cobalt/arch/Makefile.am|2 +- lib/cobalt/arch/blackfin/Makefile.am | 13 --- lib/cobalt/arch/blackfin/features.c| 24 - lib/cobalt/arch/blackfin/include/Makefile.am |2 - lib/cobalt/arch/blackfin/include/asm/Makefile.am |2 - .../arch/blackfin/include/asm/xenomai/Makefile.am |5 - .../arch/blackfin/include/asm/xenomai/features.h | 30 -- .../arch/blackfin/include/asm/xenomai/syscall.h| 58 -- lib/cobalt/arch/blackfin/include/asm/xenomai/tsc.h | 44 scripts/prepare-kernel.sh |3 - 33 files changed, 2 insertions(+), 1193 deletions(-) diff --git a/configure.ac b/configure.ac index 6c94301..a6b1200 100644 --- a/configure.ac +++ b/configure.ac @@ -131,10 +131,6 @@ case "$build_for" in target_cpu_arch=powerpc CONFIG_XENO_DEFAULT_PERIOD=10 ;; - bfin-*|bfinnommu-*|blackfin-*) - target_cpu_arch=blackfin - CONFIG_XENO_DEFAULT_PERIOD=10 - ;; arm*-*) target_cpu_arch=arm CONFIG_XENO_DEFAULT_PERIOD=100 @@ -928,10 +924,6 @@ AC_CONFIG_FILES([ \ lib/cobalt/arch/powerpc/include/Makefile \ lib/cobalt/arch/powerpc/include/asm/Makefile \ lib/cobalt/arch/powerpc/include/asm/xenomai/Makefile \ - lib/cobalt/arch/blackfin/Makefile \ - lib/cobalt/arch/blackfin/include/Makefile \ - lib/cobalt/arch/blackfin/include/asm/Makefile \ - lib/cobalt/arch/blackfin/include/asm/xenomai/Makefile \ lib/cobalt/arch/x86/Makefile \ lib/cobalt/arch/x86/include/Makefile \ lib/cobalt/arch/x86/include/asm/Makefile \ diff --git a/doc/asciidoc/README.INSTALL.adoc b/doc/asciidoc/README.INSTALL.adoc index d32d710..4fe6867 100644 --- a/doc/asciidoc/README.INSTALL.adoc +++ b/doc/asciidoc/README.INSTALL.adoc @@ -119,7 +119,6 @@ In order to cross-compile the Linux kernel, pass an ARCH and CROSS_COMPILE variable on make command line. See sections < >, < >, -< >, < >, for examples. @@ -268,27 +267,6 @@ $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux- uImage modules -- ...manually install the kernel image and modules to the proper location -[[cobalt-core-blackfin]] -Building a _Cobalt/blackfin_ kernel -^^^ - -The Blackfin is a MMU-less, DSP-type architecture running uClinux. - --- -$ cd $linux_tree -$ $xenomai_root/scripts/prepare-kernel.sh --arch=blackfin \ - --ipipe=ipipe-core-X.Y.Z-x86-NN.patch -$ make ARCH=blackfin CROSS_COMPILE=bfin-uclinux-
[Xenomai-git] Philippe Gerum : cobalt/heap: rebase on HEAPMEM algorithm
Module: xenomai-3 Branch: next Commit: 10606d3ab266b3ffd077cc06db3c96d620d70612 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=10606d3ab266b3ffd077cc06db3c96d620d70612 Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 128 8192 0 1 2 8 1024k 1665536 0 0 6 7 +shuffle +realloc 1024k 3232768 0 0 8 6 512k 3216384 0 0 5 6 +realloc ... (364 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 2 (us) average alloc time: 1 (us) average free time: 1 (us) [SEQUENTIAL ALLOC->FREE, RANDOM BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 512k 17k 28 1 1 8 2 +shuffle 512k 45k 11 1 1 7 2 1024k 2432768 0 0 7 6 +shuffle 128k 820 128 1 1 6 2 +shuffle ... (32764 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k3k 292 1 1 1 8 +shuffle 256k 174 1024 1 1 1 6 +shuffle 1024k 2432768 0 0 7 6 +shuffle 32k 12k 2 2 3 1 5 ... (32764 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 1 (us) average alloc time: 1 (us) average free time: 1 (us) [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html --- include/cobalt/kernel/heap.h | 168 kernel/cobalt/Kconfig|7 + kernel/cobalt/heap.c | 978 +- 3 files changed, 663 insertions(+), 490 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index d89f25d..8a1c6f6 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -20,6 +20,7 @@ #define _COBALT_KERNEL_HEAP_H #include +#include #include #include #include @@ -28,66 +29,66 @@ /** * @addtogroup cobalt_core_heap * @{ - * - * @par Implementation constraints - * - * - Minimum page size is 2 ** XNHEAP_MINLOG2 (must be large enough to - * hold a pointer). - * - * - Maximum page size is 2 ** XNHEAP_MAXLOG2. - * - * - Requested block size is rounded up to XNHEAP_MINLOG2. - * - * - Requested block size larger than 2 times the XNHEAP_PAGESZ is - * rounded up to the next page boundary and obtained from the free - * page list. So we need a bucket for each power of two between - * XNHEAP_MINLOG2 and XNHEAP_MAXLOG2 inclusive, plus one to honor - * requests ranging from the maximum page size to twice this size. */ -#define XNHEAP_PAGESZPAGE_SIZE -#define XNHEAP_MINLOG23 -#define XNHEAP_MAXLOG222 /* Holds pagemap.bcount blocks */ -#define XNHEAP_MINALLOCSZ (1 << XNHEAP_MINLOG2) -#define XNHEAP_MINALIGNSZ (1 << 4) /* i.e. 16 bytes */ -#define
[Xenomai-git] Philippe Gerum : drivers/testing: add core heap test module
Module: xenomai-3 Branch: next Commit: e4a38086b2fbe4d4696046d27228d38e4a8987d4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e4a38086b2fbe4d4696046d27228d38e4a8987d4 Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 drivers/testing: add core heap test module --- include/rtdm/uapi/testing.h| 41 ++- kernel/drivers/testing/Kconfig |6 + kernel/drivers/testing/Makefile|3 + kernel/drivers/testing/heapcheck.c | 515 4 files changed, 564 insertions(+), 1 deletion(-) diff --git a/include/rtdm/uapi/testing.h b/include/rtdm/uapi/testing.h index 06b8f1e..f8207b8 100644 --- a/include/rtdm/uapi/testing.h +++ b/include/rtdm/uapi/testing.h @@ -87,6 +87,37 @@ struct rttst_swtest_error { #define RTTST_RTDM_MAGIC_PRIMARY 0xfefbfefb #define RTTST_RTDM_MAGIC_SECONDARY 0xa5b9a5b9 +#define RTTST_HEAPCHECK_ZEROOVRD 1 +#define RTTST_HEAPCHECK_SHUFFLE2 +#define RTTST_HEAPCHECK_PATTERN4 +#define RTTST_HEAPCHECK_HOT8 + +struct rttst_heap_parms { + __u64 heap_size; + __u64 block_size; + int flags; + int nrstats; +}; + +struct rttst_heap_stats { + __u64 heap_size; + __u64 user_size; + __u64 block_size; + __s64 alloc_avg_ns; + __s64 alloc_max_ns; + __s64 free_avg_ns; + __s64 free_max_ns; + __u64 maximum_free; + __u64 largest_free; + int nrblocks; + int flags; +}; + +struct rttst_heap_stathdr { + int nrstats; + struct rttst_heap_stats *buf; +}; + #define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING /*! @@ -100,6 +131,8 @@ struct rttst_swtest_error { #define RTDM_SUBCLASS_SWITCHTEST 2 /** subclase name: "rtdm" */ #define RTDM_SUBCLASS_RTDMTEST 3 +/** subclase name: "heapcheck" */ +#define RTDM_SUBCLASS_HEAPCHECK4 /** @} */ /*! @@ -153,7 +186,13 @@ struct rttst_swtest_error { #define RTTST_RTIOC_RTDM_PING_SECONDARY \ _IOR(RTIOC_TYPE_TESTING, 0x43, __u32) - + +#define RTTST_RTIOC_HEAP_CHECK \ + _IOR(RTIOC_TYPE_TESTING, 0x44, struct rttst_heap_parms) + +#define RTTST_RTIOC_HEAP_STAT_COLLECT \ + _IOR(RTIOC_TYPE_TESTING, 0x45, int) + /** @} */ #endif /* !_RTDM_UAPI_TESTING_H */ diff --git a/kernel/drivers/testing/Kconfig b/kernel/drivers/testing/Kconfig index bb44abb..88c043c 100644 --- a/kernel/drivers/testing/Kconfig +++ b/kernel/drivers/testing/Kconfig @@ -14,6 +14,12 @@ config XENO_DRIVERS_SWITCHTEST Kernel-based driver for unit testing context switches and FPU switches. +config XENO_DRIVERS_HEAPCHECK + tristate "Memory allocator test driver" + default y + help + Kernel-based driver for testing Cobalt's memory allocator. + config XENO_DRIVERS_RTDMTEST depends on m tristate "RTDM unit tests driver" diff --git a/kernel/drivers/testing/Makefile b/kernel/drivers/testing/Makefile index 367a22e..09b0763 100644 --- a/kernel/drivers/testing/Makefile +++ b/kernel/drivers/testing/Makefile @@ -2,9 +2,12 @@ obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o obj-$(CONFIG_XENO_DRIVERS_RTDMTEST) += xeno_rtdmtest.o +obj-$(CONFIG_XENO_DRIVERS_HEAPCHECK) += xeno_heapcheck.o xeno_timerbench-y := timerbench.o xeno_switchtest-y := switchtest.o xeno_rtdmtest-y := rtdmtest.o + +xeno_heapcheck-y := heapcheck.o diff --git a/kernel/drivers/testing/heapcheck.c b/kernel/drivers/testing/heapcheck.c new file mode 100644 index 000..bed5a05 --- /dev/null +++ b/kernel/drivers/testing/heapcheck.c @@ -0,0 +1,515 @@ +/* + * Copyright (C) 2018 Philippe Gerum . + * + * Xenomai is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Xenomai is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xenomai; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define complain(__fmt, __args...) \ + printk(XENO_WARNING "heap check: " __fmt "\n", ##__args) + +static struct xnheap test_heap = { + .name = "test_heap" +}; + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + struct rttst_heap_stats stats; + struct runstats
[Xenomai-git] Philippe Gerum : cobalt/heap: rebase on HEAPMEM algorithm
Module: xenomai-3 Branch: next Commit: 0446cc545543100016491a71d7e2fc87082e6575 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0446cc545543100016491a71d7e2fc87082e6575 Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 128 8192 0 1 2 8 1024k 1665536 0 0 6 7 +shuffle +realloc 1024k 3232768 0 0 8 6 512k 3216384 0 0 5 6 +realloc ... (364 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 2 (us) average alloc time: 1 (us) average free time: 1 (us) [SEQUENTIAL ALLOC->FREE, RANDOM BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 512k 17k 28 1 1 8 2 +shuffle 512k 45k 11 1 1 7 2 1024k 2432768 0 0 7 6 +shuffle 128k 820 128 1 1 6 2 +shuffle ... (32764 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k3k 292 1 1 1 8 +shuffle 256k 174 1024 1 1 1 6 +shuffle 1024k 2432768 0 0 7 6 +shuffle 32k 12k 2 2 3 1 5 ... (32764 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 1 (us) average alloc time: 1 (us) average free time: 1 (us) [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html --- include/cobalt/kernel/heap.h | 168 kernel/cobalt/Kconfig|7 + kernel/cobalt/heap.c | 979 +- 3 files changed, 662 insertions(+), 492 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index d89f25d..8a1c6f6 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -20,6 +20,7 @@ #define _COBALT_KERNEL_HEAP_H #include +#include #include #include #include @@ -28,66 +29,66 @@ /** * @addtogroup cobalt_core_heap * @{ - * - * @par Implementation constraints - * - * - Minimum page size is 2 ** XNHEAP_MINLOG2 (must be large enough to - * hold a pointer). - * - * - Maximum page size is 2 ** XNHEAP_MAXLOG2. - * - * - Requested block size is rounded up to XNHEAP_MINLOG2. - * - * - Requested block size larger than 2 times the XNHEAP_PAGESZ is - * rounded up to the next page boundary and obtained from the free - * page list. So we need a bucket for each power of two between - * XNHEAP_MINLOG2 and XNHEAP_MAXLOG2 inclusive, plus one to honor - * requests ranging from the maximum page size to twice this size. */ -#define XNHEAP_PAGESZPAGE_SIZE -#define XNHEAP_MINLOG23 -#define XNHEAP_MAXLOG222 /* Holds pagemap.bcount blocks */ -#define XNHEAP_MINALLOCSZ (1 << XNHEAP_MINLOG2) -#define XNHEAP_MINALIGNSZ (1 << 4) /* i.e. 16 bytes */ -#define
[Xenomai-git] Philippe Gerum : drivers/ipc: align pool memory on native page size
Module: xenomai-3 Branch: next Commit: 8469b45a6d6137cd223f0a833b42430a4e3a58f8 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8469b45a6d6137cd223f0a833b42430a4e3a58f8 Author: Philippe GerumDate: Sun May 13 19:00:36 2018 +0200 drivers/ipc: align pool memory on native page size --- kernel/drivers/ipc/iddp.c |2 +- kernel/drivers/ipc/xddp.c |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c index 854a4b6..2a80eba 100644 --- a/kernel/drivers/ipc/iddp.c +++ b/kernel/drivers/ipc/iddp.c @@ -569,7 +569,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd, */ poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); + poolsz = PAGE_ALIGN(poolsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c index 95bee57..57275d0 100644 --- a/kernel/drivers/ipc/xddp.c +++ b/kernel/drivers/ipc/xddp.c @@ -691,8 +691,8 @@ static int __xddp_bind_socket(struct rtipc_private *priv, poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); - poolsz += xnheap_rounded_size(sk->reqbufsz); + poolsz = PAGE_ALIGN(poolsz); + poolsz += PAGE_ALIGN(sk->reqbufsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/smokey: enable test filtering with --list[=expr]
Module: xenomai-3 Branch: next Commit: 4b1e411395a44840fdbc2cfeb90a09bfe19e5026 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4b1e411395a44840fdbc2cfeb90a09bfe19e5026 Author: Philippe GerumDate: Sat May 19 12:01:49 2018 +0200 lib/smokey: enable test filtering with --list[=expr] --- lib/smokey/init.c | 91 +++-- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/lib/smokey/init.c b/lib/smokey/init.c index 9df9a55..e1a133e 100644 --- a/lib/smokey/init.c +++ b/lib/smokey/init.c @@ -143,11 +143,13 @@ * Any program linked against the Smokey API implicitly recognizes the * following options: * - * - --list dumps the list of tests implemented in the program to - * stdout. The information given includes the description strings - * provided in the plugin declarators (smokey_test_plugin()). The - * position and symbolic name of each test is also issued, which may - * be used in id specifications with the --run option (see below). + * - --list[= ] dumps the list of tests implemented in the + * program to stdout. This list may be restricted to the tests + * matching the optional regular expression (see --run). The + * information given includes the description strings provided in + * the plugin declarators (smokey_test_plugin()). The position and + * symbolic name of each test is also issued, which may be used in + * id specifications with the --run option (see below). * * @note Test positions may vary depending on changes to the host * program like adding or removing other tests, the symbolic name @@ -297,7 +299,7 @@ static const struct option smokey_options[] = { { #define list_opt 2 .name = "list", - .has_arg = no_argument, + .has_arg = optional_argument, .flag = _list, .val = 1, }, @@ -319,13 +321,13 @@ static const struct option smokey_options[] = { static void smokey_help(void) { fprintf(stderr, "--keep-going don't stop upon test error\n"); - fprintf(stderr, "--list list all tests\n"); + fprintf(stderr, "--list[= ]] list [matching] tests\n"); fprintf(stderr, "--run[= ]] run [portion of] the test list\n"); fprintf(stderr, "--exclude= ]exclude test(s) from the run list\n"); fprintf(stderr, "--vm hint about running in a virtual environment\n"); } -static void pick_test_range(int start, int end) +static void pick_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -336,7 +338,7 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _test_list); + pvlist_append(>__reserved.next, dst); } } } else { @@ -344,13 +346,13 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= end && t->__reserved.id <= start) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _test_list); + pvlist_append(>__reserved.next, dst); } } } } -static void drop_test_range(int start, int end) +static void drop_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -363,7 +365,7 @@ static void drop_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(>__reserved.next); - pvlist_append(>__reserved.next, _list); + pvlist_append(>__reserved.next, dst); } } } @@ -376,8 +378,8 @@ static int resolve_id(const char *s) return atoi(s); /* -* CAUTION: as we transfer items from register_list to -* smokey_test_list, we may end up with an empty source list, +* CAUTION: as we transfer items from register_list to a +* destination list, we may end up with an empty source list, * which is a perfectly valid situation. Unlike having an * empty registration list at startup, which would mean that * no test is available from the current program. @@ -392,7 +394,7 @@ static int resolve_id(const char *s) return -1; } -static int do_glob_match(const char *s, struct pvlistobj *list) +static int glob_match(struct pvlistobj *dst, const char *s) {
[Xenomai-git] Gilles Chanteperdrix : boilerplate/avl: merge pshared support for AVL trees
Module: xenomai-3 Branch: next Commit: 3892e3e6fa10ad62024c956c83cca4beed8494be URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3892e3e6fa10ad62024c956c83cca4beed8494be Author: Gilles ChanteperdrixDate: Tue Jul 12 20:29:22 2016 +0200 boilerplate/avl: merge pshared support for AVL trees Make the AVL tree usable in shared memory when AVL_SHARED is defined at build time, switching to offset-based memory references. Gilles published this code in July 2016 as part of his personal toolkit for hobby projects aka 'libchutils'. --- include/boilerplate/avl.h | 472 -- lib/boilerplate/avl.c | 497 ++--- 2 files changed, 697 insertions(+), 272 deletions(-) diff --git a/include/boilerplate/avl.h b/include/boilerplate/avl.h index 1aa84bf..34fb23a 100644 --- a/include/boilerplate/avl.h +++ b/include/boilerplate/avl.h @@ -23,276 +23,444 @@ #ifndef _BOILERPLATE_AVL_H #define _BOILERPLATE_AVL_H -#include +#include +#include struct avlh { - unsigned int thr: 3; +#define AVLH_APP_BITS 28 + unsigned int flags: AVLH_APP_BITS; int type: 2; - int balance :2; - unsigned int flags :25; /* Application-specific */ - struct avlh *link[3]; + int balance: 2; + union { + ptrdiff_t offset; + struct avlh *ptr; + } link[3]; }; -/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0 - for "up" is just here for orthogonality... and avoid wasting 4 bytes or - having to use a union in struct avlh. */ -#define AVL_LEFT -1 -#define AVL_UP0 -#define AVL_RIGHT 1 -/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ -#define avl_opposite(type) (-(type)) -/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */ -#define avl_type2sign(type) (type) -/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ -#define avl_type2index(type) ((type)+1) -/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */ -#define avl_sign2type(sign) (sign) - -#define AVL_THR_LEFT (1< thr |= 1 << avl_type2index(side)) -#define avlh_thr_clr(holder, side) ((holder)->thr &= ~(1 << avl_type2index(side))) -#define avlh_thr_tst(holder, side) ((holder)->thr & (1 << avl_type2index(side))) -#define avlh_link(holder, dir) ((holder)->link[avl_type2index(dir)]) -#define avlh_up(holder)avlh_link((holder), AVL_UP) -#define avlh_left(holder) avlh_link((holder), AVL_LEFT) -#define avlh_right(holder) avlh_link((holder), AVL_RIGHT) -#define avlh_parent_link(holder) (avlh_link(avlh_up(holder), (holder)->type)) - struct avl; -typedef struct avlh *avl_search_t(const struct avl *, const struct avlh *, int *); - +/* + * Comparison function: should return -1 if left is less than right, 0 + * if they are equal and 1 if left is greather than right. You can use + * the avl_sign function which will convert a difference to -1, 0, + * 1. Beware of overflow however. You can also use avl_cmp_sign() + * which should not have any such problems. + */ typedef int avlh_cmp_t(const struct avlh *const, const struct avlh *const); +typedef struct avlh * +avl_search_t(const struct avl *, const struct avlh *, int *, int); + +typedef int avlh_prn_t(char *, size_t, const struct avlh *const); + struct avl { struct avlh anchor; avl_search_t *search; avlh_cmp_t *cmp; - struct avlh *end[3]; + union { + ptrdiff_t offset; + struct avlh *ptr; + } end[3]; unsigned int count; unsigned int height; }; -#define avl_searchfn(avl) ((avl)->search) -#define avl_cmp(avl) ((avl)->cmp) -#define avl_count(avl)((avl)->count) -#define avl_height(avl) ((avl)->height) -#define avl_anchor(avl) (&(avl)->anchor) -#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)]) -#define avl_top(avl) (avlh_right(avl_anchor(avl))) -#define avl_head(avl) (avl_end((avl), AVL_LEFT)) -#define avl_tail(avl) (avl_end((avl), AVL_RIGHT)) +#define AVL_LEFT-1 +#define AVL_UP 0 +#define AVL_RIGHT1 +/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ +#define avl_opposite(type) (-(type)) +/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ +#define avl_type2index(type) ((type)+1) -#ifdef __cplusplus -extern "C" { -#endif +#define AVL_THR_LEFT (1 << avl_type2index(AVL_LEFT)) +#define AVL_THR_RIGHT (1 << avl_type2index(AVL_RIGHT)) -void avl_init(struct avl *avl, avl_search_t *search, avlh_cmp_t *cmp); +#define avlh_up(avl, holder) avlh_link((avl), (holder), AVL_UP) +#define avlh_left(avl, holder) avlh_link((avl), (holder), AVL_LEFT) +#define avlh_right(avl, holder)avlh_link((avl), (holder), AVL_RIGHT)
[Xenomai-git] Philippe Gerum : smokey: argument accessors using variables
Module: xenomai-3 Branch: next Commit: 4bf34c7757d539e76259a1b2c5218e597756d91c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4bf34c7757d539e76259a1b2c5218e597756d91c Author: Philippe GerumDate: Mon Apr 23 18:03:07 2018 +0200 smokey: argument accessors using variables --- include/smokey/smokey.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index 5fea66c..ffd91cf 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -105,6 +105,11 @@ struct smokey_test { #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) +#define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) +#define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) +#define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) + #define smokey_check_errno(__expr) \ ({ \ int __ret = (__expr); \ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/testing: add core heap test module
Module: xenomai-3 Branch: next Commit: f1382fa8534381a644a3b3162978a4c8fb2f1437 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f1382fa8534381a644a3b3162978a4c8fb2f1437 Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 drivers/testing: add core heap test module --- include/rtdm/uapi/testing.h| 41 ++- kernel/drivers/testing/Kconfig |6 + kernel/drivers/testing/Makefile|3 + kernel/drivers/testing/heapcheck.c | 515 4 files changed, 564 insertions(+), 1 deletion(-) diff --git a/include/rtdm/uapi/testing.h b/include/rtdm/uapi/testing.h index 06b8f1e..f8207b8 100644 --- a/include/rtdm/uapi/testing.h +++ b/include/rtdm/uapi/testing.h @@ -87,6 +87,37 @@ struct rttst_swtest_error { #define RTTST_RTDM_MAGIC_PRIMARY 0xfefbfefb #define RTTST_RTDM_MAGIC_SECONDARY 0xa5b9a5b9 +#define RTTST_HEAPCHECK_ZEROOVRD 1 +#define RTTST_HEAPCHECK_SHUFFLE2 +#define RTTST_HEAPCHECK_PATTERN4 +#define RTTST_HEAPCHECK_HOT8 + +struct rttst_heap_parms { + __u64 heap_size; + __u64 block_size; + int flags; + int nrstats; +}; + +struct rttst_heap_stats { + __u64 heap_size; + __u64 user_size; + __u64 block_size; + __s64 alloc_avg_ns; + __s64 alloc_max_ns; + __s64 free_avg_ns; + __s64 free_max_ns; + __u64 maximum_free; + __u64 largest_free; + int nrblocks; + int flags; +}; + +struct rttst_heap_stathdr { + int nrstats; + struct rttst_heap_stats *buf; +}; + #define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING /*! @@ -100,6 +131,8 @@ struct rttst_swtest_error { #define RTDM_SUBCLASS_SWITCHTEST 2 /** subclase name: "rtdm" */ #define RTDM_SUBCLASS_RTDMTEST 3 +/** subclase name: "heapcheck" */ +#define RTDM_SUBCLASS_HEAPCHECK4 /** @} */ /*! @@ -153,7 +186,13 @@ struct rttst_swtest_error { #define RTTST_RTIOC_RTDM_PING_SECONDARY \ _IOR(RTIOC_TYPE_TESTING, 0x43, __u32) - + +#define RTTST_RTIOC_HEAP_CHECK \ + _IOR(RTIOC_TYPE_TESTING, 0x44, struct rttst_heap_parms) + +#define RTTST_RTIOC_HEAP_STAT_COLLECT \ + _IOR(RTIOC_TYPE_TESTING, 0x45, int) + /** @} */ #endif /* !_RTDM_UAPI_TESTING_H */ diff --git a/kernel/drivers/testing/Kconfig b/kernel/drivers/testing/Kconfig index bb44abb..88c043c 100644 --- a/kernel/drivers/testing/Kconfig +++ b/kernel/drivers/testing/Kconfig @@ -14,6 +14,12 @@ config XENO_DRIVERS_SWITCHTEST Kernel-based driver for unit testing context switches and FPU switches. +config XENO_DRIVERS_HEAPCHECK + tristate "Memory allocator test driver" + default y + help + Kernel-based driver for testing Cobalt's memory allocator. + config XENO_DRIVERS_RTDMTEST depends on m tristate "RTDM unit tests driver" diff --git a/kernel/drivers/testing/Makefile b/kernel/drivers/testing/Makefile index 367a22e..09b0763 100644 --- a/kernel/drivers/testing/Makefile +++ b/kernel/drivers/testing/Makefile @@ -2,9 +2,12 @@ obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o obj-$(CONFIG_XENO_DRIVERS_RTDMTEST) += xeno_rtdmtest.o +obj-$(CONFIG_XENO_DRIVERS_HEAPCHECK) += xeno_heapcheck.o xeno_timerbench-y := timerbench.o xeno_switchtest-y := switchtest.o xeno_rtdmtest-y := rtdmtest.o + +xeno_heapcheck-y := heapcheck.o diff --git a/kernel/drivers/testing/heapcheck.c b/kernel/drivers/testing/heapcheck.c new file mode 100644 index 000..bed5a05 --- /dev/null +++ b/kernel/drivers/testing/heapcheck.c @@ -0,0 +1,515 @@ +/* + * Copyright (C) 2018 Philippe Gerum . + * + * Xenomai is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Xenomai is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xenomai; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define complain(__fmt, __args...) \ + printk(XENO_WARNING "heap check: " __fmt "\n", ##__args) + +static struct xnheap test_heap = { + .name = "test_heap" +}; + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + struct rttst_heap_stats stats; + struct runstats
[Xenomai-git] Philippe Gerum : testsuite/smokey: add core heap test
Module: xenomai-3 Branch: next Commit: 692d6b604004e12b89b3c0b8d9769ef470d1324f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=692d6b604004e12b89b3c0b8d9769ef470d1324f Author: Philippe GerumDate: Sat May 19 11:18:53 2018 +0200 testsuite/smokey: add core heap test --- configure.ac |1 + testsuite/smokey/Makefile.am |1 + testsuite/smokey/memcheck/memcheck.c | 247 +- testsuite/smokey/memcheck/memcheck.h | 22 ++- testsuite/smokey/memory-coreheap/Makefile.am |9 + testsuite/smokey/memory-coreheap/coreheap.c | 110 6 files changed, 267 insertions(+), 123 deletions(-) diff --git a/configure.ac b/configure.ac index b670206..6c94301 100644 --- a/configure.ac +++ b/configure.ac @@ -971,6 +971,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-coreheap/Makefile \ testsuite/smokey/memory-heapmem/Makefile \ testsuite/smokey/memory-tlsf/Makefile \ testsuite/smokey/memory-pshared/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index d7a71fe..601331e 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -16,6 +16,7 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-coreheap \ memory-heapmem \ memory-tlsf \ memcheck\ diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c index 7f97218..b10b30f 100644 --- a/testsuite/smokey/memcheck/memcheck.c +++ b/testsuite/smokey/memcheck/memcheck.c @@ -24,27 +24,45 @@ struct chunk { enum pattern pattern; }; -struct runstats { - size_t heap_size; - size_t user_size; - size_t block_size; - int nrblocks; - long alloc_avg_ns; - long alloc_max_ns; - long free_avg_ns; - long free_max_ns; - int flags; - double overhead; - double fragmentation; - struct runstats *next; -}; - -static struct runstats *statistics; +static struct memcheck_stat *statistics; static int nrstats; static int max_results = 4; +#ifdef CONFIG_XENO_COBALT + +#include + +static inline void breathe(int loops) +{ + struct timespec idle = { + .tv_sec = 0, + .tv_nsec = 30, + }; + + /* +* There is not rt throttling over Cobalt, so we may need to +* keep the host kernel breathing by napping during the test +* sequences. +*/ + if ((loops % 1000) == 0) + __RT(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + +static inline void harden(void) +{ + cobalt_thread_harden(); +} + +#else + +static inline void breathe(int loops) { } + +static inline void harden(void) { } + +#endif + static inline long diff_ts(struct timespec *left, struct timespec *right) { return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION @@ -69,6 +87,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) double u; for(j = nmemb; j > 0; j--) { + breathe(j); u = (double)random() / RAND_MAX; k = (unsigned int)(j * u) + 1; if (j == k) @@ -88,37 +107,39 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) static int sort_by_heap_size(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->heap_size, ls->heap_size); } static int sort_by_alloc_time(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->alloc_max_ns, ls->alloc_max_ns); } static int sort_by_free_time(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; return compare_values(rs->free_max_ns, ls->free_max_ns); } static int sort_by_frag(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; - return compare_values(rs->fragmentation, ls->fragmentation); + return compare_values(rs->maximum_free - rs->largest_free, + ls->maximum_free - ls->largest_free); } static int sort_by_overhead(const void *l, const void *r) { - const struct runstats *ls = l, *rs = r; + const struct memcheck_stat *ls = l, *rs = r; - return compare_values(rs->overhead, ls->overhead); + return compare_values(rs->heap_size - rs->user_size, + ls->heap_size - ls->user_size); } static
[Xenomai-git] Philippe Gerum : testsuite/smokey: memcheck: fix test heap sizes
Module: xenomai-3 Branch: next Commit: c99d3ecb4a4f7e74537dc40830a9cff026bae377 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c99d3ecb4a4f7e74537dc40830a9cff026bae377 Author: Philippe GerumDate: Tue May 15 15:29:44 2018 +0200 testsuite/smokey: memcheck: fix test heap sizes --- testsuite/smokey/memcheck/memcheck.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c index 3f18477..7f97218 100644 --- a/testsuite/smokey/memcheck/memcheck.c +++ b/testsuite/smokey/memcheck/memcheck.c @@ -776,7 +776,7 @@ int memcheck_run(struct memcheck_descriptor *md, for (heap_size = md->seq_min_heap_size; heap_size < md->seq_max_heap_size; heap_size <<= 1) { for (runs = 0; runs < md->random_rounds; runs++) { - block_size = (random() % heap_size) ?: 1; + block_size = (random() % (heap_size / 2)) ?: 1; ret = test_seq(md, heap_size, block_size, 0); if (ret) { smokey_trace("failed with %zuk heap, " @@ -846,7 +846,7 @@ int memcheck_run(struct memcheck_descriptor *md, * between loops. */ __RT(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); - block_size = (random() % (heap_size / 2)) ?: 1; + block_size = (random() % (md->pattern_heap_size / 2)) ?: 1; ret = test_seq(md, md->pattern_heap_size, block_size, test_flags(md, MEMCHECK_SHUFFLE|MEMCHECK_PATTERN)); if (ret) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks
Module: xenomai-3 Branch: next Commit: 899ad04df1ca3323eed3c2cd432ef4ad9363239c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=899ad04df1ca3323eed3c2cd432ef4ad9363239c Author: Philippe GerumDate: Tue May 15 18:24:02 2018 +0200 boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks --- lib/boilerplate/heapmem.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/boilerplate/heapmem.c b/lib/boilerplate/heapmem.c index f5b842d..5097d1c 100644 --- a/lib/boilerplate/heapmem.c +++ b/lib/boilerplate/heapmem.c @@ -426,9 +426,12 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size) log2size = HEAPMEM_MIN_LOG2; } else { log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size); - if (size & (size - 1)) - log2size++; - bsize = 1 << log2size; + if (log2size < HEAPMEM_PAGE_SHIFT) { + if (size & (size - 1)) + log2size++; + bsize = 1 << log2size; + } else + bsize = __align_to(size, HEAPMEM_PAGE_SIZE); } /* ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: next Commit: 3354a6255a69d2de950eae5691ac71c701ba3a99 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3354a6255a69d2de950eae5691ac71c701ba3a99 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index c0ef1df..b670206 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@ -176,7
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: next Commit: 25534016c780ee56a87610a0c269ae4a263a725c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=25534016c780ee56a87610a0c269ae4a263a725c Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 884 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 121 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1300 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ec2d7cb..c0ef1df 100644 --- a/configure.ac +++ b/configure.ac @@ -931,6 +931,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..3f18477 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,884 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() / RAND_MAX; +
[Xenomai-git] Philippe Gerum : cobalt/heap: add accessor to usage counter
Module: xenomai-3 Branch: next Commit: f126a8ca003431421451c694615bb8aea4992052 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f126a8ca003431421451c694615bb8aea4992052 Author: Philippe GerumDate: Sat May 19 15:04:06 2018 +0200 cobalt/heap: add accessor to usage counter --- include/cobalt/kernel/heap.h |6 ++ 1 file changed, 6 insertions(+) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index 8a1c6f6..09c982f 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -108,6 +108,12 @@ size_t xnheap_get_size(const struct xnheap *heap) } static inline +size_t xnheap_get_used(const struct xnheap *heap) +{ + return heap->used_size; +} + +static inline size_t xnheap_get_free(const struct xnheap *heap) { return heap->usable_size - heap->used_size; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: add heapmem allocator
Module: xenomai-3 Branch: next Commit: f24840a6f4b600544164687fb0da5bb50792b9f6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f24840a6f4b600544164687fb0da5bb50792b9f6 Author: Philippe GerumDate: Fri Apr 13 12:15:15 2018 +0200 boilerplate: add heapmem allocator This is the umpteenth incarnation of the McKusick allocator, aimed at replacing other allocators which have serious issues: - TLSF is fast but not that good when it comes to memory overhead with small sizes (i.e. < 512 bytes) on 64bit. - heapobj-pshared has decent overhead figures but may be insanely slow at deallocating blocks from large, hot heaps. - the Cobalt core allocator is even worse than heapobj-pshared in deallocating blocks, although the system heap should be generally small enough not to trigger the most pathological cases in practice, hopefully. Nevertheless, the performances are unacceptable. The original McKusick algorithm implements a quick fit allocation scheme, based on bucket management of ^2-sized chunks, which automatically switches to a page-based allocation method for blocks larger than twice the base page size. This variant maintains the free page list in AVL trees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a quick allocation bitmap to manage their blocks internally. The current implementation can replace TLSF for delivering process-local memory with similar performances but lesser overhead with small sizes. Most importantly, a kernel variant of HEAPMEM should replace the Cobalt core allocator. Likewise, heapobj-pshared which is beyond repair should be replaced with a process-shareable variant as well, assuming the average size and allocation patterns of real-time objects are similar in all contexts. --- include/boilerplate/Makefile.am |1 + include/boilerplate/heapmem.h | 155 + lib/boilerplate/Makefile.am |1 + lib/boilerplate/heapmem.c | 704 +++ 4 files changed, 861 insertions(+) diff --git a/include/boilerplate/Makefile.am b/include/boilerplate/Makefile.am index 4ed6a99..56f20bd 100644 --- a/include/boilerplate/Makefile.am +++ b/include/boilerplate/Makefile.am @@ -7,6 +7,7 @@ includesub_HEADERS =\ compiler.h \ debug.h \ hash.h \ + heapmem.h \ libc.h \ list.h \ lock.h \ diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h new file mode 100644 index 000..c4348b0 --- /dev/null +++ b/include/boilerplate/heapmem.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2018 Philippe Gerum . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef _BOILERPLATE_HEAPMEM_H +#define _BOILERPLATE_HEAPMEM_H + +#include +#include +#include +#include +#include +#include + +#define HEAPMEM_PAGE_SHIFT 9 /* 2^9 => 512 bytes */ +#define HEAPMEM_PAGE_SIZE (1UL << HEAPMEM_PAGE_SHIFT) +#define HEAPMEM_PAGE_MASK (~(HEAPMEM_PAGE_SIZE - 1)) +#define HEAPMEM_MIN_LOG2 4 /* 16 bytes */ +/* + * Use bucketed memory for sizes between 2^HEAPMEM_MIN_LOG2 and + * 2^(HEAPMEM_PAGE_SHIFT-1). + */ +#define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) +#define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) +/* Max size of an extent (2Gb). */ +#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Bits we need for encoding a page # */ +#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) + +/* Each page is represented by a page map entry. */ +#define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) + +struct heapmem_pgentry { + /* Linkage in bucket list. */ + unsigned int prev : HEAPMEM_PGENT_BITS; + unsigned int next : HEAPMEM_PGENT_BITS; + /* page_list or log2. */ + unsigned int type : 6; + /* +* We hold either a spatial map of busy blocks within the page +* for bucketed memory (up to 32 blocks per page), or the +* overall size of the multi-page block if entry.type == +* page_list. +*/ + union { + uint32_t map; + uint32_t bsize; + }; +}; + +/* + * A range descriptor is stored at the beginning of
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: add helper to return the total heap size
Module: xenomai-3 Branch: next Commit: 202dbd939fc94e125b1791edbb997bb29988f263 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=202dbd939fc94e125b1791edbb997bb29988f263 Author: Philippe GerumDate: Mon Apr 23 10:47:28 2018 +0200 copperplate/heapobj-pshared: add helper to return the total heap size --- include/copperplate/heapobj.h |2 ++ lib/copperplate/heapobj-pshared.c |6 ++ 2 files changed, 8 insertions(+) diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index 4cf947e..dc2a45d 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -304,6 +304,8 @@ size_t heapobj_validate(struct heapobj *hobj, size_t heapobj_inquire(struct heapobj *hobj); +size_t heapobj_get_size(struct heapobj *hobj); + int heapobj_bind_session(const char *session); void heapobj_unbind_session(void); diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index e08b033..6f1ca3a 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -1092,6 +1092,12 @@ size_t heapobj_inquire(struct heapobj *hobj) return heap->ubytes; } +size_t heapobj_get_size(struct heapobj *hobj) +{ + struct shared_heap *heap = __mptr(hobj->pool_ref); + return heap->total; +} + void *xnmalloc(size_t size) { return alloc_block(_heap.heap, size); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: move heap limit to ~4GB
Module: xenomai-3 Branch: next Commit: 02c857c9226232caefe17aac4d0e6da4ec039891 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=02c857c9226232caefe17aac4d0e6da4ec039891 Author: Philippe GerumDate: Sun May 13 17:17:06 2018 +0200 boilerplate/heapmem: move heap limit to ~4GB --- include/boilerplate/heapmem.h |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h index c4348b0..0ddd1ce 100644 --- a/include/boilerplate/heapmem.h +++ b/include/boilerplate/heapmem.h @@ -35,10 +35,10 @@ */ #define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) #define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) -/* Max size of an extent (2Gb). */ -#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Max size of an extent (4Gb - HEAPMEM_PAGE_SIZE). */ +#define HEAPMEM_MAX_EXTSZ (4294967295U - HEAPMEM_PAGE_SIZE + 1) /* Bits we need for encoding a page # */ -#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) +#define HEAPMEM_PGENT_BITS (32 - HEAPMEM_PAGE_SHIFT) /* Each page is represented by a page map entry. */ #define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: compiler: add more helpers and attribute tags
Module: xenomai-3 Branch: next Commit: 594a0adb34c3ac2fced973f202e4c39e33201c8c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=594a0adb34c3ac2fced973f202e4c39e33201c8c Author: Philippe GerumDate: Mon Apr 23 10:28:49 2018 +0200 boilerplate: compiler: add more helpers and attribute tags --- include/boilerplate/compiler.h| 18 ++ lib/copperplate/heapobj-pshared.c |6 -- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h index bcef7d4..f526eb2 100644 --- a/include/boilerplate/compiler.h +++ b/include/boilerplate/compiler.h @@ -46,6 +46,14 @@ #define __weak __attribute__((__weak__)) #endif +#ifndef __const +#define __const__attribute__((__const__)) +#endif + +#ifndef __pure +#define __pure __attribute__((__pure__)) +#endif + #ifndef __maybe_unused #define __maybe_unused __attribute__((__unused__)) #endif @@ -58,6 +66,16 @@ #define __deprecated __attribute__((__deprecated__)) #endif +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +#ifndef __alloc_size +#define __alloc_size(__args) __attribute__((__alloc_size__(__args))) +#endif + +#define __align_to(__size, __al) (((__size) + (__al) - 1) & (~((__al) - 1))) + #ifdef __cplusplus extern "C" { #endif diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index d4324df..e08b033 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -106,12 +106,6 @@ static struct heapobj main_pool; #define __shref(b, o) ((void *)((caddr_t)(b) + (o))) #define __shref_check(b, o)((o) ? __shref(b, o) : NULL) -static inline size_t __align_to(size_t size, size_t al) -{ - /* The alignment value must be a power of 2 */ - return ((size+al-1)&(~(al-1))); -} - static inline size_t get_pagemap_size(size_t h, memoff_t *bmapoff, int *bmapwords) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : smokey: add helper to retrieve size expr
Module: xenomai-3 Branch: next Commit: a9893e99a5b5f7087a8e4aeb646497e435ec20eb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a9893e99a5b5f7087a8e4aeb646497e435ec20eb Author: Philippe GerumDate: Mon Apr 23 18:29:46 2018 +0200 smokey: add helper to retrieve size expr --- include/smokey/smokey.h | 11 +++ lib/smokey/helpers.c| 22 ++ 2 files changed, 33 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index ffd91cf..185fd3a 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -49,6 +49,12 @@ .matched = 0, \ } +#define SMOKEY_SIZE(__name) { \ +.name = # __name, \ +.parser = smokey_size, \ +.matched = 0, \ +} + #define SMOKEY_ARGLIST(__args...) ((struct smokey_arg[]){ __args }) #define SMOKEY_NOARGS (((struct smokey_arg[]){ { .name = NULL } })) @@ -60,6 +66,7 @@ struct smokey_arg { union { int n_val; char *s_val; + size_t l_val; } u; int matched; }; @@ -104,11 +111,13 @@ struct smokey_test { #define SMOKEY_ARG_INT(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.n_val) #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define SMOKEY_ARG_SIZE(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.l_val) #define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) #define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) #define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) #define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) +#define smokey_arg_size(__t, __name) (smokey_lookup_arg(__t, __name)->u.l_val) #define smokey_check_errno(__expr) \ ({ \ @@ -216,6 +225,8 @@ int smokey_bool(const char *s, struct smokey_arg *arg); int smokey_string(const char *s, struct smokey_arg *arg); +int smokey_size(const char *s, struct smokey_arg *arg); + struct smokey_arg *smokey_lookup_arg(struct smokey_test *t, const char *arg); diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c index fd1fca3..6ee69ec 100644 --- a/lib/smokey/helpers.c +++ b/lib/smokey/helpers.c @@ -85,6 +85,28 @@ int smokey_string(const char *s, struct smokey_arg *arg) return ret; } +int smokey_size(const char *s, struct smokey_arg *arg) +{ + char *name, *p; + int ret; + + ret = sscanf(s, "%m[_a-z]=%m[^\n]", , ); + if (ret != 2) + return 0; + + ret = !strcmp(name, arg->name); + if (ret) { + arg->u.l_val = get_mem_size(p); + if (arg->u.l_val == 0) + ret = 0; + } + + free(p); + free(name); + + return ret; +} + int smokey_parse_args(struct smokey_test *t, int argc, char *const argv[]) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt: syscall: don't bark at internal syscalls
Module: xenomai-3 Branch: next Commit: b525c0ecc1b609cf69477d39e15c35e2227fd59a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b525c0ecc1b609cf69477d39e15c35e2227fd59a Author: Philippe GerumDate: Sat May 12 19:08:59 2018 +0200 cobalt: syscall: don't bark at internal syscalls Some architectures may define a secondary system call range for internal operations, fix the consistency check not to warn about them. --- .../cobalt/arch/arm/include/asm/xenomai/syscall.h | 22 .../arch/arm64/include/asm/xenomai/syscall.h | 18 +--- .../arch/blackfin/include/asm/xenomai/syscall.h| 18 +--- .../arch/powerpc/include/asm/xenomai/syscall.h | 18 +--- .../cobalt/arch/x86/include/asm/xenomai/syscall.h | 20 +++--- kernel/cobalt/posix/syscall.c |7 +++ 6 files changed, 61 insertions(+), 42 deletions(-) diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h index 92afe8d..1207136 100644 --- a/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h +++ b/kernel/cobalt/arch/arm/include/asm/xenomai/syscall.h @@ -33,6 +33,11 @@ #define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL) #endif +/* + * Cobalt syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7 + * containing the Xenomai syscall marker, Linux syscalls directly from + * ARM_r7 (may require the OABI tweak). + */ #define __xn_reg_sys(__regs) ((__regs)->ARM_ORIG_r0) /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */ #ifdef CONFIG_OABI_COMPAT @@ -46,16 +51,15 @@ #define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT) /* - * Returns the syscall number depending on the handling core. Cobalt - * syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7 - * containing the Xenomai syscall marker, Linux syscalls directly from - * ARM_r7 (may require the OABI tweak). + * Root syscall number with predicate (valid only if + * !__xn_syscall_p(__regs)). */ -static inline long __xn_get_syscall_nr(struct pt_regs *regs) -{ - return __xn_syscall_p(regs) ? __xn_reg_sys(regs) : __xn_abi_decode(regs); -} - +#define __xn_rootcall_p(__regs, __code) \ + ({ \ + *(__code) = __xn_abi_decode(__regs);\ + *(__code) < NR_syscalls || *(__code) >= __ARM_NR_BASE; \ + }) + #define __xn_reg_rval(__regs) ((__regs)->ARM_r0) #define __xn_reg_arg1(__regs) ((__regs)->ARM_r1) #define __xn_reg_arg2(__regs) ((__regs)->ARM_r2) diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h index 4b9b987..e345c9a 100644 --- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h +++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h @@ -28,6 +28,10 @@ #include #include +/* + * Cobalt and Linux syscall numbers can be fetched from syscallno, + * masking out the __COBALT_SYSCALL_BIT marker. + */ #define __xn_reg_sys(__regs) ((unsigned long)(__regs)->syscallno) #define __xn_syscall_p(regs) ((__xn_reg_sys(regs) & __COBALT_SYSCALL_BIT) != 0) #define __xn_syscall(__regs) ((unsigned long)(__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)) @@ -42,14 +46,14 @@ #define __xn_reg_sp(__regs)((__regs)->sp) /* - * Returns the syscall number depending on the handling core. Cobalt - * and Linux syscall numbers can be fetched from syscallno, masking - * out the __COBALT_SYSCALL_BIT marker. + * Root syscall number with predicate (valid only if + * !__xn_syscall_p(__regs)). */ -static inline long __xn_get_syscall_nr(struct pt_regs *regs) -{ - return __xn_syscall(regs); -} +#define __xn_rootcall_p(__regs, __code)\ + ({ \ + *(__code) = __xn_syscall(__regs); \ + *(__code) < NR_syscalls;\ + }) static inline void __xn_error_return(struct pt_regs *regs, int v) { diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h b/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h index a62fa49..3e63f29 100644 --- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h +++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/syscall.h @@ -23,6 +23,10 @@ #include #include +/* + * Cobalt and Linux syscall numbers can be fetched from P0, masking + * out the __COBALT_SYSCALL_BIT marker. + */ #define __xn_reg_sys(__regs) ((__regs)->orig_p0) #define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT) #define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT) @@ -35,14 +39,14 @@ #define __xn_reg_arg5(__regs) ((__regs)->r4) /* - * Returns the syscall number depending on the
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fd9e8604482f226761f812054ffb48beb1daaf58 Author: Jan KiszkaDate: Wed May 2 18:33:00 2018 +0200 testsuite/smokey: Add cond + pp-mutex test This stresses the case of fast-path mutex acquire plus pthread_cond_wait with that mutex, which currently triggers a bug in xnsynch_release. Along this, drop the HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL conditional - libboilerplate takes care of that. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d145e79cbda7447e247735f8eca67b5bfc0f0153 Author: Jan Kiszka Date: Wed May 2 18:34:00 2018 +0200 cobalt/synch: Do not drop PP on xnsynch_release if it wasn't committed We must not try to drop the prio ceiling in the kernel if it wasn't committed yet. That could easily happen when using a prio-ceiling mutex to wait on a cond-var. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0b7f8e54d6e8f23a5a3d7300fb39f52bd0fe0ef1 Author: Norbert Lange Date: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0bd48a73d3b463b7f3d5918b149e12167c7b738e Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5c63456f4751de8f6324edd6064618a677bb3eac Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 testsuite/smokey: Add handover test for prio-ceiling mutexes This triggers a bug in the PP implementation. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a97ec20e56d69ef40711f88f7e69702e93e74d6 Author: Philippe Gerum Date: Fri Mar 30 15:01:40 2018 +0200 net/via-rhine: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d96921fb17a95d4db478950ebbf90f623df17277 Author: Philippe Gerum Date: Fri Mar 30 15:01:30 2018 +0200 net/tulip: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8d45315776f79066dc1b9861013f3e101f85eb03 Author: Philippe Gerum Date: Fri Mar 30 15:01:23 2018 +0200 net/r8169: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be4a4a2bf831a6e1531d14881d7c9bb06815e5de Author: Philippe Gerum Date: Fri Mar 30 15:01:10 2018 +0200 net/pcnet32: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=589b8d22e5ca41daa5d5d9a545c8fcc06018e75f Author: Philippe Gerum Date: Fri Mar 30 15:01:02 2018 +0200 net/natsemi: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7edf5adf5191651fc70e08a58ecc9730c7b0 Author: Philippe Gerum Date: Fri Mar 30 15:00:56 2018 +0200 net/macb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6b9033d3d62c430427373d87883f9b824f8c3aa6 Author: Philippe Gerum Date: Fri Mar 30 15:00:48 2018 +0200 net/fec: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5fa0e35d9e2beeacbc71ffa075d3a3619aabe73f Author: Philippe Gerum Date: Fri Mar 30 15:00:39 2018 +0200 net/eepro100: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e898956f06991f703b8b5649557a6c64e28a82cb Author: Philippe Gerum Date: Fri Mar 30 15:00:26 2018 +0200 net/e1000: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=407f82f98374766b10eaba7c59abc19e9563aa51 Author: Philippe Gerum Date: Fri Mar 30 15:00:02 2018 +0200 net/at91: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=183a38a448dd85265fc8973599d1d03e6715019b Author: Philippe Gerum Date: Fri Mar 30 14:59:51 2018 +0200 net/8139too: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7367b04fa5ab05ee6420bebcc1732dee4b0c627c Author: Philippe Gerum
[Xenomai-git] New commits on branch wip/heapmem
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a651f0ccce8eb10a36edceb60d69552cd08d1a0e Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 128 8192 0 1 2 8 1024k 1665536 0 0 6 7 +shuffle +realloc 1024k 3232768 0 0 8 6 512k 3216384 0 0 5 6 +realloc ... (364 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 2 (us) average alloc time: 1 (us) average free time: 1 (us) [SEQUENTIAL ALLOC->FREE, RANDOM BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 512k 17k 28 1 1 8 2 +shuffle 512k 45k 11 1 1 7 2 1024k 2432768 0 0 7 6 +shuffle 128k 820 128 1 1 6 2 +shuffle ... (32764 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k3k 292 1 1 1 8 +shuffle 256k 174 1024 1 1 1 6 +shuffle 1024k 2432768 0 0 7 6 +shuffle 32k 12k 2 2 3 1 5 ... (32764 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 1 (us) average alloc time: 1 (us) average free time: 1 (us) [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=77d4fa2c9f93394bd935e93f8e29ea6d9a7420b5 Author: Philippe Gerum Date: Tue May 15 18:24:02 2018 +0200 boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b0afd6dcd67e4038f25ad7f2c9e3ea4fd3a268a9 Author: Philippe Gerum Date: Tue May 15 15:29:44 2018 +0200 testsuite/smokey: memcheck: fix test heap sizes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=434d42036a852ea2171a89a55b197dfc98d4b0f5 Author: Philippe Gerum Date: Sun May 13 19:00:36 2018 +0200 drivers/ipc: align pool memory on native page size URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b63991a72eb3fd1cf7bea203a4dda4daa10c80c0 Author: Philippe Gerum Date: Sun May 13 17:17:06 2018 +0200 boilerplate/heapmem: move heap limit to ~4GB URL:
[Xenomai-git] Philippe Gerum : smokey: add helper to retrieve size expr
Module: xenomai-3 Branch: wip/heapmem Commit: 056f0174f341033ab1523314ed21a2facdc5a90f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=056f0174f341033ab1523314ed21a2facdc5a90f Author: Philippe GerumDate: Mon Apr 23 18:29:46 2018 +0200 smokey: add helper to retrieve size expr --- include/smokey/smokey.h | 11 +++ lib/smokey/helpers.c| 22 ++ 2 files changed, 33 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index ffd91cf..185fd3a 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -49,6 +49,12 @@ .matched = 0, \ } +#define SMOKEY_SIZE(__name) { \ +.name = # __name, \ +.parser = smokey_size, \ +.matched = 0, \ +} + #define SMOKEY_ARGLIST(__args...) ((struct smokey_arg[]){ __args }) #define SMOKEY_NOARGS (((struct smokey_arg[]){ { .name = NULL } })) @@ -60,6 +66,7 @@ struct smokey_arg { union { int n_val; char *s_val; + size_t l_val; } u; int matched; }; @@ -104,11 +111,13 @@ struct smokey_test { #define SMOKEY_ARG_INT(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.n_val) #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define SMOKEY_ARG_SIZE(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.l_val) #define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) #define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) #define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) #define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) +#define smokey_arg_size(__t, __name) (smokey_lookup_arg(__t, __name)->u.l_val) #define smokey_check_errno(__expr) \ ({ \ @@ -216,6 +225,8 @@ int smokey_bool(const char *s, struct smokey_arg *arg); int smokey_string(const char *s, struct smokey_arg *arg); +int smokey_size(const char *s, struct smokey_arg *arg); + struct smokey_arg *smokey_lookup_arg(struct smokey_test *t, const char *arg); diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c index fd1fca3..6ee69ec 100644 --- a/lib/smokey/helpers.c +++ b/lib/smokey/helpers.c @@ -85,6 +85,28 @@ int smokey_string(const char *s, struct smokey_arg *arg) return ret; } +int smokey_size(const char *s, struct smokey_arg *arg) +{ + char *name, *p; + int ret; + + ret = sscanf(s, "%m[_a-z]=%m[^\n]", , ); + if (ret != 2) + return 0; + + ret = !strcmp(name, arg->name); + if (ret) { + arg->u.l_val = get_mem_size(p); + if (arg->u.l_val == 0) + ret = 0; + } + + free(p); + free(name); + + return ret; +} + int smokey_parse_args(struct smokey_test *t, int argc, char *const argv[]) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/heap: rebase on HEAPMEM algorithm
Module: xenomai-3 Branch: wip/heapmem Commit: edde4308feb872e4885ff50329c2c9beb56757f4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=edde4308feb872e4885ff50329c2c9beb56757f4 Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 128 8192 0 1 2 8 1024k 1665536 0 0 6 7 +shuffle +realloc 1024k 3232768 0 0 8 6 512k 3216384 0 0 5 6 +realloc ... (364 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 2 (us) average alloc time: 1 (us) average free time: 1 (us) [SEQUENTIAL ALLOC->FREE, RANDOM BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 512k 17k 28 1 1 8 2 +shuffle 512k 45k 11 1 1 7 2 1024k 2432768 0 0 7 6 +shuffle 128k 820 128 1 1 6 2 +shuffle ... (32764 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k3k 292 1 1 1 8 +shuffle 256k 174 1024 1 1 1 6 +shuffle 1024k 2432768 0 0 7 6 +shuffle 32k 12k 2 2 3 1 5 ... (32764 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 1 (us) average alloc time: 1 (us) average free time: 1 (us) [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html --- include/cobalt/kernel/heap.h | 168 kernel/cobalt/Kconfig|7 + kernel/cobalt/heap.c | 979 +- 3 files changed, 662 insertions(+), 492 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index d89f25d..4f95c80 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -20,6 +20,7 @@ #define _COBALT_KERNEL_HEAP_H #include +#include #include #include #include @@ -28,66 +29,66 @@ /** * @addtogroup cobalt_core_heap * @{ - * - * @par Implementation constraints - * - * - Minimum page size is 2 ** XNHEAP_MINLOG2 (must be large enough to - * hold a pointer). - * - * - Maximum page size is 2 ** XNHEAP_MAXLOG2. - * - * - Requested block size is rounded up to XNHEAP_MINLOG2. - * - * - Requested block size larger than 2 times the XNHEAP_PAGESZ is - * rounded up to the next page boundary and obtained from the free - * page list. So we need a bucket for each power of two between - * XNHEAP_MINLOG2 and XNHEAP_MAXLOG2 inclusive, plus one to honor - * requests ranging from the maximum page size to twice this size. */ -#define XNHEAP_PAGESZPAGE_SIZE -#define XNHEAP_MINLOG23 -#define XNHEAP_MAXLOG222 /* Holds pagemap.bcount blocks */ -#define XNHEAP_MINALLOCSZ (1 << XNHEAP_MINLOG2) -#define XNHEAP_MINALIGNSZ (1 << 4) /* i.e. 16 bytes */
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: add helper to return the total heap size
Module: xenomai-3 Branch: wip/heapmem Commit: 9ce3b7413d520e52daacd70574ed9260e7d4cabb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9ce3b7413d520e52daacd70574ed9260e7d4cabb Author: Philippe GerumDate: Mon Apr 23 10:47:28 2018 +0200 copperplate/heapobj-pshared: add helper to return the total heap size --- include/copperplate/heapobj.h |2 ++ lib/copperplate/heapobj-pshared.c |6 ++ 2 files changed, 8 insertions(+) diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index 4cf947e..dc2a45d 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -304,6 +304,8 @@ size_t heapobj_validate(struct heapobj *hobj, size_t heapobj_inquire(struct heapobj *hobj); +size_t heapobj_get_size(struct heapobj *hobj); + int heapobj_bind_session(const char *session); void heapobj_unbind_session(void); diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index e08b033..6f1ca3a 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -1092,6 +1092,12 @@ size_t heapobj_inquire(struct heapobj *hobj) return heap->ubytes; } +size_t heapobj_get_size(struct heapobj *hobj) +{ + struct shared_heap *heap = __mptr(hobj->pool_ref); + return heap->total; +} + void *xnmalloc(size_t size) { return alloc_block(_heap.heap, size); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/smokey: memcheck: fix test heap sizes
Module: xenomai-3 Branch: wip/heapmem Commit: feaa056501a5d911174838519bf7432b0d90 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=feaa056501a5d911174838519bf7432b0d90 Author: Philippe GerumDate: Tue May 15 15:29:44 2018 +0200 testsuite/smokey: memcheck: fix test heap sizes --- testsuite/smokey/memcheck/memcheck.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c index 3f18477..7f97218 100644 --- a/testsuite/smokey/memcheck/memcheck.c +++ b/testsuite/smokey/memcheck/memcheck.c @@ -776,7 +776,7 @@ int memcheck_run(struct memcheck_descriptor *md, for (heap_size = md->seq_min_heap_size; heap_size < md->seq_max_heap_size; heap_size <<= 1) { for (runs = 0; runs < md->random_rounds; runs++) { - block_size = (random() % heap_size) ?: 1; + block_size = (random() % (heap_size / 2)) ?: 1; ret = test_seq(md, heap_size, block_size, 0); if (ret) { smokey_trace("failed with %zuk heap, " @@ -846,7 +846,7 @@ int memcheck_run(struct memcheck_descriptor *md, * between loops. */ __RT(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); - block_size = (random() % (heap_size / 2)) ?: 1; + block_size = (random() % (md->pattern_heap_size / 2)) ?: 1; ret = test_seq(md, md->pattern_heap_size, block_size, test_flags(md, MEMCHECK_SHUFFLE|MEMCHECK_PATTERN)); if (ret) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: add heapmem allocator
Module: xenomai-3 Branch: wip/heapmem Commit: 8d01ea11657cbdd88b6cab4c6a0238e9e9dc992c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8d01ea11657cbdd88b6cab4c6a0238e9e9dc992c Author: Philippe GerumDate: Fri Apr 13 12:15:15 2018 +0200 boilerplate: add heapmem allocator This is the umpteenth incarnation of the McKusick allocator, aimed at replacing other allocators which have serious issues: - TLSF is fast but not that good when it comes to memory overhead with small sizes (i.e. < 512 bytes) on 64bit. - heapobj-pshared has decent overhead figures but may be insanely slow at deallocating blocks from large, hot heaps. - the Cobalt core allocator is even worse than heapobj-pshared in deallocating blocks, although the system heap should be generally small enough not to trigger the most pathological cases in practice, hopefully. Nevertheless, the performances are unacceptable. The original McKusick algorithm implements a quick fit allocation scheme, based on bucket management of ^2-sized chunks, which automatically switches to a page-based allocation method for blocks larger than twice the base page size. This variant maintains the free page list in AVL trees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a quick allocation bitmap to manage their blocks internally. The current implementation can replace TLSF for delivering process-local memory with similar performances but lesser overhead with small sizes. Most importantly, a kernel variant of HEAPMEM should replace the Cobalt core allocator. Likewise, heapobj-pshared which is beyond repair should be replaced with a process-shareable variant as well, assuming the average size and allocation patterns of real-time objects are similar in all contexts. --- include/boilerplate/Makefile.am |1 + include/boilerplate/heapmem.h | 155 + lib/boilerplate/Makefile.am |1 + lib/boilerplate/heapmem.c | 704 +++ 4 files changed, 861 insertions(+) diff --git a/include/boilerplate/Makefile.am b/include/boilerplate/Makefile.am index 4ed6a99..56f20bd 100644 --- a/include/boilerplate/Makefile.am +++ b/include/boilerplate/Makefile.am @@ -7,6 +7,7 @@ includesub_HEADERS =\ compiler.h \ debug.h \ hash.h \ + heapmem.h \ libc.h \ list.h \ lock.h \ diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h new file mode 100644 index 000..c4348b0 --- /dev/null +++ b/include/boilerplate/heapmem.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2018 Philippe Gerum . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef _BOILERPLATE_HEAPMEM_H +#define _BOILERPLATE_HEAPMEM_H + +#include +#include +#include +#include +#include +#include + +#define HEAPMEM_PAGE_SHIFT 9 /* 2^9 => 512 bytes */ +#define HEAPMEM_PAGE_SIZE (1UL << HEAPMEM_PAGE_SHIFT) +#define HEAPMEM_PAGE_MASK (~(HEAPMEM_PAGE_SIZE - 1)) +#define HEAPMEM_MIN_LOG2 4 /* 16 bytes */ +/* + * Use bucketed memory for sizes between 2^HEAPMEM_MIN_LOG2 and + * 2^(HEAPMEM_PAGE_SHIFT-1). + */ +#define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) +#define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) +/* Max size of an extent (2Gb). */ +#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Bits we need for encoding a page # */ +#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) + +/* Each page is represented by a page map entry. */ +#define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) + +struct heapmem_pgentry { + /* Linkage in bucket list. */ + unsigned int prev : HEAPMEM_PGENT_BITS; + unsigned int next : HEAPMEM_PGENT_BITS; + /* page_list or log2. */ + unsigned int type : 6; + /* +* We hold either a spatial map of busy blocks within the page +* for bucketed memory (up to 32 blocks per page), or the +* overall size of the multi-page block if entry.type == +* page_list. +*/ + union { + uint32_t map; + uint32_t bsize; + }; +}; + +/* + * A range descriptor is stored at the
[Xenomai-git] Philippe Gerum : boilerplate: compiler: add more helpers and attribute tags
Module: xenomai-3 Branch: wip/heapmem Commit: c0662ac69fbb02b29b744059ea84cc493754d7b2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c0662ac69fbb02b29b744059ea84cc493754d7b2 Author: Philippe GerumDate: Mon Apr 23 10:28:49 2018 +0200 boilerplate: compiler: add more helpers and attribute tags --- include/boilerplate/compiler.h| 18 ++ lib/copperplate/heapobj-pshared.c |6 -- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h index bcef7d4..f526eb2 100644 --- a/include/boilerplate/compiler.h +++ b/include/boilerplate/compiler.h @@ -46,6 +46,14 @@ #define __weak __attribute__((__weak__)) #endif +#ifndef __const +#define __const__attribute__((__const__)) +#endif + +#ifndef __pure +#define __pure __attribute__((__pure__)) +#endif + #ifndef __maybe_unused #define __maybe_unused __attribute__((__unused__)) #endif @@ -58,6 +66,16 @@ #define __deprecated __attribute__((__deprecated__)) #endif +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +#ifndef __alloc_size +#define __alloc_size(__args) __attribute__((__alloc_size__(__args))) +#endif + +#define __align_to(__size, __al) (((__size) + (__al) - 1) & (~((__al) - 1))) + #ifdef __cplusplus extern "C" { #endif diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index d4324df..e08b033 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -106,12 +106,6 @@ static struct heapobj main_pool; #define __shref(b, o) ((void *)((caddr_t)(b) + (o))) #define __shref_check(b, o)((o) ? __shref(b, o) : NULL) -static inline size_t __align_to(size_t size, size_t al) -{ - /* The alignment value must be a power of 2 */ - return ((size+al-1)&(~(al-1))); -} - static inline size_t get_pagemap_size(size_t h, memoff_t *bmapoff, int *bmapwords) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: 9cf7116e796d6d29d42c67a8231dbddc889ccf41 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9cf7116e796d6d29d42c67a8231dbddc889ccf41 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index c0ef1df..b670206 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks
Module: xenomai-3 Branch: wip/heapmem Commit: cc4a1bdbb35f9ea81de6fba84a774284c3a98bc0 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cc4a1bdbb35f9ea81de6fba84a774284c3a98bc0 Author: Philippe GerumDate: Tue May 15 18:24:02 2018 +0200 boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks --- lib/boilerplate/heapmem.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/boilerplate/heapmem.c b/lib/boilerplate/heapmem.c index f5b842d..5097d1c 100644 --- a/lib/boilerplate/heapmem.c +++ b/lib/boilerplate/heapmem.c @@ -426,9 +426,12 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size) log2size = HEAPMEM_MIN_LOG2; } else { log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size); - if (size & (size - 1)) - log2size++; - bsize = 1 << log2size; + if (log2size < HEAPMEM_PAGE_SHIFT) { + if (size & (size - 1)) + log2size++; + bsize = 1 << log2size; + } else + bsize = __align_to(size, HEAPMEM_PAGE_SIZE); } /* ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/ipc: align pool memory on native page size
Module: xenomai-3 Branch: wip/heapmem Commit: c1e8aa62e38700845c99d9b2d7e31867524ecc2c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c1e8aa62e38700845c99d9b2d7e31867524ecc2c Author: Philippe GerumDate: Sun May 13 19:00:36 2018 +0200 drivers/ipc: align pool memory on native page size --- kernel/drivers/ipc/iddp.c |2 +- kernel/drivers/ipc/xddp.c |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c index 854a4b6..2a80eba 100644 --- a/kernel/drivers/ipc/iddp.c +++ b/kernel/drivers/ipc/iddp.c @@ -569,7 +569,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd, */ poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); + poolsz = PAGE_ALIGN(poolsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c index 95bee57..57275d0 100644 --- a/kernel/drivers/ipc/xddp.c +++ b/kernel/drivers/ipc/xddp.c @@ -691,8 +691,8 @@ static int __xddp_bind_socket(struct rtipc_private *priv, poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); - poolsz += xnheap_rounded_size(sk->reqbufsz); + poolsz = PAGE_ALIGN(poolsz); + poolsz += PAGE_ALIGN(sk->reqbufsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: move heap limit to ~4GB
Module: xenomai-3 Branch: wip/heapmem Commit: da8c788699a8e174c3709e57a5de88ae45944740 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=da8c788699a8e174c3709e57a5de88ae45944740 Author: Philippe GerumDate: Sun May 13 17:17:06 2018 +0200 boilerplate/heapmem: move heap limit to ~4GB --- include/boilerplate/heapmem.h |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h index c4348b0..0ddd1ce 100644 --- a/include/boilerplate/heapmem.h +++ b/include/boilerplate/heapmem.h @@ -35,10 +35,10 @@ */ #define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) #define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) -/* Max size of an extent (2Gb). */ -#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Max size of an extent (4Gb - HEAPMEM_PAGE_SIZE). */ +#define HEAPMEM_MAX_EXTSZ (4294967295U - HEAPMEM_PAGE_SIZE + 1) /* Bits we need for encoding a page # */ -#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) +#define HEAPMEM_PGENT_BITS (32 - HEAPMEM_PAGE_SHIFT) /* Each page is represented by a page map entry. */ #define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : boilerplate/avl: merge pshared support for AVL trees
Module: xenomai-3 Branch: wip/heapmem Commit: 8ae78f22f49024090218d55487db85e842a9f877 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8ae78f22f49024090218d55487db85e842a9f877 Author: Gilles ChanteperdrixDate: Tue Jul 12 20:29:22 2016 +0200 boilerplate/avl: merge pshared support for AVL trees Make the AVL tree usable in shared memory when AVL_SHARED is defined at build time, switching to offset-based memory references. Gilles published this code in July 2016 as part of his personal toolkit for hobby projects aka 'libchutils'. --- include/boilerplate/avl.h | 472 -- lib/boilerplate/avl.c | 497 ++--- 2 files changed, 697 insertions(+), 272 deletions(-) diff --git a/include/boilerplate/avl.h b/include/boilerplate/avl.h index 1aa84bf..34fb23a 100644 --- a/include/boilerplate/avl.h +++ b/include/boilerplate/avl.h @@ -23,276 +23,444 @@ #ifndef _BOILERPLATE_AVL_H #define _BOILERPLATE_AVL_H -#include +#include +#include struct avlh { - unsigned int thr: 3; +#define AVLH_APP_BITS 28 + unsigned int flags: AVLH_APP_BITS; int type: 2; - int balance :2; - unsigned int flags :25; /* Application-specific */ - struct avlh *link[3]; + int balance: 2; + union { + ptrdiff_t offset; + struct avlh *ptr; + } link[3]; }; -/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0 - for "up" is just here for orthogonality... and avoid wasting 4 bytes or - having to use a union in struct avlh. */ -#define AVL_LEFT -1 -#define AVL_UP0 -#define AVL_RIGHT 1 -/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ -#define avl_opposite(type) (-(type)) -/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */ -#define avl_type2sign(type) (type) -/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ -#define avl_type2index(type) ((type)+1) -/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */ -#define avl_sign2type(sign) (sign) - -#define AVL_THR_LEFT (1< thr |= 1 << avl_type2index(side)) -#define avlh_thr_clr(holder, side) ((holder)->thr &= ~(1 << avl_type2index(side))) -#define avlh_thr_tst(holder, side) ((holder)->thr & (1 << avl_type2index(side))) -#define avlh_link(holder, dir) ((holder)->link[avl_type2index(dir)]) -#define avlh_up(holder)avlh_link((holder), AVL_UP) -#define avlh_left(holder) avlh_link((holder), AVL_LEFT) -#define avlh_right(holder) avlh_link((holder), AVL_RIGHT) -#define avlh_parent_link(holder) (avlh_link(avlh_up(holder), (holder)->type)) - struct avl; -typedef struct avlh *avl_search_t(const struct avl *, const struct avlh *, int *); - +/* + * Comparison function: should return -1 if left is less than right, 0 + * if they are equal and 1 if left is greather than right. You can use + * the avl_sign function which will convert a difference to -1, 0, + * 1. Beware of overflow however. You can also use avl_cmp_sign() + * which should not have any such problems. + */ typedef int avlh_cmp_t(const struct avlh *const, const struct avlh *const); +typedef struct avlh * +avl_search_t(const struct avl *, const struct avlh *, int *, int); + +typedef int avlh_prn_t(char *, size_t, const struct avlh *const); + struct avl { struct avlh anchor; avl_search_t *search; avlh_cmp_t *cmp; - struct avlh *end[3]; + union { + ptrdiff_t offset; + struct avlh *ptr; + } end[3]; unsigned int count; unsigned int height; }; -#define avl_searchfn(avl) ((avl)->search) -#define avl_cmp(avl) ((avl)->cmp) -#define avl_count(avl)((avl)->count) -#define avl_height(avl) ((avl)->height) -#define avl_anchor(avl) (&(avl)->anchor) -#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)]) -#define avl_top(avl) (avlh_right(avl_anchor(avl))) -#define avl_head(avl) (avl_end((avl), AVL_LEFT)) -#define avl_tail(avl) (avl_end((avl), AVL_RIGHT)) +#define AVL_LEFT-1 +#define AVL_UP 0 +#define AVL_RIGHT1 +/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ +#define avl_opposite(type) (-(type)) +/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ +#define avl_type2index(type) ((type)+1) -#ifdef __cplusplus -extern "C" { -#endif +#define AVL_THR_LEFT (1 << avl_type2index(AVL_LEFT)) +#define AVL_THR_RIGHT (1 << avl_type2index(AVL_RIGHT)) -void avl_init(struct avl *avl, avl_search_t *search, avlh_cmp_t *cmp); +#define avlh_up(avl, holder) avlh_link((avl), (holder), AVL_UP) +#define avlh_left(avl, holder) avlh_link((avl), (holder), AVL_LEFT) +#define avlh_right(avl, holder)avlh_link((avl), (holder),
[Xenomai-git] Philippe Gerum : smokey: argument accessors using variables
Module: xenomai-3 Branch: wip/heapmem Commit: dc3347e4054d0facf34675a27dc315c953d42869 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dc3347e4054d0facf34675a27dc315c953d42869 Author: Philippe GerumDate: Mon Apr 23 18:03:07 2018 +0200 smokey: argument accessors using variables --- include/smokey/smokey.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index 5fea66c..ffd91cf 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -105,6 +105,11 @@ struct smokey_test { #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) +#define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) +#define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) +#define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) + #define smokey_check_errno(__expr) \ ({ \ int __ret = (__expr); \ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : testsuite/smokey: Add cond + pp-mutex test
Module: xenomai-3 Branch: wip/heapmem Commit: 410a4cc1109ba4e0d05b7ece7b4a5210287e1183 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=410a4cc1109ba4e0d05b7ece7b4a5210287e1183 Author: Jan KiszkaDate: Wed May 2 18:33:00 2018 +0200 testsuite/smokey: Add cond + pp-mutex test This stresses the case of fast-path mutex acquire plus pthread_cond_wait with that mutex, which currently triggers a bug in xnsynch_release. Along this, drop the HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL conditional - libboilerplate takes care of that. Signed-off-by: Jan Kiszka --- testsuite/smokey/posix-cond/posix-cond.c | 96 ++ 1 file changed, 72 insertions(+), 24 deletions(-) diff --git a/testsuite/smokey/posix-cond/posix-cond.c b/testsuite/smokey/posix-cond/posix-cond.c index 6c9a458..153c645 100644 --- a/testsuite/smokey/posix-cond/posix-cond.c +++ b/testsuite/smokey/posix-cond/posix-cond.c @@ -42,27 +42,21 @@ static inline unsigned long long timer_tsc2ns(unsigned long long tsc) return clockobj_tsc_to_ns(tsc); } -static int mutex_init(pthread_mutex_t *mutex, int type, int pi) +static int mutex_init(pthread_mutex_t *mutex, int type, int proto) { pthread_mutexattr_t mattr; int err; pthread_mutexattr_init(); pthread_mutexattr_settype(, type); -#ifdef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL - if (pi != 0) - pthread_mutexattr_setprotocol(, PTHREAD_PRIO_INHERIT); - - err = pthread_mutex_init(mutex, ); -#else - if (pi != 0) { - err = ENOSYS; + err = pthread_mutexattr_setprotocol(, proto); + if (err) goto out; - } - err = pthread_mutex_init(mutex, ); + if (proto == PTHREAD_PRIO_PROTECT) + pthread_mutexattr_setprioceiling(, 3); + err = pthread_mutex_init(mutex, ); out: -#endif pthread_mutexattr_destroy(); return -err; @@ -217,7 +211,8 @@ static void autoinit_simple_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", thread_spawn(_signaler_tid, 2, cond_signaler, ), 0); @@ -246,7 +241,8 @@ static void simple_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", @@ -271,7 +267,8 @@ static void relative_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); @@ -294,7 +291,8 @@ static void autoinit_absolute_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("mutex_lock", mutex_lock(), 0); start = timer_get_tsc(); @@ -316,7 +314,8 @@ static void absolute_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 1), 0); check("mutex_lock", mutex_lock(), 0); @@ -373,7 +372,8 @@ static void sig_norestart_condwait(void) smokey_trace("%s", __func__); check_unix("sigaction", sigaction(SIGRTMIN, , NULL), 0); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", @@ -411,7 +411,8 @@ static void sig_restart_condwait(void) smokey_trace("%s", __func__); check_unix("sigaction", sigaction(SIGRTMIN, , NULL), 0); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn",
[Xenomai-git] Philippe Gerum : cobalt/heap: rebase on HEAPMEM algorithm
Module: xenomai-3 Branch: wip/heapmem Commit: 55b21ebe8a44f75f74c0a3a9e885fd3096d8327c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=55b21ebe8a44f75f74c0a3a9e885fd3096d8327c Author: Philippe GerumDate: Sun May 13 19:00:50 2018 +0200 cobalt/heap: rebase on HEAPMEM algorithm Address the issue mentioned in [1] regarding the core (xnheap) allocator, using a variant of the McKusick scheme significantly improving the performance figures. As a by-product of this overhaul, the core allocator can now manage heaps up to (4GB - PAGE_SIZE). The performance report log obtained by testing on imx6qp is as follows: == memcheck started seq_heap_size=2048k random_alloc_rounds=1024 pattern_heap_size=128k pattern_check_rounds=128 [SEQUENTIAL ALLOC->FREE, ^2 BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 3232768 0 0 8 6 1024k 3232768 0 0 7 2 +shuffle +realloc 1024k 1665536 0 0 7 2 +realloc 1024k 1665536 0 0 6 7 +shuffle +realloc ... (364 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k 128 8192 0 1 2 8 1024k 1665536 0 0 6 7 +shuffle +realloc 1024k 3232768 0 0 8 6 512k 3216384 0 0 5 6 +realloc ... (364 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 2 (us) average alloc time: 1 (us) average free time: 1 (us) [SEQUENTIAL ALLOC->FREE, RANDOM BLOCK SIZES] ON 'xnheap' HEAPSZ test heap size BLOCKSZ tested block size NRBLKS number of blocks allocatable in heap AVG-A average time to allocate block (us) AVG-F average time to free block (us) MAX-A max time to allocate block (us) MAX-F max time to free block (us) FLAGS +shuffle: randomized free +realloc: measure after initial alloc/free pass (hot heap) sorted by: max alloc time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 512k 17k 28 1 1 8 2 +shuffle 512k 45k 11 1 1 7 2 1024k 2432768 0 0 7 6 +shuffle 128k 820 128 1 1 6 2 +shuffle ... (32764 results following) ... sorted by: max free time HEAPSZ BLOCKSZ NRBLKS AVG-A AVG-F MAX-A MAX-F FLAGS 1024k3k 292 1 1 1 8 +shuffle 256k 174 1024 1 1 1 6 +shuffle 1024k 2432768 0 0 7 6 +shuffle 32k 12k 2 2 3 1 5 ... (32764 results following) ... overall: worst alloc time: 8 (us) worst free time: 8 (us) average of max. alloc times: 1 (us) average of max. free times: 1 (us) average alloc time: 1 (us) average free time: 1 (us) [1] http://www.xenomai.org/pipermail/xenomai/2018-April/038883.html --- include/cobalt/kernel/heap.h | 168 kernel/cobalt/Kconfig|7 + kernel/cobalt/heap.c | 979 +- 3 files changed, 662 insertions(+), 492 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index d89f25d..4f95c80 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -20,6 +20,7 @@ #define _COBALT_KERNEL_HEAP_H #include +#include #include #include #include @@ -28,66 +29,66 @@ /** * @addtogroup cobalt_core_heap * @{ - * - * @par Implementation constraints - * - * - Minimum page size is 2 ** XNHEAP_MINLOG2 (must be large enough to - * hold a pointer). - * - * - Maximum page size is 2 ** XNHEAP_MAXLOG2. - * - * - Requested block size is rounded up to XNHEAP_MINLOG2. - * - * - Requested block size larger than 2 times the XNHEAP_PAGESZ is - * rounded up to the next page boundary and obtained from the free - * page list. So we need a bucket for each power of two between - * XNHEAP_MINLOG2 and XNHEAP_MAXLOG2 inclusive, plus one to honor - * requests ranging from the maximum page size to twice this size. */ -#define XNHEAP_PAGESZPAGE_SIZE -#define XNHEAP_MINLOG23 -#define XNHEAP_MAXLOG222 /* Holds pagemap.bcount blocks */ -#define XNHEAP_MINALLOCSZ (1 << XNHEAP_MINLOG2) -#define XNHEAP_MINALIGNSZ (1 << 4) /* i.e. 16 bytes */
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks
Module: xenomai-3 Branch: wip/heapmem Commit: d488470dfdef89fb981799bab18c322b15eae6d5 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d488470dfdef89fb981799bab18c322b15eae6d5 Author: Philippe GerumDate: Tue May 15 18:24:02 2018 +0200 boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks --- lib/boilerplate/heapmem.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/boilerplate/heapmem.c b/lib/boilerplate/heapmem.c index f5b842d..5097d1c 100644 --- a/lib/boilerplate/heapmem.c +++ b/lib/boilerplate/heapmem.c @@ -426,9 +426,12 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size) log2size = HEAPMEM_MIN_LOG2; } else { log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size); - if (size & (size - 1)) - log2size++; - bsize = 1 << log2size; + if (log2size < HEAPMEM_PAGE_SHIFT) { + if (size & (size - 1)) + log2size++; + bsize = 1 << log2size; + } else + bsize = __align_to(size, HEAPMEM_PAGE_SIZE); } /* ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/smokey: memcheck: fix test heap sizes
Module: xenomai-3 Branch: wip/heapmem Commit: d032d8c0fdf7f19ab45f86669f3cede931020956 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d032d8c0fdf7f19ab45f86669f3cede931020956 Author: Philippe GerumDate: Tue May 15 15:29:44 2018 +0200 testsuite/smokey: memcheck: fix test heap sizes --- testsuite/smokey/memcheck/memcheck.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c index 3f18477..7f97218 100644 --- a/testsuite/smokey/memcheck/memcheck.c +++ b/testsuite/smokey/memcheck/memcheck.c @@ -776,7 +776,7 @@ int memcheck_run(struct memcheck_descriptor *md, for (heap_size = md->seq_min_heap_size; heap_size < md->seq_max_heap_size; heap_size <<= 1) { for (runs = 0; runs < md->random_rounds; runs++) { - block_size = (random() % heap_size) ?: 1; + block_size = (random() % (heap_size / 2)) ?: 1; ret = test_seq(md, heap_size, block_size, 0); if (ret) { smokey_trace("failed with %zuk heap, " @@ -846,7 +846,7 @@ int memcheck_run(struct memcheck_descriptor *md, * between loops. */ __RT(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); - block_size = (random() % (heap_size / 2)) ?: 1; + block_size = (random() % (md->pattern_heap_size / 2)) ?: 1; ret = test_seq(md, md->pattern_heap_size, block_size, test_flags(md, MEMCHECK_SHUFFLE|MEMCHECK_PATTERN)); if (ret) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/ipc: align pool memory on native page size
Module: xenomai-3 Branch: wip/heapmem Commit: d2943ff0cf2ce890e4980fe9776465053513a15f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d2943ff0cf2ce890e4980fe9776465053513a15f Author: Philippe GerumDate: Sun May 13 19:00:36 2018 +0200 drivers/ipc: align pool memory on native page size --- kernel/drivers/ipc/iddp.c |2 +- kernel/drivers/ipc/xddp.c |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c index 854a4b6..2a80eba 100644 --- a/kernel/drivers/ipc/iddp.c +++ b/kernel/drivers/ipc/iddp.c @@ -569,7 +569,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd, */ poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); + poolsz = PAGE_ALIGN(poolsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c index 95bee57..57275d0 100644 --- a/kernel/drivers/ipc/xddp.c +++ b/kernel/drivers/ipc/xddp.c @@ -691,8 +691,8 @@ static int __xddp_bind_socket(struct rtipc_private *priv, poolsz = sk->poolsz; if (poolsz > 0) { - poolsz = xnheap_rounded_size(poolsz); - poolsz += xnheap_rounded_size(sk->reqbufsz); + poolsz = PAGE_ALIGN(poolsz); + poolsz += PAGE_ALIGN(sk->reqbufsz); poolmem = xnheap_vmalloc(poolsz); if (poolmem == NULL) { ret = -ENOMEM; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/heapmem: move heap limit to ~4GB
Module: xenomai-3 Branch: wip/heapmem Commit: bac489be0f19b236dd5f7d18480f4557c6a34e0a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bac489be0f19b236dd5f7d18480f4557c6a34e0a Author: Philippe GerumDate: Sun May 13 17:17:06 2018 +0200 boilerplate/heapmem: move heap limit to ~4GB --- include/boilerplate/heapmem.h |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h index c4348b0..0ddd1ce 100644 --- a/include/boilerplate/heapmem.h +++ b/include/boilerplate/heapmem.h @@ -35,10 +35,10 @@ */ #define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) #define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) -/* Max size of an extent (2Gb). */ -#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Max size of an extent (4Gb - HEAPMEM_PAGE_SIZE). */ +#define HEAPMEM_MAX_EXTSZ (4294967295U - HEAPMEM_PAGE_SIZE + 1) /* Bits we need for encoding a page # */ -#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) +#define HEAPMEM_PGENT_BITS (32 - HEAPMEM_PAGE_SHIFT) /* Each page is represented by a page map entry. */ #define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/serial: imx: prevent call from invalid runtime mode
Module: xenomai-3 Branch: stable-3.0.x Commit: 50ef005105d07916d4202bf6d09a5c87fca828f5 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50ef005105d07916d4202bf6d09a5c87fca828f5 Author: Philippe GerumDate: Sun May 13 16:21:13 2018 +0200 drivers/serial: imx: prevent call from invalid runtime mode --- kernel/drivers/serial/rt_imx_uart.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kernel/drivers/serial/rt_imx_uart.c b/kernel/drivers/serial/rt_imx_uart.c index 61836ae..1aec219 100644 --- a/kernel/drivers/serial/rt_imx_uart.c +++ b/kernel/drivers/serial/rt_imx_uart.c @@ -963,6 +963,13 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, struct rtser_config config_buf; uint64_t *hist_buf = NULL; + /* +* We may call regular kernel services ahead, ask for +* re-entering secondary mode if need be. +*/ + if (rtdm_in_rt_context()) + return -ENOSYS; + config = (struct rtser_config *)arg; if (rtdm_fd_is_user(fd)) { @@ -984,13 +991,6 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, return -EINVAL; if (config->config_mask & RTSER_SET_TIMESTAMP_HISTORY) { - /* -* Reflect the call to non-RT as we will likely -* allocate or free the buffer. -*/ - if (rtdm_in_rt_context()) - return -ENOSYS; - if (config->timestamp_history & RTSER_RX_TIMESTAMP_HISTORY) hist_buf = kmalloc(IN_BUFFER_SIZE * @@ -1000,7 +1000,8 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, rt_imx_uart_set_config(ctx, config, _buf); - kfree(hist_buf); + if (hist_buf) + kfree(hist_buf); break; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : cobalt/synch: Do not drop PP on xnsynch_release if it wasn' t committed
Module: xenomai-3 Branch: next Commit: d082061b4bddcac8a13bca899a9c9d646c2ab80d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d082061b4bddcac8a13bca899a9c9d646c2ab80d Author: Jan KiszkaDate: Wed May 2 18:34:00 2018 +0200 cobalt/synch: Do not drop PP on xnsynch_release if it wasn't committed We must not try to drop the prio ceiling in the kernel if it wasn't committed yet. That could easily happen when using a prio-ceiling mutex to wait on a cond-var. Signed-off-by: Jan Kiszka --- kernel/cobalt/synch.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 8c217c2..c65c07a 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -942,7 +942,7 @@ bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) */ xnlock_get_irqsave(, s); - if (synch->status & XNSYNCH_PP) { + if (synch->status & XNSYNCH_CEILING) { clear_pp_boost(synch, curr); need_resched = true; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : testsuite/smokey: Add cond + pp-mutex test
Module: xenomai-3 Branch: next Commit: 410a4cc1109ba4e0d05b7ece7b4a5210287e1183 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=410a4cc1109ba4e0d05b7ece7b4a5210287e1183 Author: Jan KiszkaDate: Wed May 2 18:33:00 2018 +0200 testsuite/smokey: Add cond + pp-mutex test This stresses the case of fast-path mutex acquire plus pthread_cond_wait with that mutex, which currently triggers a bug in xnsynch_release. Along this, drop the HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL conditional - libboilerplate takes care of that. Signed-off-by: Jan Kiszka --- testsuite/smokey/posix-cond/posix-cond.c | 96 ++ 1 file changed, 72 insertions(+), 24 deletions(-) diff --git a/testsuite/smokey/posix-cond/posix-cond.c b/testsuite/smokey/posix-cond/posix-cond.c index 6c9a458..153c645 100644 --- a/testsuite/smokey/posix-cond/posix-cond.c +++ b/testsuite/smokey/posix-cond/posix-cond.c @@ -42,27 +42,21 @@ static inline unsigned long long timer_tsc2ns(unsigned long long tsc) return clockobj_tsc_to_ns(tsc); } -static int mutex_init(pthread_mutex_t *mutex, int type, int pi) +static int mutex_init(pthread_mutex_t *mutex, int type, int proto) { pthread_mutexattr_t mattr; int err; pthread_mutexattr_init(); pthread_mutexattr_settype(, type); -#ifdef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL - if (pi != 0) - pthread_mutexattr_setprotocol(, PTHREAD_PRIO_INHERIT); - - err = pthread_mutex_init(mutex, ); -#else - if (pi != 0) { - err = ENOSYS; + err = pthread_mutexattr_setprotocol(, proto); + if (err) goto out; - } - err = pthread_mutex_init(mutex, ); + if (proto == PTHREAD_PRIO_PROTECT) + pthread_mutexattr_setprioceiling(, 3); + err = pthread_mutex_init(mutex, ); out: -#endif pthread_mutexattr_destroy(); return -err; @@ -217,7 +211,8 @@ static void autoinit_simple_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", thread_spawn(_signaler_tid, 2, cond_signaler, ), 0); @@ -246,7 +241,8 @@ static void simple_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", @@ -271,7 +267,8 @@ static void relative_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); @@ -294,7 +291,8 @@ static void autoinit_absolute_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("mutex_lock", mutex_lock(), 0); start = timer_get_tsc(); @@ -316,7 +314,8 @@ static void absolute_condwait(void) smokey_trace("%s", __func__); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 1), 0); check("mutex_lock", mutex_lock(), 0); @@ -373,7 +372,8 @@ static void sig_norestart_condwait(void) smokey_trace("%s", __func__); check_unix("sigaction", sigaction(SIGRTMIN, , NULL), 0); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", @@ -411,7 +411,8 @@ static void sig_restart_condwait(void) smokey_trace("%s", __func__); check_unix("sigaction", sigaction(SIGRTMIN, , NULL), 0); - check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, 0), 0); + check("mutex_init", mutex_init(, PTHREAD_MUTEX_DEFAULT, + PTHREAD_PRIO_NONE), 0); check("cond_init", cond_init(, 0), 0); check("mutex_lock", mutex_lock(), 0); check("thread_spawn", @@
[Xenomai-git] New commits on branch wip/heapmem
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e1f60e82c09119b63bab8674356ae744aa460cdd Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f20c742f6585fd53e5ff12be6b04d5081ec4a158 Author: Philippe Gerum Date: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ebc1dbb901e4db2a3175ecf4fda668201d47227b Author: Philippe Gerum Date: Mon Apr 23 10:47:28 2018 +0200 copperplate/heapobj-pshared: add helper to return the total heap size URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=99cad85489858b0557f4461bf85bcb7d66a93559 Author: Philippe Gerum Date: Fri Apr 13 12:15:15 2018 +0200 boilerplate: add heapmem allocator This is the umpteenth incarnation of the McKusick allocator, aimed at replacing other allocators which have serious issues: - TLSF is fast but not that good when it comes to memory overhead with small sizes (i.e. < 512 bytes) on 64bit. - heapobj-pshared has decent overhead figures but may be insanely slow at deallocating blocks from large, hot heaps. - the Cobalt core allocator is even worse than heapobj-pshared in deallocating blocks, although the system heap should be generally small enough not to trigger the most pathological cases in practice, hopefully. Nevertheless, the performances are unacceptable. The original McKusick algorithm implements a quick fit allocation scheme, based on bucket management of ^2-sized chunks, which automatically switches to a page-based allocation method for blocks larger than twice the base page size. This variant maintains the free page list in AVL trees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a quick allocation bitmap to manage their blocks internally. The current implementation can replace TLSF for delivering process-local memory with similar performances but lesser overhead with small sizes. Most importantly, a kernel variant of HEAPMEM should replace the Cobalt core allocator. Likewise, heapobj-pshared which is beyond repair should be replaced with a process-shareable variant as well, assuming the average size and allocation patterns of real-time objects are similar in all contexts. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=43347d7fee5dd752eb0c93ac3d5568e5ac80b810 Author: Philippe Gerum Date: Mon Apr 23 10:28:49 2018 +0200 boilerplate: compiler: add more helpers and attribute tags URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c556dc7b8f8bd5fe7bd981a0e8ecb715f44b8aa Author: Philippe Gerum Date: Mon Apr 23 18:29:46 2018 +0200 smokey: add helper to retrieve size expr URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=94a220039395ef6d89d911ce3aec86744b5607d6 Author: Philippe Gerum Date: Mon Apr 23 18:03:07 2018 +0200 smokey: argument accessors using variables URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=138588cba6f58af2b98c011833e5678c4365001c Author: Gilles Chanteperdrix Date: Tue Jul 12 20:29:22 2016 +0200 boilerplate/avl: merge pshared support for AVL trees Make the AVL tree usable in shared memory when AVL_SHARED is defined at build time, switching to offset-based memory references. Gilles published this code in July 2016 as part of his personal toolkit for hobby projects aka 'libchutils'. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=171beb05487c7e34ea04db82fda6782d6ad89ffa Author: Norbert Lange Date: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bc646282da46d32ce4c203aa477b72ea294ae535 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=95193cce02aae6d075662d749370c8bff962ab33 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200
[Xenomai-git] Philippe Gerum : copperplate/registry: switch back to private memory for fs objects
Module: xenomai-3 Branch: stable-3.0.x Commit: 3568a12e797aa35d80650dff3acabcc14ce081ac URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3568a12e797aa35d80650dff3acabcc14ce081ac Author: Philippe GerumDate: Sat Apr 28 18:45:15 2018 +0200 copperplate/registry: switch back to private memory for fs objects Partially revert #8e606e681, keeping registry_add_dir/file() routines free from Cobalt mode switches, a property which some applications might assume when creating specific rt objects (e.g. Alchemy's mutexes, condvars). --- lib/copperplate/registry.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/copperplate/registry.c b/lib/copperplate/registry.c index 0f675ef..1d15448 100644 --- a/lib/copperplate/registry.c +++ b/lib/copperplate/registry.c @@ -116,13 +116,13 @@ int registry_add_dir(const char *fmt, ...) write_lock_safe(>lock, state); - d = __STD(malloc(sizeof(*d))); + d = pvmalloc(sizeof(*d)); if (d == NULL) { ret = -ENOMEM; goto done; } pvholder_init(>link); - d->path = strdup(path); + d->path = pvstrdup(path); if (strcmp(path, "/")) { d->basename = d->path + (basename - path) + 1; @@ -149,8 +149,8 @@ int registry_add_dir(const char *fmt, ...) _operations); if (ret) { fail: - __STD(free(d->path)); - __STD(free(d)); + pvfree(d->path); + pvfree(d); } done: write_unlock_safe(>lock, state); @@ -203,7 +203,7 @@ int registry_add_file(struct fsobj *fsobj, int mode, const char *fmt, ...) if (basename == NULL) return __bt(-EINVAL); - fsobj->path = strdup(path); + fsobj->path = pvstrdup(path); fsobj->basename = fsobj->path + (basename - path) + 1; fsobj->mode = mode & O_ACCMODE; __RT(clock_gettime(CLOCK_COPPERPLATE, >ctime)); @@ -224,7 +224,7 @@ int registry_add_file(struct fsobj *fsobj, int mode, const char *fmt, ...) ret = -ENOENT; fail: pvhash_remove(>files, >hobj, _operations); - __STD(free(fsobj->path)); + pvfree(fsobj->path); fsobj->path = NULL; goto done; } @@ -263,7 +263,7 @@ void registry_destroy_file(struct fsobj *fsobj) pvlist_remove(>link); d->nfiles--; assert(d->nfiles >= 0); - __STD(free(fsobj->path)); + pvfree(fsobj->path); __RT(pthread_mutex_unlock(>lock)); out: __RT(pthread_mutex_destroy(>lock)); @@ -693,7 +693,7 @@ static int spawn_daemon(const char *sessdir, int flags) break; } - __STD(free(path)); + free(path); return ret; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=171beb05487c7e34ea04db82fda6782d6ad89ffa Author: Norbert LangeDate: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bc646282da46d32ce4c203aa477b72ea294ae535 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=95193cce02aae6d075662d749370c8bff962ab33 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 testsuite/smokey: Add handover test for prio-ceiling mutexes This triggers a bug in the PP implementation. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a8ee84d645eb98de10d855cb18e318479ba8395f Author: Philippe Gerum Date: Fri Mar 30 15:01:40 2018 +0200 net/via-rhine: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ed9d0be858e53610815e57690f203e9bc529a05f Author: Philippe Gerum Date: Fri Mar 30 15:01:30 2018 +0200 net/tulip: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a975b12ed597e09f93b13ad56b660c8bd1dca59 Author: Philippe Gerum Date: Fri Mar 30 15:01:23 2018 +0200 net/r8169: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=14dd76a323de2723d13178ebae449c2a33d95efc Author: Philippe Gerum Date: Fri Mar 30 15:01:10 2018 +0200 net/pcnet32: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=94a5b3d5700bbe61838216f28539d5606ec3afb5 Author: Philippe Gerum Date: Fri Mar 30 15:01:02 2018 +0200 net/natsemi: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6e53e8f7b66afa4ca89207a49f19fe7fb72d98de Author: Philippe Gerum Date: Fri Mar 30 15:00:56 2018 +0200 net/macb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=83826bcbd3a8fff7297cdab1700c2c50e600 Author: Philippe Gerum Date: Fri Mar 30 15:00:48 2018 +0200 net/fec: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b7b544b524c0169ac5fd608977204be95b4cdd5e Author: Philippe Gerum Date: Fri Mar 30 15:00:39 2018 +0200 net/eepro100: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=15f034e80f756d1cdbff4988e49ba75899aaf371 Author: Philippe Gerum Date: Fri Mar 30 15:00:26 2018 +0200 net/e1000: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=85545ab5b754a70827de6bb29266b628371a6946 Author: Philippe Gerum Date: Fri Mar 30 15:00:02 2018 +0200 net/at91: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7fb9353344e52c5a09e5cbf206176321e0ee9d41 Author: Philippe Gerum Date: Fri Mar 30 14:59:51 2018 +0200 net/8139too: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c534c1e8c3050b133eb39abf96783941fee82f62 Author: Philippe Gerum Date: Fri Mar 30 13:09:19 2018 +0200 net/igb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6dbf0c470f4e50e65c8c6a4565f7ddd1e6275000 Author: Philippe Gerum Date: Fri Mar 30 12:53:34 2018 +0200 net: create sysfs nodes for net devices Each rtnet device registered with the stack is represented by a node into /sys/devices/virtual/rtnet/. Setting the address of the real device probed by the kernel into the rtnet_device.sysbind field before calling rt_register_rtnetdev(), causes the "adapter" symlink to be installed in the newly created attribute directory, pointing at that device. e.g. static int probe_handler(struct pci_dev *pdev, const struct pci_device_id *ent) { ... rtdev->sysbind = >dev; ... ret = rt_register_rtnetdev(rtdev); ... } $ ls -l /sys/devices/virtual/rtnet/ total 0 drwxr-xr-x2 root root 0 Mar 30 12:50
[Xenomai-git] Philippe Gerum : boilerplate/tlsf: raise the fixed private heap size to 64k
Module: xenomai-3 Branch: stable-3.0.x Commit: 04565eeb83633f431a5303e0f15132ecc485c93e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=04565eeb83633f431a5303e0f15132ecc485c93e Author: Philippe GerumDate: Sat Apr 28 18:28:10 2018 +0200 boilerplate/tlsf: raise the fixed private heap size to 64k When --enable-pshared is passed, we currently have no mean to specify the size of the private heap managed by TLSF. Until this issue is fixed, increase the fixed size of the private heap to 64k, so that running OOM in the few remaining code spots calling the pvmalloc* API becomes unlikely. --- lib/boilerplate/tlsf/tlsf.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/boilerplate/tlsf/tlsf.h b/lib/boilerplate/tlsf/tlsf.h index 766b992..aac4769 100644 --- a/lib/boilerplate/tlsf/tlsf.h +++ b/lib/boilerplate/tlsf/tlsf.h @@ -22,7 +22,7 @@ #include /* A basic heap size which won't be rejected by init_memory_pool(). */ -#define MIN_TLSF_HEAPSZ 8192 +#define MIN_TLSF_HEAPSZ 65536 extern size_t init_memory_pool(size_t, void *); extern size_t get_used_size(void *); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: df72ae08afc7711a600ad5c1b4fd5f72639f565e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=df72ae08afc7711a600ad5c1b4fd5f72639f565e Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index c0ef1df..b670206 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: wip/heapmem Commit: ebfcb36320e00906fd2bf4b8058bb33620788547 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ebfcb36320e00906fd2bf4b8058bb33620788547 Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 884 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 121 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1300 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ec2d7cb..c0ef1df 100644 --- a/configure.ac +++ b/configure.ac @@ -931,6 +931,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..3f18477 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,884 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() /
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: 26fbb2c8e0116552b8dce4c1fc2a0a1036e8c402 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=26fbb2c8e0116552b8dce4c1fc2a0a1036e8c402 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index c0ef1df..b670206 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: wip/heapmem Commit: e3019ac600cf0f3b202cf1b454b463b7cef074ff URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e3019ac600cf0f3b202cf1b454b463b7cef074ff Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 884 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 121 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1300 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ec2d7cb..c0ef1df 100644 --- a/configure.ac +++ b/configure.ac @@ -931,6 +931,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..3f18477 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,884 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() /
[Xenomai-git] New commits on branch wip/heapmem
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=984ce322de865a3ba7896ff9f5272bc07f0c4075 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=871d062a1ca1e38413fd924fc05490079ad86e3c Author: Philippe Gerum Date: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d7c0f165bbe49e29dd50c3c74597cb5cf8e59c37 Author: Philippe Gerum Date: Mon Apr 23 10:47:28 2018 +0200 copperplate/heapobj-pshared: add helper to return the total heap size URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0c6d84b42ef5873476a32b729bb520fc0bb072ad Author: Philippe Gerum Date: Fri Apr 13 12:15:15 2018 +0200 boilerplate: add heapmem allocator This is the umpteenth incarnation of the McKusick allocator, aimed at replacing other allocators which have serious issues: - TLSF is fast but not that good when it comes to memory overhead with small sizes (i.e. < 512 bytes) on 64bit. - heapobj-pshared has decent overhead figures but may be insanely slow at deallocating blocks from large, hot heaps. - the Cobalt core allocator is even worse than heapobj-pshared in deallocating blocks, although the system heap should be generally small enough not to trigger the most pathological cases in practice, hopefully. Nevertheless, the performances are unacceptable. The original McKusick algorithm implements a quick fit allocation scheme, based on bucket management of ^2-sized chunks, which automatically switches to a page-based allocation method for blocks larger than twice the base page size. This variant maintains the free page list in AVL trees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a quick allocation bitmap to manage their blocks internally. The current implementation can replace TLSF for delivering process-local memory with similar performances but lesser overhead with small sizes. Most importantly, a kernel variant of HEAPMEM should replace the Cobalt core allocator. Likewise, heapobj-pshared which is beyond repair should be replaced with a process-shareable variant as well, assuming the average size and allocation patterns of real-time objects are similar in all contexts. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2af5432db53d1c73a0efa35cdb534269b8b9bb94 Author: Philippe Gerum Date: Mon Apr 23 10:28:49 2018 +0200 boilerplate: compiler: add more helpers and attribute tags URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9499058e27f0191f09b5fb4b191b967f62affe75 Author: Philippe Gerum Date: Mon Apr 23 18:29:46 2018 +0200 smokey: add helper to retrieve size expr URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cb30ed6e5fcb1e9c4c822fc174460d008e438243 Author: Philippe Gerum Date: Mon Apr 23 18:03:07 2018 +0200 smokey: argument accessors using variables URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3ed3f8587cca9a823c128c96fb669d060059bd49 Author: Gilles Chanteperdrix Date: Tue Jul 12 20:29:22 2016 +0200 boilerplate/avl: merge pshared support for AVL trees Make the AVL tree usable in shared memory when AVL_SHARED is defined at build time, switching to offset-based memory references. Gilles published this code in July 2016 as part of his personal toolkit for hobby projects aka 'libchutils'. URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d044252681c6740fcd83095a001f07f11366e51f Author: Norbert Lange Date: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fb754c807de950132bc6c07e2eaf6628fb22e355 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=06744569820cc09ac1efb8270ccc4c37579a7e42 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d044252681c6740fcd83095a001f07f11366e51f Author: Norbert LangeDate: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fb754c807de950132bc6c07e2eaf6628fb22e355 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=06744569820cc09ac1efb8270ccc4c37579a7e42 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 testsuite/smokey: Add handover test for prio-ceiling mutexes This triggers a bug in the PP implementation. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=01e1f35241b89f0fdaf7edc5789f07852574376d Author: Philippe Gerum Date: Fri Mar 30 15:01:40 2018 +0200 net/via-rhine: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d4a1c16943601d276b2e2a4d2da7a4d96f9e463b Author: Philippe Gerum Date: Fri Mar 30 15:01:30 2018 +0200 net/tulip: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=29fb81014e6acb9bbb9fda1de4326e34da2a4242 Author: Philippe Gerum Date: Fri Mar 30 15:01:23 2018 +0200 net/r8169: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=871031f0fb3bfa8dbba247b9c041c588fdc8a9c9 Author: Philippe Gerum Date: Fri Mar 30 15:01:10 2018 +0200 net/pcnet32: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4c9bbab7a5b362c41c420ce2047e2ea8c5804227 Author: Philippe Gerum Date: Fri Mar 30 15:01:02 2018 +0200 net/natsemi: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fa97d3ecd99be09eedeed396b9041d5977849835 Author: Philippe Gerum Date: Fri Mar 30 15:00:56 2018 +0200 net/macb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1b822a879b319c6a7b4d61d646cb15928e102b73 Author: Philippe Gerum Date: Fri Mar 30 15:00:48 2018 +0200 net/fec: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b8bf78e23a5163103d478a98f1f1f48b8704fa07 Author: Philippe Gerum Date: Fri Mar 30 15:00:39 2018 +0200 net/eepro100: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=42ea143c7fff7188d94d0480d006cd1abad12bb1 Author: Philippe Gerum Date: Fri Mar 30 15:00:26 2018 +0200 net/e1000: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ef8ecfe674907fe41065da6d8f223a32355ea42a Author: Philippe Gerum Date: Fri Mar 30 15:00:02 2018 +0200 net/at91: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=33a151fcd80145260c2f8f2b8c1f73ccb9b412ee Author: Philippe Gerum Date: Fri Mar 30 14:59:51 2018 +0200 net/8139too: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2937f3812a345e74574b12b5015afc5581fd2e5a Author: Philippe Gerum Date: Fri Mar 30 13:09:19 2018 +0200 net/igb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=265f1a310c402d8e1823ec664a5a1a9be264a912 Author: Philippe Gerum Date: Fri Mar 30 12:53:34 2018 +0200 net: create sysfs nodes for net devices Each rtnet device registered with the stack is represented by a node into /sys/devices/virtual/rtnet/. Setting the address of the real device probed by the kernel into the rtnet_device.sysbind field before calling rt_register_rtnetdev(), causes the "adapter" symlink to be installed in the newly created attribute directory, pointing at that device. e.g. static int probe_handler(struct pci_dev *pdev, const struct pci_device_id *ent) { ... rtdev->sysbind = >dev; ... ret = rt_register_rtnetdev(rtdev); ... } $ ls -l /sys/devices/virtual/rtnet/ total 0 drwxr-xr-x2 root root 0 Mar 30 12:50
[Xenomai-git] Henning Schild : smokey/dlopen: fix testcase
Module: xenomai-3 Branch: stable-3.0.x Commit: 34f28393ede872e50a24cc3ffcc810c40422c717 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=34f28393ede872e50a24cc3ffcc810c40422c717 Author: Henning SchildDate: Tue Apr 24 14:37:00 2018 +0200 smokey/dlopen: fix testcase The intention of another binary and fork/exec was to have a binary is not a xenoami-binary already, to actually test dlopen. Unfortunately a copy-paste mistake in Makefile.am resulted in dlopentest being a xenomai application already. Therefore the dlopens tested something they where not supposed to. Change Makefile.am to make dlopentest a truly non-xenomai binary. And change what it is testing accordingly. We do not support dlclose so do not test it anymore. Signed-off-by: Henning Schild --- testsuite/smokey/dlopen/Makefile.am |8 +--- testsuite/smokey/dlopen/dlopentest.c |9 - testsuite/smokey/dlopen/libalchemy-test.c |2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/testsuite/smokey/dlopen/Makefile.am b/testsuite/smokey/dlopen/Makefile.am index 70390e5..db5a521 100644 --- a/testsuite/smokey/dlopen/Makefile.am +++ b/testsuite/smokey/dlopen/Makefile.am @@ -42,16 +42,10 @@ test_PROGRAMS = dlopentest dlopentest_SOURCES = dlopentest.c dlopentest_CPPFLAGS = \ - @XENO_USER_CFLAGS@ \ -Wno-format-security\ - -DXENO_TEST_DIR='"$(XENO_TEST_DIR)"'\ - -I$(top_srcdir)/include - -dlopentest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + -DXENO_TEST_DIR='"$(XENO_TEST_DIR)"' dlopentest_LDADD = \ - @XENO_CORE_LDADD@ \ - @XENO_USER_LDADD@ \ -ldl noinst_LIBRARIES = libdlopen.a diff --git a/testsuite/smokey/dlopen/dlopentest.c b/testsuite/smokey/dlopen/dlopentest.c index 43f00e2..cbf9b74 100644 --- a/testsuite/smokey/dlopen/dlopentest.c +++ b/testsuite/smokey/dlopen/dlopentest.c @@ -75,14 +75,5 @@ int main(int argc, char *const argv[]) if (ret) error(1, errno, "libposix_func: %s", strerror(-ret)); - if (dlclose(handlep)) - fprintf(stderr, "%s", dlerror()); - if (dlclose(handlea)) - fprintf(stderr, "%s", dlerror()); - - setenv("XENO_TEST_DLOPEN_NO_INIT", "1", 1); - ret = my_dlcall("libalchemy-test.so", "libalchemy_func", ); - assert(ret == ENOMEM); - return 0; } diff --git a/testsuite/smokey/dlopen/libalchemy-test.c b/testsuite/smokey/dlopen/libalchemy-test.c index 4784e2b..3e1eb23 100644 --- a/testsuite/smokey/dlopen/libalchemy-test.c +++ b/testsuite/smokey/dlopen/libalchemy-test.c @@ -33,7 +33,7 @@ static size_t def_mem_pool_size = SIZE_MAX; static int alchemy_tune(void) { - if (getenv("XENO_TEST_DLOPEN_NO_INIT") || ran_init) + if (ran_init) return 0; def_mem_pool_size = get_config_tunable(mem_pool_size); set_config_tunable(mem_pool_size, 2*def_mem_pool_size); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Henning Schild : Revert "boilerplate/setup: introduce destructors for __setup_call"
Module: xenomai-3 Branch: stable-3.0.x Commit: 0dfccf7e8d50738c5dd542f1120d04bc6692d1eb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0dfccf7e8d50738c5dd542f1120d04bc6692d1eb Author: Henning SchildDate: Tue Apr 24 14:37:00 2018 +0200 Revert "boilerplate/setup: introduce destructors for __setup_call" In fact we would need real destructors for all setup_descriptor s. Stop pretending that we know how to dlclose or destruct. This reverts commit 5511e76040444af875ae1bb099c13a25b16336fc. --- include/boilerplate/setup.h |7 --- lib/boilerplate/setup.c |6 -- 2 files changed, 13 deletions(-) diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h index 83af91f..7df3cfe 100644 --- a/include/boilerplate/setup.h +++ b/include/boilerplate/setup.h @@ -78,16 +78,10 @@ struct setup_descriptor { #define __early_ctor __attribute__ ((constructor(210))) #define __bootstrap_ctor __attribute__ ((constructor(220))) -#define __setup_dtor __attribute__ ((destructor(200))) - #define __setup_call(__name, __id) \ static __setup_ctor void __declare_ ## __name(void)\ { \ __register_setup_call(&(__name), __id); \ -} \ -static __setup_dtor void __undeclare_ ## __name(void) \ -{ \ - __unregister_setup_call(&(__name), __id); \ } #define core_setup_call(__name)__setup_call(__name, 0) @@ -102,7 +96,6 @@ extern "C" { #endif void __register_setup_call(struct setup_descriptor *p, int id); -void __unregister_setup_call(struct setup_descriptor *p, int id); extern pid_t __node_id; diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c index 2a64427..8b363ef 100644 --- a/lib/boilerplate/setup.c +++ b/lib/boilerplate/setup.c @@ -701,12 +701,6 @@ void __register_setup_call(struct setup_descriptor *p, int id) pvlist_prepend(>__reserved.next, _list); } -void __unregister_setup_call(struct setup_descriptor *p, int id) -{ - pvlist_remove(>__reserved.next); -} - - const char *get_program_name(void) { return basename(__base_setup_data.arg0 ?: "program"); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Henning Schild : build: link dlopen libs with "nodelete"
Module: xenomai-3 Branch: stable-3.0.x Commit: aa008686091484c88cbb809bc190133a98769a30 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=aa008686091484c88cbb809bc190133a98769a30 Author: Henning SchildDate: Tue Apr 24 14:37:00 2018 +0200 build: link dlopen libs with "nodelete" This way a dlclose() will not unmap the libs memory anymore. A real dlclose() will not work anyways because we lack destructors for all the stuff we initialize in setup_descriptor->init(). Signed-off-by: Henning Schild --- configure.ac |1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 82aea1e..4f9b1f9 100644 --- a/configure.ac +++ b/configure.ac @@ -685,6 +685,7 @@ AC_MSG_RESULT(${CONFIG_XENO_LIBS_DLOPEN:-no}) if test x$CONFIG_XENO_LIBS_DLOPEN = xy; then AC_DEFINE(CONFIG_XENO_LIBS_DLOPEN,1,[config]) AC_DEFINE_UNQUOTED(CONFIG_XENO_TLS_MODEL,"global-dynamic",[TLS model]) + XENO_LIB_LDFLAGS="-Wl,-z -Wl,nodelete" else AC_DEFINE_UNQUOTED(CONFIG_XENO_TLS_MODEL,"initial-exec",[TLS model]) XENO_LIB_LDFLAGS="-Wl,-z -Wl,nodlopen" ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Norbert Lange : smokey/net_common: fix one out-of-bounds access
Module: xenomai-3 Branch: next Commit: 6472486c50e0e7b8d48bef6de6912220e65ddf0e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6472486c50e0e7b8d48bef6de6912220e65ddf0e Author: Norbert LangeDate: Wed Apr 25 15:05:00 2018 +0200 smokey/net_common: fix one out-of-bounds access Signed-off-by: Norbert Lange --- testsuite/smokey/net_common/smokey_net_server.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/smokey/net_common/smokey_net_server.c b/testsuite/smokey/net_common/smokey_net_server.c index a0ed52f..2e19208 100644 --- a/testsuite/smokey/net_common/smokey_net_server.c +++ b/testsuite/smokey/net_common/smokey_net_server.c @@ -89,7 +89,7 @@ rtnet_rtcfg_add_client(int fd, const char *hwaddr, const char *ipaddr) cmd.args.add.ip_addr = ip.s_addr; cmd.args.add.timeout = 3000; memcpy(cmd.args.add.mac_addr, mac.ether_addr_octet, - sizeof(cmd.args.add.mac_addr)); + sizeof(mac.ether_addr_octet)); check_unix(ioctl(fd, RTCFG_IOC_ADD, )); } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Norbert Lange : demo/posix, testsuite/smokey: silences some compiler warnings
Module: xenomai-3 Branch: next Commit: 6eae2e3cbc7b91dfc8cc0f6c4d56b82c40c2d49f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6eae2e3cbc7b91dfc8cc0f6c4d56b82c40c2d49f Author: Norbert LangeDate: Wed Apr 25 15:05:00 2018 +0200 demo/posix, testsuite/smokey: silences some compiler warnings Signed-off-by: Norbert Lange --- demo/posix/cobalt/gpiopwm.c |4 ++-- testsuite/smokey/posix-select/posix-select.c |3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c index b34cbf1..eddd5cc 100644 --- a/demo/posix/cobalt/gpiopwm.c +++ b/demo/posix/cobalt/gpiopwm.c @@ -219,7 +219,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie) saddr.sin_port = htons(port); saddr.sin_family = AF_INET; - if (bind(sockfd, , sizeof(saddr)) < 0) + if (bind(sockfd, (struct sockaddr *), sizeof(saddr)) < 0) perror("bind"); clen = sizeof(caddr); @@ -230,7 +230,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie) print_config("UDP Server\n"); memset(buf,'\0', blen); - ret = recvfrom(sockfd, buf, blen - 1, 0, , ); + ret = recvfrom(sockfd, buf, blen - 1, 0, (struct sockaddr *), ); if (ret < 0) perror("recvfrom"); diff --git a/testsuite/smokey/posix-select/posix-select.c b/testsuite/smokey/posix-select/posix-select.c index 6bd88dd..e9bf938 100644 --- a/testsuite/smokey/posix-select/posix-select.c +++ b/testsuite/smokey/posix-select/posix-select.c @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include smokey_test_plugin(posix_select, ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Norbert Lange : smokey/net_common: fix one out-of-bounds access
Module: xenomai-3 Branch: stable-3.0.x Commit: d18c8ad0b824b9c98c2925e3f50dbfd836060576 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d18c8ad0b824b9c98c2925e3f50dbfd836060576 Author: Norbert LangeDate: Wed Apr 25 15:05:00 2018 +0200 smokey/net_common: fix one out-of-bounds access Signed-off-by: Norbert Lange --- testsuite/smokey/net_common/smokey_net_server.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/smokey/net_common/smokey_net_server.c b/testsuite/smokey/net_common/smokey_net_server.c index a0ed52f..2e19208 100644 --- a/testsuite/smokey/net_common/smokey_net_server.c +++ b/testsuite/smokey/net_common/smokey_net_server.c @@ -89,7 +89,7 @@ rtnet_rtcfg_add_client(int fd, const char *hwaddr, const char *ipaddr) cmd.args.add.ip_addr = ip.s_addr; cmd.args.add.timeout = 3000; memcpy(cmd.args.add.mac_addr, mac.ether_addr_octet, - sizeof(cmd.args.add.mac_addr)); + sizeof(mac.ether_addr_octet)); check_unix(ioctl(fd, RTCFG_IOC_ADD, )); } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: add heapmem allocator
Module: xenomai-3 Branch: wip/heapmem Commit: 1d468fb85145130866c84a40481b714bef49fecb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d468fb85145130866c84a40481b714bef49fecb Author: Philippe GerumDate: Fri Apr 13 12:15:15 2018 +0200 boilerplate: add heapmem allocator This is the umpteenth incarnation of the McKusick allocator, aimed at replacing other allocators which have serious issues: - TLSF is fast but not that good when it comes to memory overhead with small sizes (i.e. < 512 bytes) on 64bit. - heapobj-pshared has decent overhead figures but may be insanely slow at deallocating blocks from large, hot heaps. - the Cobalt core allocator is even worse than heapobj-pshared in deallocating blocks, although the system heap should be generally small enough not to trigger the most pathological cases in practice, hopefully. Nevertheless, the performances are unacceptable. The original McKusick algorithm implements a quick fit allocation scheme, based on bucket management of ^2-sized chunks, which automatically switches to a page-based allocation method for blocks larger than twice the base page size. This variant maintains the free page list in AVL trees for fast lookups of multi-page memory ranges, and pages holding bucketed memory have a quick allocation bitmap to manage their blocks internally. The current implementation can replace TLSF for delivering process-local memory with similar performances but lesser overhead with small sizes. Most importantly, a kernel variant of HEAPMEM should replace the Cobalt core allocator. Likewise, heapobj-pshared which is beyond repair should be replaced with a process-shareable variant as well, assuming the average size and allocation patterns of real-time objects are similar in all contexts. --- include/boilerplate/Makefile.am |1 + include/boilerplate/heapmem.h | 155 + lib/boilerplate/Makefile.am |1 + lib/boilerplate/heapmem.c | 704 +++ 4 files changed, 861 insertions(+) diff --git a/include/boilerplate/Makefile.am b/include/boilerplate/Makefile.am index 4ed6a99..56f20bd 100644 --- a/include/boilerplate/Makefile.am +++ b/include/boilerplate/Makefile.am @@ -7,6 +7,7 @@ includesub_HEADERS =\ compiler.h \ debug.h \ hash.h \ + heapmem.h \ libc.h \ list.h \ lock.h \ diff --git a/include/boilerplate/heapmem.h b/include/boilerplate/heapmem.h new file mode 100644 index 000..c4348b0 --- /dev/null +++ b/include/boilerplate/heapmem.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2018 Philippe Gerum . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef _BOILERPLATE_HEAPMEM_H +#define _BOILERPLATE_HEAPMEM_H + +#include +#include +#include +#include +#include +#include + +#define HEAPMEM_PAGE_SHIFT 9 /* 2^9 => 512 bytes */ +#define HEAPMEM_PAGE_SIZE (1UL << HEAPMEM_PAGE_SHIFT) +#define HEAPMEM_PAGE_MASK (~(HEAPMEM_PAGE_SIZE - 1)) +#define HEAPMEM_MIN_LOG2 4 /* 16 bytes */ +/* + * Use bucketed memory for sizes between 2^HEAPMEM_MIN_LOG2 and + * 2^(HEAPMEM_PAGE_SHIFT-1). + */ +#define HEAPMEM_MAX(HEAPMEM_PAGE_SHIFT - HEAPMEM_MIN_LOG2) +#define HEAPMEM_MIN_ALIGN (1U << HEAPMEM_MIN_LOG2) +/* Max size of an extent (2Gb). */ +#define HEAPMEM_MAX_EXTSZ (1U << 31) +/* Bits we need for encoding a page # */ +#define HEAPMEM_PGENT_BITS (31 - HEAPMEM_PAGE_SHIFT - 1) + +/* Each page is represented by a page map entry. */ +#define HEAPMEM_PGMAP_BYTESsizeof(struct heapmem_pgentry) + +struct heapmem_pgentry { + /* Linkage in bucket list. */ + unsigned int prev : HEAPMEM_PGENT_BITS; + unsigned int next : HEAPMEM_PGENT_BITS; + /* page_list or log2. */ + unsigned int type : 6; + /* +* We hold either a spatial map of busy blocks within the page +* for bucketed memory (up to 32 blocks per page), or the +* overall size of the multi-page block if entry.type == +* page_list. +*/ + union { + uint32_t map; + uint32_t bsize; + }; +}; + +/* + * A range descriptor is stored at the
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: a36437ed07959f21cf7d63510a6bf8d53db54bbb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a36437ed07959f21cf7d63510a6bf8d53db54bbb Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 61ebcbe..2caa4f3 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : smokey: add helper to retrieve size expr
Module: xenomai-3 Branch: wip/heapmem Commit: 91ec9082982a7f42b7de7e933425b08ec9895ef2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=91ec9082982a7f42b7de7e933425b08ec9895ef2 Author: Philippe GerumDate: Mon Apr 23 18:29:46 2018 +0200 smokey: add helper to retrieve size expr --- include/smokey/smokey.h | 11 +++ lib/smokey/helpers.c| 22 ++ 2 files changed, 33 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index ffd91cf..185fd3a 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -49,6 +49,12 @@ .matched = 0, \ } +#define SMOKEY_SIZE(__name) { \ +.name = # __name, \ +.parser = smokey_size, \ +.matched = 0, \ +} + #define SMOKEY_ARGLIST(__args...) ((struct smokey_arg[]){ __args }) #define SMOKEY_NOARGS (((struct smokey_arg[]){ { .name = NULL } })) @@ -60,6 +66,7 @@ struct smokey_arg { union { int n_val; char *s_val; + size_t l_val; } u; int matched; }; @@ -104,11 +111,13 @@ struct smokey_test { #define SMOKEY_ARG_INT(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.n_val) #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define SMOKEY_ARG_SIZE(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.l_val) #define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) #define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) #define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) #define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) +#define smokey_arg_size(__t, __name) (smokey_lookup_arg(__t, __name)->u.l_val) #define smokey_check_errno(__expr) \ ({ \ @@ -216,6 +225,8 @@ int smokey_bool(const char *s, struct smokey_arg *arg); int smokey_string(const char *s, struct smokey_arg *arg); +int smokey_size(const char *s, struct smokey_arg *arg); + struct smokey_arg *smokey_lookup_arg(struct smokey_test *t, const char *arg); diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c index fd1fca3..6ee69ec 100644 --- a/lib/smokey/helpers.c +++ b/lib/smokey/helpers.c @@ -85,6 +85,28 @@ int smokey_string(const char *s, struct smokey_arg *arg) return ret; } +int smokey_size(const char *s, struct smokey_arg *arg) +{ + char *name, *p; + int ret; + + ret = sscanf(s, "%m[_a-z]=%m[^\n]", , ); + if (ret != 2) + return 0; + + ret = !strcmp(name, arg->name); + if (ret) { + arg->u.l_val = get_mem_size(p); + if (arg->u.l_val == 0) + ret = 0; + } + + free(p); + free(name); + + return ret; +} + int smokey_parse_args(struct smokey_test *t, int argc, char *const argv[]) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: wip/heapmem Commit: a2c232d73b0ffdae8235a9c3f68728f68500fad4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a2c232d73b0ffdae8235a9c3f68728f68500fad4 Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 851 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 125 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1271 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 59ea776..61ebcbe 100644 --- a/configure.ac +++ b/configure.ac @@ -930,6 +930,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..b38dcc8 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,851 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() /
[Xenomai-git] Philippe Gerum : smokey: argument accessors using variables
Module: xenomai-3 Branch: wip/heapmem Commit: eccf431e4158052855bd07ebf292b50fe5799b90 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eccf431e4158052855bd07ebf292b50fe5799b90 Author: Philippe GerumDate: Mon Apr 23 18:03:07 2018 +0200 smokey: argument accessors using variables --- include/smokey/smokey.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h index 5fea66c..ffd91cf 100644 --- a/include/smokey/smokey.h +++ b/include/smokey/smokey.h @@ -105,6 +105,11 @@ struct smokey_test { #define SMOKEY_ARG_BOOL(__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg)) #define SMOKEY_ARG_STRING(__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val) +#define smokey_arg_isset(__t, __name) (smokey_lookup_arg(__t, __name)->matched) +#define smokey_arg_int(__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val) +#define smokey_arg_bool(__t, __name) (!!smokey_arg_int(__t, __name)) +#define smokey_arg_string(__t, __name) (smokey_lookup_arg(__t, __name)->u.s_val) + #define smokey_check_errno(__expr) \ ({ \ int __ret = (__expr); \ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix reservation in allocation bitmap
Module: xenomai-3 Branch: wip/heapmem Commit: bd6a419fe1d0e2ee0382baf2ed1db22355abe69b URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bd6a419fe1d0e2ee0382baf2ed1db22355abe69b Author: Philippe GerumDate: Thu Apr 26 11:03:50 2018 +0200 copperplate/heapobj-pshared: fix reservation in allocation bitmap This is a severe bug which would cause an already reserved page range to be returned twice in specific situations depending on the bitmap contents at the time of the second allocation. --- lib/copperplate/heapobj-pshared.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index a3c5484..d4324df 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -289,8 +289,12 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) */ for (n = 0, seq = 0; n < bitwords; n++) { v = bitmap[n]; + if (v == -1U) { + seq = 0; + continue; + } b = 0; - while (v != -1U) { + for (;;) { r = __ctz(v); if (r) { seq += r; @@ -316,8 +320,11 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) * keep searching for one which is at least * nrpages-bit long. */ - if (v == -1U && b < 32) - seq = 0; + if (v == -1U) { + if (b < 32) + seq = 0; + break; + } } } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : boilerplate/avl: merge pshared support for AVL trees
Module: xenomai-3 Branch: wip/heapmem Commit: 748488c18143c680696714428dda8e05a9bd31c0 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=748488c18143c680696714428dda8e05a9bd31c0 Author: Gilles ChanteperdrixDate: Tue Jul 12 20:29:22 2016 +0200 boilerplate/avl: merge pshared support for AVL trees Make the AVL tree usable in shared memory when AVL_SHARED is defined at build time, switching to offset-based memory references. Gilles published this code in July 2016 as part of his personal toolkit for hobby projects aka 'libchutils'. --- include/boilerplate/avl.h | 472 -- lib/boilerplate/avl.c | 497 ++--- 2 files changed, 697 insertions(+), 272 deletions(-) diff --git a/include/boilerplate/avl.h b/include/boilerplate/avl.h index 1aa84bf..34fb23a 100644 --- a/include/boilerplate/avl.h +++ b/include/boilerplate/avl.h @@ -23,276 +23,444 @@ #ifndef _BOILERPLATE_AVL_H #define _BOILERPLATE_AVL_H -#include +#include +#include struct avlh { - unsigned int thr: 3; +#define AVLH_APP_BITS 28 + unsigned int flags: AVLH_APP_BITS; int type: 2; - int balance :2; - unsigned int flags :25; /* Application-specific */ - struct avlh *link[3]; + int balance: 2; + union { + ptrdiff_t offset; + struct avlh *ptr; + } link[3]; }; -/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0 - for "up" is just here for orthogonality... and avoid wasting 4 bytes or - having to use a union in struct avlh. */ -#define AVL_LEFT -1 -#define AVL_UP0 -#define AVL_RIGHT 1 -/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ -#define avl_opposite(type) (-(type)) -/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */ -#define avl_type2sign(type) (type) -/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ -#define avl_type2index(type) ((type)+1) -/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */ -#define avl_sign2type(sign) (sign) - -#define AVL_THR_LEFT (1< thr |= 1 << avl_type2index(side)) -#define avlh_thr_clr(holder, side) ((holder)->thr &= ~(1 << avl_type2index(side))) -#define avlh_thr_tst(holder, side) ((holder)->thr & (1 << avl_type2index(side))) -#define avlh_link(holder, dir) ((holder)->link[avl_type2index(dir)]) -#define avlh_up(holder)avlh_link((holder), AVL_UP) -#define avlh_left(holder) avlh_link((holder), AVL_LEFT) -#define avlh_right(holder) avlh_link((holder), AVL_RIGHT) -#define avlh_parent_link(holder) (avlh_link(avlh_up(holder), (holder)->type)) - struct avl; -typedef struct avlh *avl_search_t(const struct avl *, const struct avlh *, int *); - +/* + * Comparison function: should return -1 if left is less than right, 0 + * if they are equal and 1 if left is greather than right. You can use + * the avl_sign function which will convert a difference to -1, 0, + * 1. Beware of overflow however. You can also use avl_cmp_sign() + * which should not have any such problems. + */ typedef int avlh_cmp_t(const struct avlh *const, const struct avlh *const); +typedef struct avlh * +avl_search_t(const struct avl *, const struct avlh *, int *, int); + +typedef int avlh_prn_t(char *, size_t, const struct avlh *const); + struct avl { struct avlh anchor; avl_search_t *search; avlh_cmp_t *cmp; - struct avlh *end[3]; + union { + ptrdiff_t offset; + struct avlh *ptr; + } end[3]; unsigned int count; unsigned int height; }; -#define avl_searchfn(avl) ((avl)->search) -#define avl_cmp(avl) ((avl)->cmp) -#define avl_count(avl)((avl)->count) -#define avl_height(avl) ((avl)->height) -#define avl_anchor(avl) (&(avl)->anchor) -#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)]) -#define avl_top(avl) (avlh_right(avl_anchor(avl))) -#define avl_head(avl) (avl_end((avl), AVL_LEFT)) -#define avl_tail(avl) (avl_end((avl), AVL_RIGHT)) +#define AVL_LEFT-1 +#define AVL_UP 0 +#define AVL_RIGHT1 +/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */ +#define avl_opposite(type) (-(type)) +/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */ +#define avl_type2index(type) ((type)+1) -#ifdef __cplusplus -extern "C" { -#endif +#define AVL_THR_LEFT (1 << avl_type2index(AVL_LEFT)) +#define AVL_THR_RIGHT (1 << avl_type2index(AVL_RIGHT)) -void avl_init(struct avl *avl, avl_search_t *search, avlh_cmp_t *cmp); +#define avlh_up(avl, holder) avlh_link((avl), (holder), AVL_UP) +#define avlh_left(avl, holder) avlh_link((avl), (holder), AVL_LEFT) +#define avlh_right(avl, holder)avlh_link((avl), (holder),
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: add helper to return the total heap size
Module: xenomai-3 Branch: wip/heapmem Commit: 5964a2e18703e5d956efb86fb824716104109841 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5964a2e18703e5d956efb86fb824716104109841 Author: Philippe GerumDate: Mon Apr 23 10:47:28 2018 +0200 copperplate/heapobj-pshared: add helper to return the total heap size --- include/copperplate/heapobj.h |2 ++ lib/copperplate/heapobj-pshared.c |6 ++ 2 files changed, 8 insertions(+) diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index 4cf947e..dc2a45d 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -304,6 +304,8 @@ size_t heapobj_validate(struct heapobj *hobj, size_t heapobj_inquire(struct heapobj *hobj); +size_t heapobj_get_size(struct heapobj *hobj); + int heapobj_bind_session(const char *session); void heapobj_unbind_session(void); diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index e08b033..6f1ca3a 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -1092,6 +1092,12 @@ size_t heapobj_inquire(struct heapobj *hobj) return heap->ubytes; } +size_t heapobj_get_size(struct heapobj *hobj) +{ + struct shared_heap *heap = __mptr(hobj->pool_ref); + return heap->total; +} + void *xnmalloc(size_t size) { return alloc_block(_heap.heap, size); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: compiler: add more helpers and attribute tags
Module: xenomai-3 Branch: wip/heapmem Commit: 5849eff618549d00f79bf58fb170b1e3694df856 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5849eff618549d00f79bf58fb170b1e3694df856 Author: Philippe GerumDate: Mon Apr 23 10:28:49 2018 +0200 boilerplate: compiler: add more helpers and attribute tags --- include/boilerplate/compiler.h| 18 ++ lib/copperplate/heapobj-pshared.c |6 -- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h index bcef7d4..f526eb2 100644 --- a/include/boilerplate/compiler.h +++ b/include/boilerplate/compiler.h @@ -46,6 +46,14 @@ #define __weak __attribute__((__weak__)) #endif +#ifndef __const +#define __const__attribute__((__const__)) +#endif + +#ifndef __pure +#define __pure __attribute__((__pure__)) +#endif + #ifndef __maybe_unused #define __maybe_unused __attribute__((__unused__)) #endif @@ -58,6 +66,16 @@ #define __deprecated __attribute__((__deprecated__)) #endif +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +#ifndef __alloc_size +#define __alloc_size(__args) __attribute__((__alloc_size__(__args))) +#endif + +#define __align_to(__size, __al) (((__size) + (__al) - 1) & (~((__al) - 1))) + #ifdef __cplusplus extern "C" { #endif diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index d4324df..e08b033 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -106,12 +106,6 @@ static struct heapobj main_pool; #define __shref(b, o) ((void *)((caddr_t)(b) + (o))) #define __shref_check(b, o)((o) ? __shref(b, o) : NULL) -static inline size_t __align_to(size_t size, size_t al) -{ - /* The alignment value must be a power of 2 */ - return ((size+al-1)&(~(al-1))); -} - static inline size_t get_pagemap_size(size_t h, memoff_t *bmapoff, int *bmapwords) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix reservation in allocation bitmap
Module: xenomai-3 Branch: next Commit: bd6a419fe1d0e2ee0382baf2ed1db22355abe69b URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bd6a419fe1d0e2ee0382baf2ed1db22355abe69b Author: Philippe GerumDate: Thu Apr 26 11:03:50 2018 +0200 copperplate/heapobj-pshared: fix reservation in allocation bitmap This is a severe bug which would cause an already reserved page range to be returned twice in specific situations depending on the bitmap contents at the time of the second allocation. --- lib/copperplate/heapobj-pshared.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index a3c5484..d4324df 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -289,8 +289,12 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) */ for (n = 0, seq = 0; n < bitwords; n++) { v = bitmap[n]; + if (v == -1U) { + seq = 0; + continue; + } b = 0; - while (v != -1U) { + for (;;) { r = __ctz(v); if (r) { seq += r; @@ -316,8 +320,11 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) * keep searching for one which is at least * nrpages-bit long. */ - if (v == -1U && b < 32) - seq = 0; + if (v == -1U) { + if (b < 32) + seq = 0; + break; + } } } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix reservation in allocation bitmap
Module: xenomai-3 Branch: stable-3.0.x Commit: 984d13432547d9cb9283162e3efd6b2224acb2a9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=984d13432547d9cb9283162e3efd6b2224acb2a9 Author: Philippe GerumDate: Thu Apr 26 11:03:50 2018 +0200 copperplate/heapobj-pshared: fix reservation in allocation bitmap This is a severe bug which would cause an already reserved page range to be returned twice in specific situations depending on the bitmap contents at the time of the second allocation. --- lib/copperplate/heapobj-pshared.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index a3c5484..d4324df 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -289,8 +289,12 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) */ for (n = 0, seq = 0; n < bitwords; n++) { v = bitmap[n]; + if (v == -1U) { + seq = 0; + continue; + } b = 0; - while (v != -1U) { + for (;;) { r = __ctz(v); if (r) { seq += r; @@ -316,8 +320,11 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) * keep searching for one which is at least * nrpages-bit long. */ - if (v == -1U && b < 32) - seq = 0; + if (v == -1U) { + if (b < 32) + seq = 0; + break; + } } } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: wip/heapmem Commit: 4756348e6de8693b957540fda92bb10f21ec16f6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4756348e6de8693b957540fda92bb10f21ec16f6 Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 851 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 125 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1271 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 59ea776..61ebcbe 100644 --- a/configure.ac +++ b/configure.ac @@ -930,6 +930,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..b38dcc8 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,851 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() /
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: 3471a0e2ed6f0407e393ad194bd27ba5236bcef8 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3471a0e2ed6f0407e393ad194bd27ba5236bcef8 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 61ebcbe..2caa4f3 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix reservation in allocation bitmap
Module: xenomai-3 Branch: wip/heapmem Commit: 6987444c499aae975e3fce6b70fa706d8f93081c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6987444c499aae975e3fce6b70fa706d8f93081c Author: Philippe GerumDate: Thu Apr 26 11:03:50 2018 +0200 copperplate/heapobj-pshared: fix reservation in allocation bitmap This is a severe bug which would cause an already reserved page range to be returned twice in specific situations depending on the bitmap contents at the time of the second allocation. --- lib/copperplate/heapobj-pshared.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index 6557ab6..6f1ca3a 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -283,8 +283,12 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) */ for (n = 0, seq = 0; n < bitwords; n++) { v = bitmap[n]; + if (v == -1U) { + seq = 0; + continue; + } b = 0; - while (v != -1U) { + for (;;) { r = __ctz(v); if (r) { seq += r; @@ -310,8 +314,11 @@ static int reserve_page_range(uint32_t *bitmap, int bitwords, int nrpages) * keep searching for one which is at least * nrpages-bit long. */ - if (v == -1U && b < 32) - seq = 0; + if (v == -1U) { + if (b < 32) + seq = 0; + break; + } } } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators
Module: xenomai-3 Branch: wip/heapmem Commit: ecdc9770b12be89517135c003e1611378f744b6c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ecdc9770b12be89517135c003e1611378f744b6c Author: Philippe GerumDate: Sun Apr 22 18:20:04 2018 +0200 testsuite/smokey: add test suite for memory allocators --- configure.ac|4 + testsuite/smokey/Makefile.am| 17 +- testsuite/smokey/memcheck/Makefile.am |8 + testsuite/smokey/memcheck/memcheck.c| 851 +++ testsuite/smokey/memcheck/memcheck.h| 65 ++ testsuite/smokey/memory-heapmem/Makefile.am |9 + testsuite/smokey/memory-heapmem/heapmem.c | 51 ++ testsuite/smokey/memory-pshared/Makefile.am |9 + testsuite/smokey/memory-pshared/pshared.c | 125 testsuite/smokey/memory-tlsf/Makefile.am| 10 + testsuite/smokey/memory-tlsf/tlsf.c | 123 11 files changed, 1271 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 59ea776..61ebcbe 100644 --- a/configure.ac +++ b/configure.ac @@ -930,6 +930,10 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/memcheck/Makefile \ + testsuite/smokey/memory-heapmem/Makefile \ + testsuite/smokey/memory-tlsf/Makefile \ + testsuite/smokey/memory-pshared/Makefile \ testsuite/smokey/fpu-stress/Makefile \ testsuite/smokey/net_udp/Makefile \ testsuite/smokey/net_packet_dgram/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index c6fe70b..d7a71fe 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -5,6 +5,10 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) smokey_SOURCES = main.c +# Make sure to list modules from the most dependent to the +# least. e.g. net_common should appear after all net_* modules, +# memcheck should appear after all heapmem-* modules. + COBALT_SUBDIRS = \ arith \ bufp\ @@ -12,6 +16,9 @@ COBALT_SUBDIRS = \ fpu-stress \ iddp\ leaks \ + memory-heapmem \ + memory-tlsf \ + memcheck\ net_packet_dgram\ net_packet_raw \ net_udp \ @@ -31,11 +38,19 @@ COBALT_SUBDIRS =\ vdso-access \ xddp +if XENO_PSHARED +COBALT_SUBDIRS += memory-pshared +endif + if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen endif -MERCURY_SUBDIRS = +MERCURY_SUBDIRS = memory-heapmem memory-tlsf +if XENO_PSHARED +MERCURY_SUBDIRS += memory-pshared +endif +MERCURY_SUBDIRS += memcheck DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS) diff --git a/testsuite/smokey/memcheck/Makefile.am b/testsuite/smokey/memcheck/Makefile.am new file mode 100644 index 000..482314a --- /dev/null +++ b/testsuite/smokey/memcheck/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libmemcheck.a +noinst_HEADERS = memcheck.h + +AM_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include + +libmemcheck_a_SOURCES = memcheck.c diff --git a/testsuite/smokey/memcheck/memcheck.c b/testsuite/smokey/memcheck/memcheck.c new file mode 100644 index 000..9244fd8 --- /dev/null +++ b/testsuite/smokey/memcheck/memcheck.c @@ -0,0 +1,851 @@ +/* + * Copyright (C) 2018 Philippe Gerum + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "memcheck.h" + +enum pattern { + alphabet_series, + digit_series, + binary_series, +}; + +struct chunk { + void *ptr; + enum pattern pattern; +}; + +struct runstats { + size_t heap_size; + size_t user_size; + size_t block_size; + int nrblocks; + long alloc_avg_ns; + long alloc_max_ns; + long free_avg_ns; + long free_max_ns; + int flags; + double overhead; + double fragmentation; + struct runstats *next; +}; + +static struct runstats *statistics; + +static int nrstats; + +static int max_results = 4; + +static inline long diff_ts(struct timespec *left, struct timespec *right) +{ + return (long long)(left->tv_sec - right->tv_sec) * ONE_BILLION + + left->tv_nsec - right->tv_nsec; +} + +static inline void swap(void *left, void *right, const size_t size) +{ + char trans[size]; + + memcpy(trans, left, size); + memcpy(left, right, size); + memcpy(right, trans, size); +} + +static void random_shuffle(void *vbase, size_t nmemb, const size_t size) +{ + struct { + char x[size]; + } __attribute__((packed)) *base = vbase; + unsigned int j, k; + double u; + + for(j = nmemb; j > 0; j--) { + u = (double)random() /
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: d516ee9ef8661d9dc65372ecfff0c6a2415ce323 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d516ee9ef8661d9dc65372ecfff0c6a2415ce323 Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 61ebcbe..2caa4f3 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] Philippe Gerum : copperplate/heapobj: enable heapmem for private memory
Module: xenomai-3 Branch: wip/heapmem Commit: 02de3d7eb1f1008afe67fdaeb92511e51ba5c41f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=02de3d7eb1f1008afe67fdaeb92511e51ba5c41f Author: Philippe GerumDate: Sun Apr 22 19:50:57 2018 +0200 copperplate/heapobj: enable heapmem for private memory Make HEAPMEM the default private memory allocator for real-time configurations (cobalt || (mercury && non-debug)). This setting can be reverted by passing --with-localmem=tlsf. --- configure.ac | 51 ++--- include/copperplate/heapobj.h | 68 ++- lib/boilerplate/Makefile.am |7 ++- lib/copperplate/Makefile.am |4 ++ lib/copperplate/heapobj-heapmem.c | 91 + 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 61ebcbe..2caa4f3 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,26 @@ if test x$use_pshared = xy; then fi AM_CONDITIONAL(XENO_PSHARED,[test x$use_pshared = xy]) +dnl Allocator selection + +localmem_allocator=heapmem +AC_MSG_CHECKING([for process-local memory allocator]) +AC_ARG_WITH(localmem, +AS_HELP_STRING([--with-localmem=],[Select process-local memory allocator]), +[ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([You must supply an argument to --with-localmem]) + ;; + heapmem|tlsf) + localmem_allocator=$withval + ;; + *) + AC_MSG_ERROR([--localmem-allocator=]) + esac +]) +AC_MSG_RESULT($localmem_allocator) + dnl Registry support in user-space (FUSE-based, default: off) use_registry= @@ -610,12 +630,31 @@ AM_CONDITIONAL(CONFIG_XENO_SHARED,[test "$enable_shared" = 'yes']) # Default sampling period (ns) used in various tests AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config]) -dnl Allocator for Copperplate -dnl Note: in dual kernel mode, we don't want malloc, no matter what. -dnl We switch to malloc only over the Mercury core in debug mode, to ease -dnl debugging with valgrind, instrumented glibc etc. -AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x]) -test $rtcore_type = cobalt -o x$debug_mode = x && AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) +dnl Allocator for Copperplate. Note: in dual kernel mode, we don't +dnl want malloc, no matter what: pick either heapmem or tlsf, defaults +dnl to heapmem. Force switch to malloc over the Mercury core in debug +dnl mode, to ease debugging with valgrind, instrumented glibc etc. + +if test $rtcore_type = cobalt -o x$debug_mode = x; then + case $localmem_allocator in + heapmem) + AC_DEFINE(CONFIG_XENO_HEAPMEM,1,[config]) + use_heapmem=y + use_tlsf= + ;; + tlsf) + AC_DEFINE(CONFIG_XENO_TLSF,1,[config]) + use_tlsf=y + use_heapmem= + ;; + esac +else + use_heapmem= + use_tlsf= +AC_MSG_WARN([using malloc() for private memory in debug mode]) +fi +AM_CONDITIONAL(XENO_TLSF,[test x$use_tlsf = xy]) +AM_CONDITIONAL(XENO_HEAPMEM,[test x$use_heapmem = xy]) dnl Check for atomic builtins. For now we only check for the legacy dnl interface, i.e. __sync_*. diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h index dc2a45d..c8a7773 100644 --- a/include/copperplate/heapobj.h +++ b/include/copperplate/heapobj.h @@ -139,7 +139,71 @@ static inline char *pvstrdup(const char *ptr) return strcpy(str, ptr); } -#else /* !CONFIG_XENO_TLSF, i.e. malloc */ +#elif defined(CONFIG_XENO_HEAPMEM) + +#include + +extern struct heap_memory heapmem_main; + +static inline +void pvheapobj_destroy(struct heapobj *hobj) +{ + heapmem_destroy(hobj->pool); +} + +static inline +int pvheapobj_extend(struct heapobj *hobj, size_t size, void *mem) +{ + return heapmem_extend(hobj->pool, mem, size); +} + +static inline +void *pvheapobj_alloc(struct heapobj *hobj, size_t size) +{ + return heapmem_alloc(hobj->pool, size); +} + +static inline +void pvheapobj_free(struct heapobj *hobj, void *ptr) +{ + heapmem_free(hobj->pool, ptr); +} + +static inline +size_t pvheapobj_validate(struct heapobj *hobj, void *ptr) +{ + ssize_t size = heapmem_check(hobj->pool, ptr); + return size < 0 ? 0 : size; +} + +static inline +size_t pvheapobj_inquire(struct heapobj *hobj) +{ + return heapmem_used_size(hobj->pool); +} + +static inline void *pvmalloc(size_t size) +{ + return heapmem_alloc(_main, size); +} + +static inline void pvfree(void *ptr) +{ + heapmem_free(_main, ptr); +} + +static inline char *pvstrdup(const char *ptr) +{ + char *str; + + str = (char *)pvmalloc(strlen(ptr) + 1); + if (str == NULL) + return NULL; + + return strcpy(str, ptr); +} + +#else /* !CONFIG_XENO_HEAPMEM, i.e. malloc */ #include @@
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5e449ed0f8374fd333688f2a71a896d92e244783 Author: Jan KiszkaDate: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5ea21568d44049d3998e42171b100177d77feb5f Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 testsuite/smokey: Add handover test for prio-ceiling mutexes This triggers a bug in the PP implementation. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=caf3e34a6f75f9d992a0ce2891f23ae8a9bc012c Author: Philippe Gerum Date: Fri Mar 30 15:01:40 2018 +0200 net/via-rhine: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3a7473f23a21fe2d8e20a05eff2918a5737307b4 Author: Philippe Gerum Date: Fri Mar 30 15:01:30 2018 +0200 net/tulip: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=01087b02d57e751c04679ed147329bcaaf98a11a Author: Philippe Gerum Date: Fri Mar 30 15:01:23 2018 +0200 net/r8169: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=46fc232c5c75e0b24bf3f8edb6c553fe443f61b4 Author: Philippe Gerum Date: Fri Mar 30 15:01:10 2018 +0200 net/pcnet32: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d6932042b183d580790eed9ecc8dbfd5ab6584b Author: Philippe Gerum Date: Fri Mar 30 15:01:02 2018 +0200 net/natsemi: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ca3cbf6cd5a5ab5aa9b7d4e97c74eae5f197c9db Author: Philippe Gerum Date: Fri Mar 30 15:00:56 2018 +0200 net/macb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1a7615f6fa1fdbd931a1af44f640c16c0ec8e5d4 Author: Philippe Gerum Date: Fri Mar 30 15:00:48 2018 +0200 net/fec: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bab48fee1673970a84ec6ac1127767ede88d1776 Author: Philippe Gerum Date: Fri Mar 30 15:00:39 2018 +0200 net/eepro100: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=696186819b8ef54656717e27ef811cfb5ee4aad1 Author: Philippe Gerum Date: Fri Mar 30 15:00:26 2018 +0200 net/e1000: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=42fbe0da79bfb0ddeda45dd5efe56fd593b902c8 Author: Philippe Gerum Date: Fri Mar 30 15:00:02 2018 +0200 net/at91: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fc81d238d1c115b7cfd230fd3377240890295f40 Author: Philippe Gerum Date: Fri Mar 30 14:59:51 2018 +0200 net/8139too: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5172100950b74ef30cc6215d514d6844e56f0b50 Author: Philippe Gerum Date: Fri Mar 30 13:09:19 2018 +0200 net/igb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ca7f18d465e1579b91a09efc75d05e5a4cdbbc19 Author: Philippe Gerum Date: Fri Mar 30 12:53:34 2018 +0200 net: create sysfs nodes for net devices Each rtnet device registered with the stack is represented by a node into /sys/devices/virtual/rtnet/. Setting the address of the real device probed by the kernel into the rtnet_device.sysbind field before calling rt_register_rtnetdev(), causes the "adapter" symlink to be installed in the newly created attribute directory, pointing at that device. e.g. static int probe_handler(struct pci_dev *pdev, const struct pci_device_id *ent) { ... rtdev->sysbind = >dev; ... ret = rt_register_rtnetdev(rtdev); ... } $ ls -l /sys/devices/virtual/rtnet/ total 0 drwxr-xr-x2 root root 0 Mar 30 12:50 enp1s0 drwxr-xr-x2 root root 0 Mar 30 12:50 rtlo $ ls -l /sys/devices/virtual/rtnet/enp1s0/ total 0 lrwxrwxrwx1 root root 0 Mar 30 12:51 adapter -> ../../../pci:00/:00:13.0/:01:00.0 lrwxrwxrwx1 root root 0 Mar 30 12:51
[Xenomai-git] Philippe Gerum : Revert "copperplate/heapobj-pshared: fix memory limit"
Module: xenomai-3 Branch: stable-3.0.x Commit: 63621418456fa55a7ce1825bbcc8550bc5c275a6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=63621418456fa55a7ce1825bbcc8550bc5c275a6 Author: Philippe GerumDate: Thu Apr 19 19:18:28 2018 +0200 Revert "copperplate/heapobj-pshared: fix memory limit" This reverts commit 5b0c3677fa15397ab7d8e609685f8b4259d62fde which was wrong and fortunately did not survive the upcoming memcheck tests. --- lib/copperplate/heapobj-pshared.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index 0a3c24e..a3c5484 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -226,7 +226,7 @@ static int init_heap(struct shared_heap *heap, void *base, extent->bitmap = __shoff(base, mem) + bmapoff; extent->bitwords = bmapwords; extent->membase = __shoff(base, mem) + metasz; - extent->memlim = __shoff(base, mem) + size; + extent->memlim = extent->membase + size; init_extent(base, extent); __list_append(base, >link, >extents); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] New commits on branch next
URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=11be709384b4bd8b905a6416e54018c58be1ec0c Author: Jan KiszkaDate: Wed Apr 18 14:51:00 2018 +0200 cobalt/synch: Clear PP boost prior to handing over the ownership Otherwise we first add the synch object to the new owner's boost list before we remove it from the old one's, corrupting the list. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f10fa418179ba745d4dd035793fe11a3da97a7d0 Author: Jan Kiszka Date: Wed Apr 18 14:51:00 2018 +0200 testsuite/smokey: Add handover test for prio-ceiling mutexes This triggers a bug in the PP implementation. Signed-off-by: Jan Kiszka URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=07c5612c7203772ccb00d72b5151ec6fddd5b016 Author: Philippe Gerum Date: Fri Mar 30 15:01:40 2018 +0200 net/via-rhine: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=495fed5cc7265e2abc2243ca78640a93b99f3cfb Author: Philippe Gerum Date: Fri Mar 30 15:01:30 2018 +0200 net/tulip: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a817725d153c64cf6d0370561390b9292ea1f956 Author: Philippe Gerum Date: Fri Mar 30 15:01:23 2018 +0200 net/r8169: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=190293fff00faeecb8da6ba384340a6dbc89f380 Author: Philippe Gerum Date: Fri Mar 30 15:01:10 2018 +0200 net/pcnet32: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cf865dca3a14f20c72d9994f5410cfcd66235e19 Author: Philippe Gerum Date: Fri Mar 30 15:01:02 2018 +0200 net/natsemi: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c225161387ece92eb2b0c1261de8a34dadda2ad8 Author: Philippe Gerum Date: Fri Mar 30 15:00:56 2018 +0200 net/macb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c94128bd5a4912f5b64cca3905b8a11a4c923d12 Author: Philippe Gerum Date: Fri Mar 30 15:00:48 2018 +0200 net/fec: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4ad59ee7f857fa11307e78acd3ba25f71c640e7 Author: Philippe Gerum Date: Fri Mar 30 15:00:39 2018 +0200 net/eepro100: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=361434d97909704551b56a1990a437496305b6b3 Author: Philippe Gerum Date: Fri Mar 30 15:00:26 2018 +0200 net/e1000: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=989539aa897a0d96570feee043455c81f11a8914 Author: Philippe Gerum Date: Fri Mar 30 15:00:02 2018 +0200 net/at91: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b24180b04b1e3ad1477fb4e5ddb41a4ffe833961 Author: Philippe Gerum Date: Fri Mar 30 14:59:51 2018 +0200 net/8139too: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e8abb0cb89338e128eb2a771b6133207aa9ed2c8 Author: Philippe Gerum Date: Fri Mar 30 13:09:19 2018 +0200 net/igb: add adapter symlink into sysfs attributes URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20e11a6dfdfe30032d79a20d768c72e44970a136 Author: Philippe Gerum Date: Fri Mar 30 12:53:34 2018 +0200 net: create sysfs nodes for net devices Each rtnet device registered with the stack is represented by a node into /sys/devices/virtual/rtnet/. Setting the address of the real device probed by the kernel into the rtnet_device.sysbind field before calling rt_register_rtnetdev(), causes the "adapter" symlink to be installed in the newly created attribute directory, pointing at that device. e.g. static int probe_handler(struct pci_dev *pdev, const struct pci_device_id *ent) { ... rtdev->sysbind = >dev; ... ret = rt_register_rtnetdev(rtdev); ... } $ ls -l /sys/devices/virtual/rtnet/ total 0 drwxr-xr-x2 root root 0 Mar 30 12:50 enp1s0 drwxr-xr-x2 root root 0 Mar 30 12:50 rtlo $ ls -l /sys/devices/virtual/rtnet/enp1s0/ total 0 lrwxrwxrwx1 root root 0 Mar 30 12:51 adapter -> ../../../pci:00/:00:13.0/:01:00.0 lrwxrwxrwx1 root root 0 Mar 30 12:51
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix off-by-one error in pagemap reset
Module: xenomai-3 Branch: stable-3.0.x Commit: 5abb09dab0035263b0f6233d54795230cdb8f37e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5abb09dab0035263b0f6233d54795230cdb8f37e Author: Philippe GerumDate: Thu Apr 19 11:01:49 2018 +0200 copperplate/heapobj-pshared: fix off-by-one error in pagemap reset --- lib/copperplate/heapobj-pshared.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index e523ce8..0a3c24e 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -156,7 +156,7 @@ static void init_extent(void *base, struct shared_extent *extent) assert(lastpgnum >= 1); /* Mark all pages as free in the page map. */ - memset(extent->pagemap, 0, lastpgnum * sizeof(struct page_entry)); + memset(extent->pagemap, 0, (lastpgnum + 1) * sizeof(struct page_entry)); /* Clear the allocation bitmap. */ p = __shref(base, extent->bitmap); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Greg Gallagher : cobalt/rtdm: Increase RTDM_MAX_MINOR to 4096 form 1024
Module: xenomai-3 Branch: stable-3.0.x Commit: 0e0dee05a511e14139b8c1c1e25b84662feed4d3 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0e0dee05a511e14139b8c1c1e25b84662feed4d3 Author: Greg GallagherDate: Thu Apr 19 06:14:00 2018 +0200 cobalt/rtdm: Increase RTDM_MAX_MINOR to 4096 form 1024 Increase the number of RTDM devices that are allowed to be registered to 4096 to allow gpio drivers with higher pin numbers to be able to register in rtdm space. --- include/cobalt/kernel/rtdm/driver.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index 63beb48..5a20585 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -94,7 +94,7 @@ enum rtdm_selecttype; /** @} Device Flags */ /** Maximum number of named devices per driver. */ -#define RTDM_MAX_MINOR 1024 +#define RTDM_MAX_MINOR 4096 /** @} rtdm_device_register */ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: fix memory limit
Module: xenomai-3 Branch: stable-3.0.x Commit: 5b0c3677fa15397ab7d8e609685f8b4259d62fde URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5b0c3677fa15397ab7d8e609685f8b4259d62fde Author: Philippe GerumDate: Thu Apr 19 11:00:06 2018 +0200 copperplate/heapobj-pshared: fix memory limit --- lib/copperplate/heapobj-pshared.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index 03d6eaa..e523ce8 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -226,7 +226,7 @@ static int init_heap(struct shared_heap *heap, void *base, extent->bitmap = __shoff(base, mem) + bmapoff; extent->bitwords = bmapwords; extent->membase = __shoff(base, mem) + metasz; - extent->memlim = extent->membase + size; + extent->memlim = __shoff(base, mem) + size; init_extent(base, extent); __list_append(base, >link, >extents); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : scripts: histo.gp: fix spelling in label
Module: xenomai-3 Branch: stable-3.0.x Commit: e34036b36908eef04b1c788d6e53fdd4adfdb944 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e34036b36908eef04b1c788d6e53fdd4adfdb944 Author: Philippe GerumDate: Thu Apr 19 10:15:10 2018 +0200 scripts: histo.gp: fix spelling in label --- scripts/histo.gp |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/histo.gp b/scripts/histo.gp index bde779d..624a174 100644 --- a/scripts/histo.gp +++ b/scripts/histo.gp @@ -11,7 +11,7 @@ set output output_file set title graph_title set xlabel "user-space latency in microseconds" -set ylabel "occurences + 1 (log)" +set ylabel "occurrences + 1 (log)" set logscale y set key off set grid ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/gpio: mxc: look for imx7d devices
Module: xenomai-3 Branch: stable-3.0.x Commit: 2f07eda4df8d00b028c711fe94c7dc2091f6e4ff URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2f07eda4df8d00b028c711fe94c7dc2091f6e4ff Author: Philippe GerumDate: Thu Apr 19 10:22:02 2018 +0200 drivers/gpio: mxc: look for imx7d devices --- kernel/drivers/gpio/gpio-mxc.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/drivers/gpio/gpio-mxc.c b/kernel/drivers/gpio/gpio-mxc.c index e204fe0..7b28111 100644 --- a/kernel/drivers/gpio/gpio-mxc.c +++ b/kernel/drivers/gpio/gpio-mxc.c @@ -20,10 +20,16 @@ #define RTDM_SUBCLASS_MXC 2 +static const char *compat_array[] = { + "fsl,imx6q-gpio", + "fsl,imx7d-gpio", +}; + static int __init mxc_gpio_init(void) { - return rtdm_gpiochip_scan_of(NULL, "fsl,imx6q-gpio", -RTDM_SUBCLASS_MXC); + return rtdm_gpiochip_scan_array_of(NULL, compat_array, + ARRAY_SIZE(compat_array), + RTDM_SUBCLASS_MXC); } module_init(mxc_gpio_init); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/gpio: core: add OF-based scanner searching for multiple compat strings
Module: xenomai-3 Branch: stable-3.0.x Commit: a2262d5b85f35df485b726c93783a28336024850 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a2262d5b85f35df485b726c93783a28336024850 Author: Philippe GerumDate: Thu Apr 19 10:21:01 2018 +0200 drivers/gpio: core: add OF-based scanner searching for multiple compat strings --- include/cobalt/kernel/rtdm/gpio.h |4 kernel/drivers/gpio/gpio-core.c | 19 +++ 2 files changed, 23 insertions(+) diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h index 378a678..cdb472f 100644 --- a/include/cobalt/kernel/rtdm/gpio.h +++ b/include/cobalt/kernel/rtdm/gpio.h @@ -65,6 +65,10 @@ int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc, int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat, int type); +int rtdm_gpiochip_scan_array_of(struct device_node *from, + const char *compat[], + int nentries, int type); + void rtdm_gpiochip_remove_of(int type); #endif diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c index 3e97547..a27c9ee 100644 --- a/kernel/drivers/gpio/gpio-core.c +++ b/kernel/drivers/gpio/gpio-core.c @@ -571,6 +571,25 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat, } EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_of); +int rtdm_gpiochip_scan_array_of(struct device_node *from, + const char *compat[], + int nentries, int type) +{ + int ret = -ENODEV, _ret, n; + + for (n = 0; n < nentries; n++) { + _ret = rtdm_gpiochip_scan_of(from, compat[n], type); + if (_ret) { + if (_ret != -ENODEV) + return _ret; + } else + ret = 0; + } + + return ret; +} +EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_array_of); + void rtdm_gpiochip_remove_of(int type) { struct rtdm_gpio_chip *rgc, *n; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/gpio: core: lock gpio_chip list while scanning for removal
Module: xenomai-3 Branch: stable-3.0.x Commit: 144746346a118ac368935b8b9ea14f4677cf8e96 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=144746346a118ac368935b8b9ea14f4677cf8e96 Author: Philippe GerumDate: Thu Apr 19 10:28:40 2018 +0200 drivers/gpio: core: lock gpio_chip list while scanning for removal --- kernel/drivers/gpio/gpio-core.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c index a27c9ee..3ce73db 100644 --- a/kernel/drivers/gpio/gpio-core.c +++ b/kernel/drivers/gpio/gpio-core.c @@ -597,12 +597,18 @@ void rtdm_gpiochip_remove_of(int type) if (!realtime_core_enabled()) return; + mutex_lock(_lock); + list_for_each_entry_safe(rgc, n, _gpio_chips, next) { if (rgc->driver.profile_info.subclass_id == type) { + mutex_unlock(_lock); rtdm_gpiochip_remove(rgc); kfree(rgc); + mutex_lock(_lock); } } + + mutex_unlock(_lock); } EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove_of); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/threadobj: do not leak the periodic timer
Module: xenomai-3 Branch: stable-3.0.x Commit: 7fffb2630c8358ed7b1654aaf4a200ea28981e93 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7fffb2630c8358ed7b1654aaf4a200ea28981e93 Author: Philippe GerumDate: Wed Apr 18 20:10:31 2018 +0200 copperplate/threadobj: do not leak the periodic timer --- lib/copperplate/threadobj.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index d9e9267..a1a805a 100644 --- a/lib/copperplate/threadobj.c +++ b/lib/copperplate/threadobj.c @@ -1631,6 +1631,14 @@ int threadobj_set_periodic(struct threadobj *thobj, __threadobj_check_locked(thobj); timer = thobj->periodic_timer; + if (!timespec_scalar(idate) && !timespec_scalar(period)) { + if (timer) { + thobj->periodic_timer = NULL; + __RT(timer_delete(timer)); + } + return 0; + } + if (timer == NULL) { memset(, 0, sizeof(sev)); sev.sigev_signo = SIGPERIOD; @@ -1640,8 +1648,7 @@ int threadobj_set_periodic(struct threadobj *thobj, if (ret) return __bt(-errno); thobj->periodic_timer = timer; - } else if (!timespec_scalar(idate) && !timespec_scalar(period)) - thobj->periodic_timer = NULL; + } its.it_value = *idate; its.it_interval = *period; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git