From: Christoph Hellwig <hch@lst.de>
To: Vlastimil Babka <vbabka@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Harry Yoo <harry.yoo@oracle.com>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>, Zi Yan <ziy@nvidia.com>,
Eric Biggers <ebiggers@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 03/11] mempool: improve kerneldoc comments
Date: Thu, 13 Nov 2025 09:39:44 +0100 [thread overview]
Message-ID: <20251113084022.1255121-4-hch@lst.de> (raw)
In-Reply-To: <20251113084022.1255121-1-hch@lst.de>
Use proper formatting, use full sentences and reduce some verbosity in
function parameter descriptions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/mempool.c | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/mm/mempool.c b/mm/mempool.c
index 1c38e873e546..1f4701713203 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -372,18 +372,20 @@ int mempool_resize(mempool_t *pool, int new_min_nr)
EXPORT_SYMBOL(mempool_resize);
/**
- * mempool_alloc - allocate an element from a specific memory pool
- * @pool: pointer to the memory pool which was allocated via
- * mempool_create().
- * @gfp_mask: the usual allocation bitmask.
+ * mempool_alloc - allocate an element from a memory pool
+ * @pool: pointer to the memory pool
+ * @gfp_mask: GFP_* flags. %__GFP_ZERO is not supported.
*
- * this function only sleeps if the alloc_fn() function sleeps or
- * returns NULL. Note that due to preallocation, this function
- * *never* fails when called from process contexts. (it might
- * fail if called from an IRQ context.)
- * Note: using __GFP_ZERO is not supported.
+ * Allocate an element from @pool. This is done by first calling into the
+ * alloc_fn supplied at pool initialization time, and dipping into the reserved
+ * pool when alloc_fn fails to allocate an element.
*
- * Return: pointer to the allocated element or %NULL on error.
+ * This function only sleeps if the alloc_fn callback sleeps, or when waiting
+ * for elements to become available in the pool.
+ *
+ * Return: pointer to the allocated element or %NULL when failing to allocate
+ * an element. Allocation failure can only happen when @gfp_mask does not
+ * include %__GFP_DIRECT_RECLAIM.
*/
void *mempool_alloc_noprof(mempool_t *pool, gfp_t gfp_mask)
{
@@ -456,11 +458,10 @@ EXPORT_SYMBOL(mempool_alloc_noprof);
/**
* mempool_alloc_preallocated - allocate an element from preallocated elements
- * belonging to a specific memory pool
- * @pool: pointer to the memory pool which was allocated via
- * mempool_create().
+ * belonging to a memory pool
+ * @pool: pointer to the memory pool
*
- * This function is similar to mempool_alloc, but it only attempts allocating
+ * This function is similar to mempool_alloc(), but it only attempts allocating
* an element from the preallocated elements. It does not sleep and immediately
* returns if no preallocated elements are available.
*
@@ -492,12 +493,14 @@ void *mempool_alloc_preallocated(mempool_t *pool)
EXPORT_SYMBOL(mempool_alloc_preallocated);
/**
- * mempool_free - return an element to the pool.
- * @element: pool element pointer.
- * @pool: pointer to the memory pool which was allocated via
- * mempool_create().
+ * mempool_free - return an element to a mempool
+ * @element: pointer to element
+ * @pool: pointer to the memory pool
+ *
+ * Returns @element to @pool if it needs replenishing, else frees it using
+ * the free_fn callback in @pool.
*
- * this function only sleeps if the free_fn() function sleeps.
+ * This function only sleeps if the free_fn callback sleeps.
*/
void mempool_free(void *element, mempool_t *pool)
{
--
2.47.3
next prev parent reply other threads:[~2025-11-13 8:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 8:39 mempool_alloc_bulk and various mempool improvements v3 Christoph Hellwig
2025-11-13 8:39 ` [PATCH 01/11] fault-inject: make enum fault_flags available unconditionally Christoph Hellwig
2025-11-13 8:39 ` [PATCH 02/11] mm: improve kerneldoc comments for __alloc_pages_bulk Christoph Hellwig
2025-11-13 8:39 ` Christoph Hellwig [this message]
2025-11-13 8:39 ` [PATCH 04/11] mempool: add error injection support Christoph Hellwig
2025-11-13 8:39 ` [PATCH 05/11] mempool: factor out a mempool_adjust_gfp helper Christoph Hellwig
2025-11-13 8:39 ` [PATCH 06/11] mempool: factor out a mempool_alloc_from_pool helper Christoph Hellwig
2025-11-23 3:42 ` Hugh Dickins
2025-11-23 11:34 ` Vlastimil Babka
2025-11-23 17:49 ` Hugh Dickins
2025-11-23 21:22 ` Vlastimil Babka
2025-11-23 23:04 ` Hugh Dickins
2025-11-25 11:32 ` Vlastimil Babka
2025-11-24 6:17 ` Christoph Hellwig
2025-11-24 6:15 ` Christoph Hellwig
2025-11-25 11:34 ` Vlastimil Babka
2025-11-24 6:14 ` Christoph Hellwig
2025-11-13 8:39 ` [PATCH 07/11] mempool: add mempool_{alloc,free}_bulk Christoph Hellwig
2025-11-13 8:39 ` [PATCH 08/11] mempool: legitimize the io_schedule_timeout in mempool_alloc_from_pool Christoph Hellwig
2025-11-13 8:39 ` [PATCH 09/11] mempool: remove mempool_{init,create}_kvmalloc_pool Christoph Hellwig
2025-11-13 8:39 ` [PATCH 10/11] mempool: de-typedef Christoph Hellwig
2025-11-13 8:39 ` [PATCH 11/11] mempool: drop the file name in the top of file comment Christoph Hellwig
2025-11-13 16:12 ` mempool_alloc_bulk and various mempool improvements v3 Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251113084022.1255121-4-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=ebiggers@kernel.org \
--cc=harry.yoo@oracle.com \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox