Page 1 of 1

memory leak in epiphany driver

PostPosted: Sun Jan 17, 2016 3:05 pm
by pharaoh
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.

Re: memory leak in epiphany driver

PostPosted: Mon Jan 18, 2016 12:46 pm
by MiguelTasende
May be related to this?

viewtopic.php?f=13&t=3326

Re: memory leak in epiphany driver

PostPosted: Mon Jan 18, 2016 2:21 pm
by olajep
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

Re: memory leak in epiphany driver

PostPosted: Mon Jan 18, 2016 7:31 pm
by pharaoh
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? ;-)