On Wed, 03 Dec 2014 18:06:20 +0100 "Dominig ar Foll (Intel OTC)" <[email protected]> said:
> Le 03/12/2014 17:42, Thiago Macieira a écrit : > > On Wednesday 03 December 2014 10:36:26 Dominig ar Foll wrote: > >> the model that I have used in previous project was to check have the > >> ressource manager to try to allocate the memory amount considered to be > >> the healthy minimum for a very short time an to release it. > >> That model also allow to check that not only memory is available but a > >> decent amount of continuous memory can be allocated. > > Contiguous memory does not make sense in userspace. One contiguous block of > > virtual memory can be backed by a series of discontiguous pages. And there > > are very, very few legitimate uses of contiguous physical blocks of memory > > and they're all related to hardware. > Yes and that why that check was done. It also indicate a level of > fragmentation of RAM in the system what can be used a guessing point for > thing starting to go bad. > > > > I don't recommend trying to allocate memory to check if you can allocate > > memory, as you may cause the very problem you're trying to prevent (suppose > > something else tries to allocate a healthy amount of memory at the same > > time). Besides, you have to fault in all of those pages to make sure you > > actually got them, which will imply CPU usage... > > All the Telco product that I worked on before joining Intel, use that > model. Checking has a cost. > The trick is to ask for enough in one go to be able to take a decision > on Kernel refusal without forcing the kernel to take action by itself. > Not that nice, but works pretty well. > Dominig problem is that this won't work well on linux... 1. swap - if you have it the above method won't be that great 2. until you touch the pages (read or write) they don't exist so it will have no impact 3. a malloc won't give you linear/continuous memory. either will a mmap etc. unless it's a specialized device guaranteeing that (i know of no general device providing that) 4. due to linux doing overcommit to ensure we don't waste lots of memory any allocation is never guaranteed. you can turn this off, but then you basically need a chunk more real memory to make up for it. i might guess 50% to 100% more you really need the kernel to give userspace more information. -- Carsten Haitzler (The Rasterman) <[email protected]> _______________________________________________ Dev mailing list [email protected] https://lists.tizen.org/listinfo/dev
