This discussion is archived
0 Replies Latest reply: Oct 3, 2013 2:14 PM by 886c68de-d5df-4bee-85c8-4abae85ea398 RSS

kmem_alloc(KM_NOSLEEP) sleeps?  Really?

886c68de-d5df-4bee-85c8-4abae85ea398 Newbie
Currently Being Moderated

Hi,

 

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

 

DESCRIPTION

     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.

 

Cliff

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points