All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Leopold Palomo-Avellaneda <leo@alaxarxa.net>,
	"Xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Cannot initialize TLSF memory manager
Date: Thu, 23 Nov 2017 16:29:29 +0100	[thread overview]
Message-ID: <6d2aee3e-2ddc-3008-f00e-a350030efcf3@xenomai.org> (raw)
In-Reply-To: <52b92049-fcaa-8d48-8e89-516fc6f0ab21@alaxarxa.net>

On 11/23/2017 04:15 PM, Leopold Palomo-Avellaneda wrote:
> On 23/11/17 16:12, Philippe Gerum wrote:
>> On 11/23/2017 04:08 PM, Leopold Palomo-Avellaneda wrote:
>>> On 23/11/17 16:04, Philippe Gerum wrote:
>>>> On 11/23/2017 03:58 PM, Leopold Palomo-Avellaneda wrote:
>>>>> On 23/11/17 13:22, Philippe Gerum wrote:
>>>>>> On 11/23/2017 01:10 PM, Leopold Palomo-Avellaneda wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>>
>>>>>>> I have seen this bug before, but it seems that it's again in 3.0.6. Running
>>>>>>> 3.0.6 with:
>>>>>>>
>>>>>>>  xeno-config --info
>>>>>>> Xenomai version: Xenomai/cobalt v3.0.6
>>>>>>> Linux bmm3 4.9.51-xenomai-3.0.6-ipipe #1 SMP Thu Nov 23 09:03:27 CET 2017 x86_64
>>>>>>> GNU/Linux
>>>>>>> Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.9.51-xenomai-3.0.6-ipipe
>>>>>>> root=UUID=ab96eed9-cd79-4d30-9e93-e9f32a18cca6 ro quiet
>>>>>>> xenomai.allowed_group=113 nosmap
>>>>>>> I-pipe release #4 detected
>>>>>>> Cobalt core 3.0.6 detected
>>>>>>> Compiler: gcc version 6.3.0 20170516 (Debian 6.3.0-18)
>>>>>>> Build args: --build=x86_64-linux-gnu --includedir=/usr/include
>>>>>>> --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc
>>>>>>> --localstatedir=/var --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu
>>>>>>> --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode
>>>>>>> --disable-dependency-tracking --prefix=/usr --includedir=/usr/include/xenomai
>>>>>>> --mandir=/usr/share/man --with-testdir=/usr/lib/x86_64-linux-gnu/xenomai
>>>>>>> --enable-fortify --libdir=/usr/lib/x86_64-linux-gnu/ --enable-pshared
>>>>>>> --enable-registry --enable-doc-build --enable-dlopen-libs --enable-tls
>>>>>>> --enable-smp --with-core=cobalt --build x86_64-linux-gnu
>>>>>>> build_alias=x86_64-linux-gnu CFLAGS=-g -O2
>>>>>>> -fdebug-prefix-map=/build/xenomai-3.0.6+ds1=. -fstack-protector-strong -Wformat
>>>>>>> -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fno-omit-frame-pointer
>>>>>>> LDFLAGS=-Wl,-z,relro -Wl,-z,now -Wl,--as-needed CPPFLAGS=-Wdate-time
>>>>>>> -D_FORTIFY_SOURCE=2
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> when I try xeno-test, I got:
>>>>>>>
>>>>>>>  xeno-test
>>>>>>> Started child 2593: /bin/bash
>>>>>>> /usr/lib/x86_64-linux-gnu/xenomai/xeno-test-run-wrapper /usr/bin/xeno-test
>>>>>>> ++ echo 0
>>>>>>> ++ testdir=/usr/lib/x86_64-linux-gnu/xenomai
>>>>>>> ++ /usr/lib/x86_64-linux-gnu/xenomai/smokey --run
>>>>>>> init_memory_pool(): invalid pool
>>>>>>>    0"000.022| BUG in heapobj_pkg_init_private(): [main] cannot initialize TLSF
>>>>>>> memory manager
>>>>>>>
>>>>>>>
>>>>>>> Any idea?
>>>>>>>
>>>>>>
>>>>>> Can you check whether the call to tlsf_malloc() in
>>>>>> heapobj_pkg_init_private() returns non-NULL?
>>>>>> (lib/copperplate/heapobj-tlsf.c), and print out the value of alloc_size too?
>>>>>
>>>>> Checking the code, it fails before to return anything. Running crosss-link, that
>>>>> fails in the same function:
>>>>> ./cross-link
>>>>>
>>>>> init_memory_pool(): invalid pool
>>>>> Init memory pool returns -1 bytes
>>>>>    0"000.041| BUG in heapobj_pkg_init_private(): [main] cannot initialize TLSF
>>>>> memory manager
>>>>>
>>>>>
>>>>> I just added:
>>>>>
>>>>> +      printf("Init memory pool returns %zd bytes \n", available_size);
>>>>>
>>>>>         if (available_size == (size_t)-1)
>>>>>                 panic("cannot initialize TLSF memory manager");
>>>>>
>>>>> +     printf("Running after ...\n");
>>>>>
>>>>>
>>>>> in that function of the file you mentioned.
>>>>>
>>>>
>>>> Can you try this?
>>>>
>>>> diff --git a/lib/copperplate/heapobj-tlsf.c b/lib/copperplate/heapobj-tlsf.c
>>>> index 370985210..0186be423 100644
>>>> --- a/lib/copperplate/heapobj-tlsf.c
>>>> +++ b/lib/copperplate/heapobj-tlsf.c
>>>> @@ -103,6 +103,7 @@ int heapobj_pkg_init_private(void)
>>>>  	 * out the allocation overhead.
>>>>  	 */
>>>>  	mem = tlsf_malloc(alloc_size);
>>>> +	printf("mem=%p, alloc_size=%zu\n", mem, alloc_size);
>>>>  	available_size = init_memory_pool(alloc_size, mem);
>>>>  	if (available_size == (size_t)-1)
>>>>  		panic("cannot initialize TLSF memory manager");
>>>>
>>> ./cross-link
>>> mem=0x7f70b739a8e0, alloc_size=4096
>>> init_memory_pool(): invalid pool
>>> Init memory pool returns -1 bytes
>>>    0"000.029| BUG in heapobj_pkg_init_private(): [main] cannot initialize TLSF
>>> memory manager
>>>
>>
>> Ok, so please try this:
>>
>> diff --git a/lib/copperplate/heapobj-tlsf.c b/lib/copperplate/heapobj-tlsf.c
>> index 370985210..948f7fc52 100644
>> --- a/lib/copperplate/heapobj-tlsf.c
>> +++ b/lib/copperplate/heapobj-tlsf.c
>> @@ -78,7 +78,7 @@ int heapobj_init_array_private(struct heapobj *hobj, const char *name,
>>  int heapobj_pkg_init_private(void)
>>  {
>>  	#ifdef CONFIG_XENO_PSHARED
>> -		size_t alloc_size = sysconf(_SC_PAGE_SIZE);
>> +		size_t alloc_size = sysconf(_SC_PAGE_SIZE) * 2;
>>  	#else
>>  		size_t alloc_size = __copperplate_setup_data.mem_pool;
>>  	#endif
>>
>>
> 
> with my user
> 
> ./cross-link
> mem=0x7f0d630488e0, alloc_size=8192
> Init memory pool returns 1808 bytes
> Running after ...
> sysregd:
> create_directory_recursive("/var/run/xenomai/leopold.palomo/anon@19479"):
> Permission denied
> sysregd:
> create_directory_recursive("/var/run/xenomai/leopold.palomo/anon@19479"):
> Permission denied
> sysregd:
> create_directory_recursive("/var/run/xenomai/leopold.palomo/anon@19479"):
> Permission denied
>    0"610.664| WARNING: [main] cannot connect to registry daemon
>    0"610.798| WARNING: [main] setup call copperplate failed
>    0"610.830| BUG in __xenomai_init(): [main] initialization failed, EAGAIN
> 
> with sudo ...
> 
> leopold.palomo@bmm3 ~/xenomai/xenomai-3.0.6/system/demo$ sudo ./cross-link
> mem=0x7fc9e73f88e0, alloc_size=8192
> Init memory pool returns 1808 bytes
> Running after ...
> mem=0x7f2e146318e0, alloc_size=8192
> Init memory pool returns 1808 bytes
> Running after ...
> main : can't open /dev/rtdm/rtser0 (write), No such file or directory
> 
> 
> seems you are near ....
> 

The two issues are unrelated AFAICT. The memory init issue is gone, and
I can explain why. The Permission denied issue is odd though, and you
may want to check /var/run/xenomai for perms.

Not being able to open rtser0 is yet another kind of problem: the uart
driver is not up and running, so the devices were not created. crosslink
definitely needs such driver.

-- 
Philippe.


  reply	other threads:[~2017-11-23 15:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 12:10 [Xenomai] Cannot initialize TLSF memory manager Leopold Palomo-Avellaneda
2017-11-23 12:22 ` Philippe Gerum
2017-11-23 14:58   ` Leopold Palomo-Avellaneda
2017-11-23 15:04     ` Philippe Gerum
2017-11-23 15:08       ` Leopold Palomo-Avellaneda
2017-11-23 15:12         ` Philippe Gerum
2017-11-23 15:15           ` Leopold Palomo-Avellaneda
2017-11-23 15:29             ` Philippe Gerum [this message]
2017-11-24 10:34               ` [Xenomai] Testing 3.0.6 (Was Re: Cannot initialize TLSF memory manager) Leopold Palomo-Avellaneda
2017-11-24 10:55                 ` Philippe Gerum
2017-11-24 12:01                   ` Leopold Palomo-Avellaneda
2017-11-24 12:04                     ` Philippe Gerum
2017-11-24 12:10                       ` Leopold Palomo-Avellaneda
2017-11-24 12:22                         ` Philippe Gerum
2017-11-24 12:24                           ` Leopold Palomo-Avellaneda
2017-11-24 14:21                             ` Philippe Gerum
2017-11-24 14:38                               ` Leopold Palomo-Avellaneda
2017-11-25 20:27                                 ` Philippe Gerum
2017-11-23 15:04     ` [Xenomai] Cannot initialize TLSF memory manager Leopold Palomo-Avellaneda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d2aee3e-2ddc-3008-f00e-a350030efcf3@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=leo@alaxarxa.net \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.