Print this page
5513 KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pages
14465 Present KM_NOSLEEP_LAZY as documented interface
Change-Id: I002ec28ddf390650f1fcba1ca94f6abfdb241439


  82 
  83 
  84        vmp
  85                       Drivers should pass NULL.
  86 
  87 
  88        cflags
  89                       Drivers must pass 0.
  90 
  91 
  92        kmflag
  93                       Possible flags are:
  94 
  95                       KM_SLEEP
  96                                      Allow sleeping (blocking) until memory is
  97                                      available.
  98 
  99 
 100                       KM_NOSLEEP
 101                                      Return NULL immediately if memory is not
 102                                      available.




 103 
 104 










 105                       KM_PUSHPAGE
 106                                      Allow the allocation to use reserved
 107                                      memory.
 108 
 109 
 110 
 111        obj
 112                       Pointer to the object allocated by kmem_cache_alloc().
 113 
 114 
 115        move
 116                       Pointer to an object relocation function. Parameters are
 117                       defined below.
 118 
 119 
 120 
 121        The parameters for the callback constructor function are as follows:
 122 
 123        void *buf
 124                          Pointer to the object to be constructed.


 500 
 501 
 502 
 503        This makes foo allocation fast, because the allocator will usually do
 504        nothing more than fetch an already-constructed foo from the cache.
 505        foo_constructor and foo_destructor will be invoked only to populate and
 506        drain the cache, respectively.
 507 
 508 
 509        Example 2 Registering a Move Callback
 510 
 511 
 512        To register a move() callback:
 513 
 514 
 515          object_cache = kmem_cache_create(...);
 516          kmem_cache_set_move(object_cache, object_move);
 517 
 518 
 519 RETURN VALUES
 520        If successful, the constructor function must return 0. If KM_NOSLEEP is
 521        set and memory cannot be allocated without sleeping, the constructor
 522        must return -1.


 523 
 524 
 525        kmem_cache_create() returns a pointer to the allocated cache.
 526 
 527 
 528        If successful, kmem_cache_alloc() returns a pointer to the allocated
 529        object. If KM_NOSLEEP is set and memory cannot be allocated without
 530        sleeping, kmem_cache_alloc() returns NULL.
 531 
 532 ATTRIBUTES
 533        See attributes(5) for descriptions of the following attributes:
 534 
 535 
 536 
 537 
 538        +--------------------+-----------------+
 539        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 540        +--------------------+-----------------+
 541        |Interface Stability | Committed       |
 542        +--------------------+-----------------+




  82 
  83 
  84        vmp
  85                       Drivers should pass NULL.
  86 
  87 
  88        cflags
  89                       Drivers must pass 0.
  90 
  91 
  92        kmflag
  93                       Possible flags are:
  94 
  95                       KM_SLEEP
  96                                      Allow sleeping (blocking) until memory is
  97                                      available.
  98 
  99 
 100                       KM_NOSLEEP
 101                                      Return NULL immediately if memory is not
 102                                      available, but after an aggressive
 103                                      reclaiming attempt.  Any mention of
 104                                      KM_NOSLEEP without mentioning
 105                                      KM_NOSLEEP_LAZY (see below) applies to
 106                                      both values.
 107 
 108 
 109                       KM_NOSLEEP_LAZY
 110                                      Return NULL immediately if memory is not
 111                                      available, without the aggressive
 112                                      reclaiming attempt.  This is actually two
 113                                      flags combined: (KM_NOSLEEP |
 114                                      KM_NORMALPRI), the latter flag indicating
 115                                      not to attempt reclamation before giving
 116                                      up and returning NULL.
 117 
 118 
 119                       KM_PUSHPAGE
 120                                      Allow the allocation to use reserved
 121                                      memory.
 122 
 123 
 124 
 125        obj
 126                       Pointer to the object allocated by kmem_cache_alloc().
 127 
 128 
 129        move
 130                       Pointer to an object relocation function. Parameters are
 131                       defined below.
 132 
 133 
 134 
 135        The parameters for the callback constructor function are as follows:
 136 
 137        void *buf
 138                          Pointer to the object to be constructed.


 514 
 515 
 516 
 517        This makes foo allocation fast, because the allocator will usually do
 518        nothing more than fetch an already-constructed foo from the cache.
 519        foo_constructor and foo_destructor will be invoked only to populate and
 520        drain the cache, respectively.
 521 
 522 
 523        Example 2 Registering a Move Callback
 524 
 525 
 526        To register a move() callback:
 527 
 528 
 529          object_cache = kmem_cache_create(...);
 530          kmem_cache_set_move(object_cache, object_move);
 531 
 532 
 533 RETURN VALUES
 534        If successful, the constructor function must return 0. If KM_NOSLEEP or
 535        KM_NOSLEEP_LAZY is set and memory cannot be allocated without sleeping,
 536        the constructor must return -1.  If the constructor takes extraordinary
 537        steps during a KM_NOSLEEP construction, it may not take those for a
 538        KM_NOSLEEP_LAZY construction.
 539 
 540 
 541        kmem_cache_create() returns a pointer to the allocated cache.
 542 
 543 
 544        If successful, kmem_cache_alloc() returns a pointer to the allocated
 545        object. If KM_NOSLEEP is set and memory cannot be allocated without
 546        sleeping, kmem_cache_alloc() returns NULL.
 547 
 548 ATTRIBUTES
 549        See attributes(5) for descriptions of the following attributes:
 550 
 551 
 552 
 553 
 554        +--------------------+-----------------+
 555        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 556        +--------------------+-----------------+
 557        |Interface Stability | Committed       |
 558        +--------------------+-----------------+