0 Replies Latest reply on Oct 3, 2013 9:14 PM by 886c68de-d5df-4bee-85c8-4abae85ea398

    kmem_alloc(KM_NOSLEEP) sleeps?  Really?




      From the Solaris 10 kmem_alloc(9F) man page:



           The kmem_alloc() function allocates  size  bytes  of  kernel

           memory  and  returns  a pointer to the allocated memory. The

           allocated memory is at least double-word aligned, so it  can

           hold  any  C  data  structure.  No  greater alignment can be

           assumed. flag determines whether the caller  can  sleep  for

           memory. KM_SLEEP allocations may sleep but are guaranteed to

           succeed. KM_NOSLEEP allocations are guaranteed not to  sleep

           but  may fail (return NULL) if no memory is currently avail-

           able.  The  initial  contents  of  memory  allocated   using

           kmem_alloc() are random garbage.


      I have been informed by Oracle internal sources that kmem_alloc(KM_NOSLEEP) can indeed sleep.  There apparently is a blocking mutex in the slab allocator refill operation that can be taken even when KM_NOSLEEP is indicated.


      Can anybody with Solaris 10 VM internals knowledge shed some more light on this?  It's counterintuitive to say the least.  Is there any way to allocate kernel memory in Solaris without blocking?  Do I really have to write my own memory allocator to work around this deficiency?


      Thanks for any help you can provide.