linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memblock: update comments and kernel-doc
@ 2019-02-08 11:45 Mike Rapoport
  2019-02-08 22:40 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2019-02-08 11:45 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jonathan Corbet, linux-mm, linux-doc, linux-kernel, Mike Rapoport

* Remove comments mentioning bootmem
* Extend "DOC: memblock overview"
* Add kernel-doc comments for several more functions

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---

The patch is against the current -mm tree which seems the best route for it
as well :)

 mm/memblock.c | 60 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 43 insertions(+), 17 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index f87d3ae..900c95b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -69,8 +69,19 @@
  * :c:func:`memblock_set_node`. The :c:func:`memblock_add_node`
  * performs such an assignment directly.
  *
- * Once memblock is setup the memory can be allocated using either
- * memblock or bootmem APIs.
+ * Once memblock is setup the memory can be allocated using one of the
+ * API variants:
+ *
+ * * :c:func:`memblock_phys_alloc*` - these functions return the
+ *   **physical** address of the allocated memory
+ * * :c:func:`memblock_alloc*` - these functions return the **virtual**
+ *   address of the allocated memory.
+ *
+ * Note, that both API variants use implict assumptions about allowed
+ * memory ranges and the fallback methods. Consult the documentation
+ * of :c:func:`memblock_alloc_internal` and
+ * :c:func:`memblock_alloc_range_nid` functions for more elaboarte
+ * description.
  *
  * As the system boot progresses, the architecture specific
  * :c:func:`mem_init` function frees all the memory to the buddy page
@@ -428,17 +439,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
 	else
 		in_slab = &memblock_reserved_in_slab;
 
-	/* Try to find some space for it.
-	 *
-	 * WARNING: We assume that either slab_is_available() and we use it or
-	 * we use MEMBLOCK for allocations. That means that this is unsafe to
-	 * use when bootmem is currently active (unless bootmem itself is
-	 * implemented on top of MEMBLOCK which isn't the case yet)
-	 *
-	 * This should however not be an issue for now, as we currently only
-	 * call into MEMBLOCK while it's still active, or much later when slab
-	 * is active for memory hotplug operations
-	 */
+	/* Try to find some space for it */
 	if (use_slab) {
 		new_array = kmalloc(new_size, GFP_KERNEL);
 		addr = new_array ? __pa(new_array) : 0;
@@ -982,7 +983,7 @@ static bool should_skip_region(struct memblock_region *m, int nid, int flags)
 }
 
 /**
- * __next__mem_range - next function for for_each_free_mem_range() etc.
+ * __next_mem_range - next function for for_each_free_mem_range() etc.
  * @idx: pointer to u64 loop variable
  * @nid: node selector, %NUMA_NO_NODE for all nodes
  * @flags: pick from blocks based on memory attributes
@@ -1392,6 +1393,18 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
 	return found;
 }
 
+/**
+ * memblock_phys_alloc_range - allocate a memory block inside specified range
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @start: the lower bound of the memory region to allocate (physical address)
+ * @end: the upper bound of the memory region to allocate (physical address)
+ *
+ * Allocate @size bytes in the between @start and @end.
+ *
+ * Return: physical address of the allocated memory block on success,
+ * %0 on failure.
+ */
 phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,
 					     phys_addr_t align,
 					     phys_addr_t start,
@@ -1400,6 +1413,19 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,
 	return memblock_alloc_range_nid(size, align, start, end, NUMA_NO_NODE);
 }
 
