[Xenomai-git] New commits on branch next

2018-05-15 Thread git repository hosting
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fd9e8604482f226761f812054ffb48beb1daaf58
Author: Jan Kiszka 
Date:   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 
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=66b51c7653d648ca71c60f13e6962794441c16d9
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 add

[Xenomai-git] Philippe Gerum : testsuite/smokey: add test suite for memory allocators

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: f71ced70e583c12913b278460256e0ae5ce71697
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f71ced70e583c12913b278460256e0ae5ce71697

Author: Philippe Gerum 
Date:   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;
+   k = (unsigned int)

[Xenomai-git] New commits on branch wip/heapmem

2018-05-15 Thread git repository hosting
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a651f0ccce8eb10a36edceb60d69552cd08d1a0e
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) ...

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:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6151bccac48b4be175e131cdba71a2ae602ec670
Author: Philippe Gerum 
Date:   Sun Apr 22 19:50:57 2018 +0200

copperplate/

[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: add helper to return the total heap size

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 9ce3b7413d520e52daacd70574ed9260e7d4cabb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9ce3b7413d520e52daacd70574ed9260e7d4cabb

Author: Philippe Gerum 
Date:   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(&main_heap.heap, size);


___
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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: d082061b4bddcac8a13bca899a9c9d646c2ab80d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d082061b4bddcac8a13bca899a9c9d646c2ab80d

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 

---

 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(&nklock, 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] Philippe Gerum : smokey: add helper to retrieve size expr

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 056f0174f341033ab1523314ed21a2facdc5a90f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=056f0174f341033ab1523314ed21a2facdc5a90f

Author: Philippe Gerum 
Date:   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]", &name, &p);
+   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: edde4308feb872e4885ff50329c2c9beb56757f4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=edde4308feb872e4885ff50329c2c9beb56757f4

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) ...

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 */
-#define XNHEAP_NBUCKE

[Xenomai-git] Philippe Gerum : testsuite/smokey: memcheck: fix test heap sizes

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: feaa056501a5d911174838519bf7432b0d90
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=feaa056501a5d911174838519bf7432b0d90

Author: Philippe Gerum 
Date:   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, &idle, 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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 8d01ea11657cbdd88b6cab4c6a0238e9e9dc992c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8d01ea11657cbdd88b6cab4c6a0238e9e9dc992c

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.

---

 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 the first page of
+ * a range o

[Xenomai-git] Philippe Gerum : boilerplate: compiler: add more helpers and attribute tags

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: c0662ac69fbb02b29b744059ea84cc493754d7b2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c0662ac69fbb02b29b744059ea84cc493754d7b2

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 9cf7116e796d6d29d42c67a8231dbddc889ccf41
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9cf7116e796d6d29d42c67a8231dbddc889ccf41

