tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mmap, ENOMEM and setrlimit



David Laight <david%l8s.co.uk@localhost> wrote:

[mmap fails with unlimited RLIMIT_DATA and RLIMIT_AS]
> Setting these to unlimited will still leave a kernel limit - possibly
> based on the systems physical memory size (even though the amount of
> swap would really be relevant).
> 
> You probably need to annotate the places where ENOMEM can be set.

I switched to tech-kern, which seems more approrpiate than tech-userlevel
here.

I get ENOMEM doing this (stacksize = 262144, pu->pu_cc_stackshift = 18):

         sp = mmap(NULL, stacksize, PROT_READ|PROT_WRITE,
             MAP_ANON|MAP_PRIVATE|MAP_ALIGNED(pu->pu_cc_stackshift), -1, 0);
 
The ENOMEM is raised in uvm_map_prepare(), here:

                /*
                 * try to reclaim kva and wait until someone does unmap.
                 * fragile locking here, so we awaken every second to
                 * recheck the condition.
                 */
   
                mutex_enter(&map->misc_lock);
                while ((map->flags & VM_MAP_WANTVA) != 0 &&
                   map->timestamp == timestamp) {
                        if ((flags & UVM_FLAG_WAITVA) == 0) {
                                mutex_exit(&map->misc_lock);
                                UVMHIST_LOG(maphist,
                                    "<- uvm_map_findspace failed!", 0,0,0,0);
                                return ENOMEM;
                        } else {
                                cv_timedwait(&map->cv, &map->misc_lock, hz);
                        }
                }
                mutex_exit(&map->misc_lock);



-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index