All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-16 22:08 [Xenomai-help] ENXIO error with large shared memory Henry Bausley
@ 2009-03-16 21:31 ` Gilles Chanteperdrix
  2009-03-17  0:49 ` Henry Bausley
  1 sibling, 0 replies; 9+ messages in thread
From: Gilles Chanteperdrix @ 2009-03-16 21:31 UTC (permalink / raw)
  To: Henry Bausley; +Cc: xenomai

Henry Bausley wrote:
> I am trying to map a large shared memory buffer and cannot seem to map 32M.
> I get the error code ENXIO back from the posix skin mmap.
> 
> The code works for
>   ftruncate(prgshmfd, 16777216);
>   pPrgShm = mmap(NULL, 16777216, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);
> but fails if I have
>   ftruncate(prgshmfd, 16777216*2);

What if you checked the return value of ftruncate here ?

>   pPrgShm = mmap(NULL, 16777216*2, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);
> 

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Xenomai-help] ENXIO error with large shared memory
@ 2009-03-16 22:08 Henry Bausley
  2009-03-16 21:31 ` Gilles Chanteperdrix
  2009-03-17  0:49 ` Henry Bausley
  0 siblings, 2 replies; 9+ messages in thread
From: Henry Bausley @ 2009-03-16 22:08 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

I am trying to map a large shared memory buffer and cannot seem to map 32M.
I get the error code ENXIO back from the posix skin mmap.

The code works for
  ftruncate(prgshmfd, 16777216);
  pPrgShm = mmap(NULL, 16777216, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);
but fails if I have
  ftruncate(prgshmfd, 16777216*2);
  pPrgShm = mmap(NULL, 16777216*2, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);


The condition failing is mmap in xenomai/skins/posix/shm.c. 

 if (!shm->addr || off + len > shm->size) 
        {
   err = ENXIO;
   up(&shm->maplock);
   goto err_free_map;
 }


For  16M
len = 0x1000000 and shm->size = 0x1000000

For 32M
len = 0x2000000 and shm->size = 0x1FFF000

Is there something I didn't configure correctly that is limiting my size?


I am currently using 2.4.6 Xenomai, I-pipe 2.2-07 with kernel 2.6.26-denx on a 1Ghz PowerPC 460EX with 2G RAM

**********************************************************
Outbound scan for Spam or Virus by Barracuda at Delta Tau
**********************************************************

