Skip to content

Commit 5c82978

Browse files
Christoph Hellwigtehcaster
authored andcommitted
mempool: improve kerneldoc comments
Use proper formatting, use full sentences and reduce some verbosity in function parameter descriptions. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20251113084022.1255121-4-hch@lst.de Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent e9939ce commit 5c82978

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

mm/mempool.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -372,18 +372,20 @@ int mempool_resize(mempool_t *pool, int new_min_nr)
372372
EXPORT_SYMBOL(mempool_resize);
373373

374374
/**
375-
* mempool_alloc - allocate an element from a specific memory pool
376-
* @pool: pointer to the memory pool which was allocated via
377-
* mempool_create().
378-
* @gfp_mask: the usual allocation bitmask.
375+
* mempool_alloc - allocate an element from a memory pool
376+
* @pool: pointer to the memory pool
377+
* @gfp_mask: GFP_* flags. %__GFP_ZERO is not supported.
379378
*
380-
* this function only sleeps if the alloc_fn() function sleeps or
381-
* returns NULL. Note that due to preallocation, this function
382-
* *never* fails when called from process contexts. (it might
383-
* fail if called from an IRQ context.)
384-
* Note: using __GFP_ZERO is not supported.
379+
* Allocate an element from @pool. This is done by first calling into the
380+
* alloc_fn supplied at pool initialization time, and dipping into the reserved
381+
* pool when alloc_fn fails to allocate an element.
385382
*
386-
* Return: pointer to the allocated element or %NULL on error.
383+
* This function only sleeps if the alloc_fn callback sleeps, or when waiting
384+
* for elements to become available in the pool.
385+
*
386+
* Return: pointer to the allocated element or %NULL when failing to allocate
387+
* an element. Allocation failure can only happen when @gfp_mask does not
388+
* include %__GFP_DIRECT_RECLAIM.
387389
*/
388390
void *mempool_alloc_noprof(mempool_t *pool, gfp_t gfp_mask)
389391
{
@@ -456,11 +458,10 @@ EXPORT_SYMBOL(mempool_alloc_noprof);
456458

457459
/**
458460
* mempool_alloc_preallocated - allocate an element from preallocated elements
459-
* belonging to a specific memory pool
460-
* @pool: pointer to the memory pool which was allocated via
461-
* mempool_create().
461+
* belonging to a memory pool
462+
* @pool: pointer to the memory pool
462463
*
463-
* This function is similar to mempool_alloc, but it only attempts allocating
464+
* This function is similar to mempool_alloc(), but it only attempts allocating
464465
* an element from the preallocated elements. It does not sleep and immediately
465466
* returns if no preallocated elements are available.
466467
*
@@ -492,12 +493,14 @@ void *mempool_alloc_preallocated(mempool_t *pool)
492493
EXPORT_SYMBOL(mempool_alloc_preallocated);
493494

494495
/**
495-
* mempool_free - return an element to the pool.
496-
* @element: pool element pointer.
497-
* @pool: pointer to the memory pool which was allocated via
498-
* mempool_create().
496+
* mempool_free - return an element to a mempool
497+
* @element: pointer to element
498+
* @pool: pointer to the memory pool
499+
*
500+
* Returns @element to @pool if it needs replenishing, else frees it using
501+
* the free_fn callback in @pool.
499502
*
500-
* this function only sleeps if the free_fn() function sleeps.
503+
* This function only sleeps if the free_fn callback sleeps.
501504
*/
502505
void mempool_free(void *element, mempool_t *pool)
503506
{

0 commit comments

Comments
 (0)