+/**
+ * memblock_phys_alloc_range - allocate a memory block from specified MUMA node
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
+ *
+ * Allocates memory block from the specified NUMA node. If the node
+ * has no available memory, attempts to allocated from any node in the
+ * system.
+ *
+ * Return: physical address of the allocated memory block on success,
+ * %0 on failure.
+ */
 phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
 {
 	return memblock_alloc_range_nid(size, align, 0,
@@ -1526,13 +1552,13 @@ void * __init memblock_alloc_try_nid(
 }
 
 /**
- * __memblock_free_late - free bootmem block pages directly to buddy allocator
+ * __memblock_free_late - free pages directly to buddy allocator
  * @base: phys starting address of the  boot memory block
  * @size: size of the boot memory block in bytes
  *
- * This is only useful when the bootmem allocator has already been torn
+ * This is only useful when the memblock allocator has already been torn
  * down, but we are still initializing the system.  Pages are released directly
- * to the buddy allocator, no bootmem metadata is updated because it is gone.
+ * to the buddy allocator.
  */
 void __init __memblock_free_late(phys_addr_t base, phys_addr_t size)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] memblock: update comments and kernel-doc
  2019-02-08 11:45 [PATCH] memblock: update comments and kernel-doc Mike Rapoport
@ 2019-02-08 22:40 ` Andrew Morton
  2019-02-09  8:59   ` Mike Rapoport
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2019-02-08 22:40 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Jonathan Corbet, linux-mm, linux-doc, linux-kernel

On Fri,  8 Feb 2019 13:45:47 +0200 Mike Rapoport <rppt@linux.ibm.com> wrote:

> * Remove comments mentioning bootmem
> * Extend "DOC: memblock overview"
> * Add kernel-doc comments for several more functions
> 
> ...
>
> @@ -1400,6 +1413,19 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,
>  	return memblock_alloc_range_nid(size, align, start, end, NUMA_NO_NODE);
>  }
>  
> +/**
> + * memblock_phys_alloc_range - allocate a memory block from specified MUMA node
> + * @size: size of memory block to be allocated in bytes
> + * @align: alignment of the region and block's size
> + * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
> + *
> + * Allocates memory block from the specified NUMA node. If the node
> + * has no available memory, attempts to allocated from any node in the
> + * system.
> + *
> + * Return: physical address of the allocated memory block on success,
> + * %0 on failure.
> + */
>  phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
>  {
>  	return memblock_alloc_range_nid(size, align, 0,

copy-n-paste!

--- a/mm/memblock.c~memblock-update-comments-and-kernel-doc-fix
+++ a/mm/memblock.c
@@ -1414,7 +1414,7 @@ phys_addr_t __init memblock_phys_alloc_r
 }
 
 /**
- * memblock_phys_alloc_range - allocate a memory block from specified MUMA node
+ * memblock_phys_alloc_try_nid - allocate a memory block from specified MUMA node
  * @size: size of memory block to be allocated in bytes
  * @align: alignment of the region and block's size
  * @nid: nid of the free area to find, %NUMA_NO_NODE for any node


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memblock: update comments and kernel-doc
  2019-02-08 22:40 ` Andrew Morton
@ 2019-02-09  8:59   ` Mike Rapoport
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2019-02-09  8:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jonathan Corbet, linux-mm, linux-doc, linux-kernel

On Fri, Feb 08, 2019 at 02:40:47PM -0800, Andrew Morton wrote:
> On Fri,  8 Feb 2019 13:45:47 +0200 Mike Rapoport <rppt@linux.ibm.com> wrote:
> 
> > * Remove comments mentioning bootmem
> > * Extend "DOC: memblock overview"
> > * Add kernel-doc comments for several more functions
> > 
> > ...
> >
> > @@ -1400,6 +1413,19 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,
> >  	return memblock_alloc_range_nid(size, align, start, end, NUMA_NO_NODE);
> >  }
> >  
> > +/**
> > + * memblock_phys_alloc_range - allocate a memory block from specified MUMA node
> > + * @size: size of memory block to be allocated in bytes
> > + * @align: alignment of the region and block's size
> > + * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
> > + *
> > + * Allocates memory block from the specified NUMA node. If the node
> > + * has no available memory, attempts to allocated from any node in the
> > + * system.
> > + *
> > + * Return: physical address of the allocated memory block on success,
> > + * %0 on failure.
> > + */
> >  phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
> >  {
> >  	return memblock_alloc_range_nid(size, align, 0,
> 
> copy-n-paste!

Oops, thanks for the fix!
 
> --- a/mm/memblock.c~memblock-update-comments-and-kernel-doc-fix
> +++ a/mm/memblock.c
> @@ -1414,7 +1414,7 @@ phys_addr_t __init memblock_phys_alloc_r
>  }
>  
>  /**
> - * memblock_phys_alloc_range - allocate a memory block from specified MUMA node
> + * memblock_phys_alloc_try_nid - allocate a memory block from specified MUMA node
>   * @size: size of memory block to be allocated in bytes
>   * @align: alignment of the region and block's size
>   * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
> 

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-09  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 11:45 [PATCH] memblock: update comments and kernel-doc Mike Rapoport
2019-02-08 22:40 ` Andrew Morton
2019-02-09  8:59   ` Mike Rapoport

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).