Author: Philippe Gerum 
Date:   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(&heapmem_main, size);
+}
+
+static inline void pvfree(void *ptr)
+{
+   heapmem_free(&heapmem_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 
 
@@ -17

[Xenomai-git] Philippe Gerum : boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: cc4a1bdbb35f9ea81de6fba84a774284c3a98bc0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cc4a1bdbb35f9ea81de6fba84a774284c3a98bc0

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: c1e8aa62e38700845c99d9b2d7e31867524ecc2c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c1e8aa62e38700845c99d9b2d7e31867524ecc2c

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: da8c788699a8e174c3709e57a5de88ae45944740
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=da8c788699a8e174c3709e57a5de88ae45944740

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 8ae78f22f49024090218d55487db85e842a9f877
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8ae78f22f49024090218d55487db85e842a9f877

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'.

---

 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  (1thr &= ~(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)
 
-void avl_destroy(struct avl *avl);
+#define avlh_thr_tst(avl, holder, side) (avlh_link(avl, holder, side) == NULL)
+#define avlh_child(avl, holder, side) (av

[Xenomai-git] Philippe Gerum : smokey: argument accessors using variables

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: dc3347e4054d0facf34675a27dc315c953d42869
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dc3347e4054d0facf34675a27dc315c953d42869

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 410a4cc1109ba4e0d05b7ece7b4a5210287e1183
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=410a4cc1109ba4e0d05b7ece7b4a5210287e1183

Author: Jan Kiszka 
Date:   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(&mattr);
pthread_mutexattr_settype(&mattr, type);
-#ifdef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
-   if (pi != 0)
-   pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
-
-   err = pthread_mutex_init(mutex, &mattr);
-#else
-   if (pi != 0) {
-   err = ENOSYS;
+   err = pthread_mutexattr_setprotocol(&mattr, proto);
+   if (err)
goto out;
-   }
-   err = pthread_mutex_init(mutex, &mattr);
+   if (proto == PTHREAD_PRIO_PROTECT)
+   pthread_mutexattr_setprioceiling(&mattr, 3);
 
+   err = pthread_mutex_init(mutex, &mattr);
   out:
-#endif
pthread_mutexattr_destroy(&mattr);
 
return -err;
@@ -217,7 +211,8 @@ static void autoinit_simple_condwait(void)
 
smokey_trace("%s", __func__);
 
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
check("thread_spawn",
  thread_spawn(&cond_signaler_tid, 2, cond_signaler, &cm), 0);
@@ -246,7 +241,8 @@ static void simple_condwait(void)
 
smokey_trace("%s", __func__);
 
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("cond_init", cond_init(&cond, 0), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
check("thread_spawn",
@@ -271,7 +267,8 @@ static void relative_condwait(void)
 
smokey_trace("%s", __func__);
 
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("cond_init", cond_init(&cond, 0), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
 
@@ -294,7 +291,8 @@ static void autoinit_absolute_condwait(void)
 
smokey_trace("%s", __func__);
 
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
 
start = timer_get_tsc();
@@ -316,7 +314,8 @@ static void absolute_condwait(void)
 
smokey_trace("%s", __func__);
 
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("cond_init", cond_init(&cond, 1), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
 
@@ -373,7 +372,8 @@ static void sig_norestart_condwait(void)
smokey_trace("%s", __func__);
 
check_unix("sigaction", sigaction(SIGRTMIN, &sa, NULL), 0);
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  PTHREAD_PRIO_NONE), 0);
check("cond_init", cond_init(&cond, 0), 0);
check("mutex_lock", mutex_lock(&mutex), 0);
check("thread_spawn",
@@ -411,7 +411,8 @@ static void sig_restart_condwait(void)
smokey_trace("%s", __func__);
 
check_unix("sigaction", sigaction(SIGRTMIN, &sa, NULL), 0);
-   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT, 0), 0);
+   check("mutex_init", mutex_init(&mutex, PTHREAD_MUTEX_DEFAULT,
+  

[Xenomai-git] Philippe Gerum : cobalt/heap: rebase on HEAPMEM algorithm

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: 55b21ebe8a44f75f74c0a3a9e885fd3096d8327c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=55b21ebe8a44f75f74c0a3a9e885fd3096d8327c

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) ...

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 */
-#define XNHEAP_NBUCKE

[Xenomai-git] Philippe Gerum : boilerplate/heapmem: align on HEAPMEM_PAGE_SIZE for non-bucketed blocks

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: d488470dfdef89fb981799bab18c322b15eae6d5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d488470dfdef89fb981799bab18c322b15eae6d5

Author: Philippe Gerum 
Date:   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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: d032d8c0fdf7f19ab45f86669f3cede931020956
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d032d8c0fdf7f19ab45f86669f3cede931020956

Author: Philippe Gerum 
Date:   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, &idle, 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

2018-05-15 Thread git repository hosting
Module: xenomai-3
Branch: wip/heapmem
Commit: d2943ff0cf2ce890e4980fe9776465053513a15f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d2943ff0cf2ce890e4980fe9776465053513a15f

Author: Philippe Gerum 
Date:   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