memory leak in epiphany driver

Forum about Parallella boot process, linux kernel, distros, SD-cards, etc.

memory leak in epiphany driver

Postby pharaoh » Sun Jan 17, 2016 3:05 pm

I ran into some trouble playing around with OpenCL on Parallella, see viewtopic.php?f=18&t=3405.

The memory leak seems to be in the epiphy driver. While running the OpenCL code i checked the process memory map with pmap and a diff between two checks showed this:

# diff /tmp/a /tmp/c
5a6,28
> 6b500000 32768K rwxs- /dev/epiphany
> 6d500000 32768K rwxs- /dev/epiphany
> 6f500000 32768K rwxs- /dev/epiphany
> 71500000 32768K rwxs- /dev/epiphany
> 73500000 32768K rwxs- /dev/epiphany
> 75500000 32768K rwxs- /dev/epiphany
> 77500000 32768K rwxs- /dev/epiphany
> 79500000 32768K rwxs- /dev/epiphany
> 7b500000 32768K rwxs- /dev/epiphany
> 7d500000 32768K rwxs- /dev/epiphany
> 7f500000 32768K rwxs- /dev/epiphany
> 81500000 32768K rwxs- /dev/epiphany
> 83500000 32768K rwxs- /dev/epiphany
> 85500000 32768K rwxs- /dev/epiphany
> 87500000 32768K rwxs- /dev/epiphany
> 89500000 32768K rwxs- /dev/epiphany
> 8b500000 32768K rwxs- /dev/epiphany
> 8d500000 32768K rwxs- /dev/epiphany
> 8f500000 32768K rwxs- /dev/epiphany
> 91500000 32768K rwxs- /dev/epiphany
> 93500000 32768K rwxs- /dev/epiphany
> 95500000 32768K rwxs- /dev/epiphany
> 97500000 32768K rwxs- /dev/epiphany
159c182
< total 485248K
---
> total 1238912K


Has anyone an idea what's going on in the driver? Why does the driver allocate more and more 32M chunks? And more importantly: who can fix it?
I'm no kernel developer but i really would like to get this issue resolvd because this bug makes parallella more or less useless.
I would contact the original author Ben Chaco from XCube but havent't found any email adress.
pharaoh
 
Posts: 6
Joined: Sat Jan 16, 2016 1:37 pm

Re: memory leak in epiphany driver

Postby MiguelTasende » Mon Jan 18, 2016 12:46 pm

May be related to this?

viewtopic.php?f=13&t=3326
MiguelTasende
 
Posts: 51
Joined: Tue Jun 30, 2015 12:44 pm

Re: memory leak in epiphany driver

Postby olajep » Mon Jan 18, 2016 2:21 pm

I think it's related to a bug in e_free(). Check this patch for reference:
https://github.com/adapteva/epiphany-li ... af2ee5191c

Please try this code:
Code: Select all
#include <e-hal.h>
#include <epiphany-shm-manager.h>   /* For private APIs */
#include <epiphany-hal-api-local.h>

#define e_free my_e_free

// e_free is broken in ESDK 2015.1 and 2014.11
// Free a memory buffer in external memory
int my_e_free(e_mem_t *mbuf)
{
   if (NULL == mbuf) {
      return E_ERR;
   }

   if (E_SHARED_MEM != mbuf->objtype) {
      // The shared memory mapping is persistent - don't unmap
      munmap(mbuf->mapped_base, mbuf->map_size);
      close(mbuf->memfd);
   }

   return E_OK;
}



Thanks,
Ola
_start = 266470723;
olajep
 
Posts: 140
Joined: Mon Dec 17, 2012 3:24 am
Location: Sweden

Re: memory leak in epiphany driver

Postby pharaoh » Mon Jan 18, 2016 7:31 pm

Yes, that's it, thanks a lot! If you don't want to build the whole SDK you could use the beta sdk: ftp://ftp.parallella.org/esdk/beta/esdk ... 523.tar.gz, this version has the fix included.

Now that it's working i want the 64core epiphany, where is it? ;-)
pharaoh
 
Posts: 6
Joined: Sat Jan 16, 2016 1:37 pm


Return to Linux/U-Boot

Who is online

Users browsing this forum: No registered users and 4 guests