[-- Attachment #2: Type: text/html, Size: 1675 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-16 22:08 [Xenomai-help] ENXIO error with large shared memory Henry Bausley
  2009-03-16 21:31 ` Gilles Chanteperdrix
@ 2009-03-17  0:49 ` Henry Bausley
  2009-03-17 15:18   ` Gilles Chanteperdrix
  1 sibling, 1 reply; 9+ messages in thread
From: Henry Bausley @ 2009-03-17  0:49 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

ftruncate returns 0
  ----- Original Message ----- 
  From: Henry Bausley 
  To: xenomai@xenomai.org
  Sent: Monday, March 16, 2009 3:08 PM
  Subject: [Xenomai-help] ENXIO error with large shared memory


  I am trying to map a large shared memory buffer and cannot seem to map 32M.
  I get the error code ENXIO back from the posix skin mmap.

  The code works for
    ftruncate(prgshmfd, 16777216);
    pPrgShm = mmap(NULL, 16777216, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);
  but fails if I have
    ftruncate(prgshmfd, 16777216*2);
    pPrgShm = mmap(NULL, 16777216*2, PROT_READ | PROT_WRITE, MAP_SHARED, prgshmfd, 0);


  The condition failing is mmap in xenomai/skins/posix/shm.c. 

   if (!shm->addr || off + len > shm->size) 
          {
     err = ENXIO;
     up(&shm->maplock);
     goto err_free_map;
   }


  For  16M
  len = 0x1000000 and shm->size = 0x1000000

  For 32M
  len = 0x2000000 and shm->size = 0x1FFF000

  Is there something I didn't configure correctly that is limiting my size?


  I am currently using 2.4.6 Xenomai, I-pipe 2.2-07 with kernel 2.6.26-denx on a 1Ghz PowerPC 460EX with 2G RAM


------------------------------------------------------------------------------


  _______________________________________________
  Xenomai-help mailing list
  Xenomai-help@domain.hid
  https://mail.gna.org/listinfo/xenomai-help

**********************************************************
Outbound scan for Spam or Virus by Barracuda at Delta Tau
**********************************************************

[-- Attachment #2: Type: text/html, Size: 2734 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17  0:49 ` Henry Bausley
@ 2009-03-17 15:18   ` Gilles Chanteperdrix
  2009-03-17 16:08     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2009-03-17 15:18 UTC (permalink / raw)
  To: Henry Bausley; +Cc: xenomai

Henry Bausley wrote:
> ftruncate returns 0

Ok. I think I understood what the problem is, I will try to send a patch
tonight.

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17 15:18   ` Gilles Chanteperdrix
@ 2009-03-17 16:08     ` Gilles Chanteperdrix
  2009-03-17 19:16       ` Henry Bausley
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2009-03-17 16:08 UTC (permalink / raw)
  To: Henry Bausley; +Cc: xenomai

Gilles Chanteperdrix wrote:
> Henry Bausley wrote:
>> ftruncate returns 0
> 
> Ok. I think I understood what the problem is, I will try to send a patch
> tonight.
> 

The following not very subtil patch seems to fix the issue:

Index: include/nucleus/heap.h
===================================================================
--- include/nucleus/heap.h      (revision 4692)
+++ include/nucleus/heap.h      (working copy)
@@ -156,6 +156,7 @@

 static inline size_t xnheap_rounded_size(size_t hsize, size_t psize)
 {
+       size_t rounded_size;
        /*
         * Account for the minimum heap size (i.e. 2 * page size) plus
         * overhead so that the actual heap space is large enough to
@@ -167,7 +168,10 @@
        if (hsize < 2 * psize)
                hsize = 2 * psize;
        hsize += xnheap_overhead(hsize, psize);
-       return xnheap_align(hsize, psize);
+       rounded_size = xnheap_align(hsize, psize);
+       while (rounded_size - xnheap_overhead(rounded_size, psize) < hsize)
+               rounded_size += psize;
+       return rounded_size;
 }

 #ifdef __cplusplus


-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17 19:16       ` Henry Bausley
@ 2009-03-17 18:21         ` Gilles Chanteperdrix
  2009-08-13 23:12           ` Henry Bausley
  2009-03-17 18:23         ` Gilles Chanteperdrix
  1 sibling, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2009-03-17 18:21 UTC (permalink / raw)
  To: Henry Bausley; +Cc: xenomai

Henry Bausley wrote:
> The patch makes it work for 32M.  However if I try to go larger ie.48M or 
> 64M I get the following

Do you get the same error if you only run a simple program that does
such a big allocation ?

In other words, is it the big allocation by itself which causes this
"badness" or the accumulation of allocations (and possible memory
corruption).

You should be aware that the vmalloc space also has limits. Why do you
need to share such big areas between kernel and user-space ?

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17 19:16       ` Henry Bausley
  2009-03-17 18:21         ` Gilles Chanteperdrix
@ 2009-03-17 18:23         ` Gilles Chanteperdrix
  1 sibling, 0 replies; 9+ messages in thread
From: Gilles Chanteperdrix @ 2009-03-17 18:23 UTC (permalink / raw)
  To: Henry Bausley; +Cc: xenomai

Henry Bausley wrote:
> The patch makes it work for 32M.  However if I try to go larger ie.48M or 
> 64M I get the following
> 
> 
>   Program buffer: 67108864
>      User buffer: 1048576
>     Table buffer: 1048576
> LookAhead buffer: 16777216
> RT User Program ftruncate No Error
> ------------[ cut here ]------------
> Badness at c00b6a94 [verbose debug info unavailable]

Please compile the kernel with more debug options so thatwe know exactly
where this badness happens.

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17 16:08     ` Gilles Chanteperdrix
@ 2009-03-17 19:16       ` Henry Bausley
  2009-03-17 18:21         ` Gilles Chanteperdrix
  2009-03-17 18:23         ` Gilles Chanteperdrix
  0 siblings, 2 replies; 9+ messages in thread
From: Henry Bausley @ 2009-03-17 19:16 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

The patch makes it work for 32M.  However if I try to go larger ie.48M or 
64M I get the following


  Program buffer: 67108864
     User buffer: 1048576
    Table buffer: 1048576
LookAhead buffer: 16777216
RT User Program ftruncate No Error
------------[ cut here ]------------
Badness at c00b6a94 [verbose debug info unavailable]
NIP: c00b6a94 LR: c00b7064 CTR: 00000000
REGS: ef1edbe0 TRAP: 0700   Not tainted  (2.6.26.8)
MSR: 00029000 <EE,ME>  CR: 48008248  XER: 00000007
TASK = ef8f75a0[2143] 'insmod' THREAD: ef1ec000
GPR00: 00000001 ef1edc90 ef8f75a0 ef1716c0 0000033b ef1edcc8 c1727978 
ffffffff
GPR08: ef817800 00000000 c1726be0 ef034a54 88008284 100197d8 f4fc0000 
f4fc0cf0
GPR16: f4fc0d2c ef9a106c c040b228 f4fc0000 ef1edd30 00101420 ffc00ffd 
c03f0000
GPR24: 0000033b ef1716c0 ff16cfff c03cafe0 ff16d000 ef1edcc8 ff16d000 
ff100000
NIP [c00b6a94] map_vm_area+0xb0/0x174
LR [c00b7064] __vmalloc_area_node+0xd8/0x164
Call Trace:
[ef1edc90] [00101420] 0x101420 (unreliable)
[ef1edcc0] [c00b7064] __vmalloc_area_node+0xd8/0x164
[ef1edcf0] [c0051ff8] xnheap_init_mapped+0x13c/0x4a8
[ef1edd20] [c0094324] ftruncate+0x3a0/0x528
[ef1edd80] [f4fa2c5c] init_module+0x374/0x91c [rtpmac]
[ef1ede70] [c00476ec] sys_init_module+0x134/0x1784
[ef1edf40] [c000e06c] ret_from_syscall+0x0/0x3c
Instruction dump:
418200cc 57e0bd38 7d090215 41820098 817d0000 81480004 39200000 7d205379
814b0000 38000000 41820008 38000001 <0f000000> 2f8a0000 3bff1000 7f1ef800
------------[ cut here ]------------

----- Original Message ----- 
From: "Gilles Chanteperdrix" <gilles.chanteperdrix@xenomai.org>
To: "Henry Bausley" <hbausley@domain.hid>
Cc: <xenomai@xenomai.org>
Sent: Tuesday, March 17, 2009 9:08 AM
Subject: Re: [Xenomai-help] ENXIO error with large shared memory


> Gilles Chanteperdrix wrote:
>> Henry Bausley wrote:
>>> ftruncate returns 0
>>
>> Ok. I think I understood what the problem is, I will try to send a patch
>> tonight.
>>
>
> The following not very subtil patch seems to fix the issue:
>
> Index: include/nucleus/heap.h
> ===================================================================
> --- include/nucleus/heap.h      (revision 4692)
> +++ include/nucleus/heap.h      (working copy)
> @@ -156,6 +156,7 @@
>
> static inline size_t xnheap_rounded_size(size_t hsize, size_t psize)
> {
> +       size_t rounded_size;
>        /*
>         * Account for the minimum heap size (i.e. 2 * page size) plus
>         * overhead so that the actual heap space is large enough to
> @@ -167,7 +168,10 @@
>        if (hsize < 2 * psize)
>                hsize = 2 * psize;
>        hsize += xnheap_overhead(hsize, psize);
> -       return xnheap_align(hsize, psize);
> +       rounded_size = xnheap_align(hsize, psize);
> +       while (rounded_size - xnheap_overhead(rounded_size, psize) < 
> hsize)
> +               rounded_size += psize;
> +       return rounded_size;
> }
>
> #ifdef __cplusplus
>
>
> -- 
>                                                 Gilles. 



**********************************************************
Outbound scan for Spam or Virus by Barracuda at Delta Tau
**********************************************************


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] ENXIO error with large shared memory
  2009-03-17 18:21         ` Gilles Chanteperdrix
@ 2009-08-13 23:12           ` Henry Bausley
  0 siblings, 0 replies; 9+ messages in thread
From: Henry Bausley @ 2009-08-13 23:12 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

This problems was due to the limits of vmalloc.  To increase
the limit required changing the PAGE_OFFSET

The virtual address space used by vmalloc() is in the
range of VMALLOC_START and VMALLOC_END. If
CONFIG_HIGMEM is defined while building the kernel (it
will be, if the machine has more than 1GB memory), and
the PAGE_OFFSET is the default value of 0xc0000000,
this range is approximately 0xf8000000 to 0xfe000000.
This is about 96MB.
from ->  http://mail.nl.linux.org/kernelnewbies/2001-12/msg00004.html


then changed the advanced kernel settings

#
# Advanced setup
#
CONFIG_ADVANCED_OPTIONS=y
# CONFIG_LOWMEM_SIZE_BOOL is not set
CONFIG_LOWMEM_SIZE=0x30000000
CONFIG_PAGE_OFFSET_BOOL=y
CONFIG_PAGE_OFFSET=0x80000000
CONFIG_KERNEL_START_BOOL=y
CONFIG_KERNEL_START=0x80000000
CONFIG_PHYSICAL_START=0x00000000
CONFIG_TASK_SIZE_BOOL=y
CONFIG_TASK_SIZE=0x80000000
# CONFIG_CONSISTENT_START_BOOL is not set
CONFIG_CONSISTENT_START=0xff100000


from

#
# Advanced setup
#
# CONFIG_ADVANCED_OPTIONS is not set

#
# Default settings for advanced configuration options are used
#
CONFIG_LOWMEM_SIZE=0x30000000
CONFIG_PAGE_OFFSET=0xc0000000
CONFIG_KERNEL_START=0xc0000000
CONFIG_PHYSICAL_START=0x00000000
CONFIG_TASK_SIZE=0xc0000000
CONFIG_CONSISTENT_START=0xff100000
CONFIG_CONSISTENT_SIZE=0x00200000
CONFIG_NET=y



----- Original Message ----- 
From: "Gilles Chanteperdrix" <gilles.chanteperdrix@xenomai.org>
To: "Henry Bausley" <hbausley@domain.hid>
Cc: <xenomai@xenomai.org>
Sent: Tuesday, March 17, 2009 10:21 AM
Subject: Re: [Xenomai-help] ENXIO error with large shared memory


> Henry Bausley wrote:
>> The patch makes it work for 32M.  However if I try to go larger ie.48M or
>> 64M I get the following
>
> Do you get the same error if you only run a simple program that does
> such a big allocation ?
>
> In other words, is it the big allocation by itself which causes this
> "badness" or the accumulation of allocations (and possible memory
> corruption).
>
> You should be aware that the vmalloc space also has limits. Why do you
> need to share such big areas between kernel and user-space ?
>
> -- 
>                                                 Gilles. 




**********************************************************
Outbound scan for Spam or Virus by Barracuda at Delta Tau
**********************************************************


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-08-13 23:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-16 22:08 [Xenomai-help] ENXIO error with large shared memory Henry Bausley
2009-03-16 21:31 ` Gilles Chanteperdrix
2009-03-17  0:49 ` Henry Bausley
2009-03-17 15:18   ` Gilles Chanteperdrix
2009-03-17 16:08     ` Gilles Chanteperdrix
2009-03-17 19:16       ` Henry Bausley
2009-03-17 18:21         ` Gilles Chanteperdrix
2009-08-13 23:12           ` Henry Bausley
2009-03-17 18:23         ` Gilles Chanteperdrix

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.