[3/8] mm/percpu: Update the code comment when creating new chunk

Message ID 20221024081435.204970-4-bhe@redhat.com
State New
Headers
Series Cleanup and optimization patches for percpu |

Commit Message

Baoquan He Oct. 24, 2022, 8:14 a.m. UTC
  The lock pcpu_alloc_mutex taking code has been moved to the beginning of
pcpu_allo() if it's non atomic allocation. So the code comment above
above pcpu_create_chunk() callsite need be updated.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 mm/percpu.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
  

Comments

Dennis Zhou Oct. 24, 2022, 4:54 p.m. UTC | #1
On Mon, Oct 24, 2022 at 04:14:30PM +0800, Baoquan He wrote:
> The lock pcpu_alloc_mutex taking code has been moved to the beginning of
> pcpu_allo() if it's non atomic allocation. So the code comment above

Typo here ^ pcpu_alloc().

> above pcpu_create_chunk() callsite need be updated.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  mm/percpu.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index a3fde4ac03a4..a8121302a79c 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1817,16 +1817,12 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
>  
>  	spin_unlock_irqrestore(&pcpu_lock, flags);
>  
> -	/*
> -	 * No space left.  Create a new chunk.  We don't want multiple
> -	 * tasks to create chunks simultaneously.  Serialize and create iff
> -	 * there's still no empty chunk after grabbing the mutex.
> -	 */
>  	if (is_atomic) {
>  		err = "atomic alloc failed, no space left";
>  		goto fail;
>  	}
>  
> +	/* No space left.  Create a new chunk. */
>  	if (list_empty(&pcpu_chunk_lists[pcpu_free_slot])) {
>  		chunk = pcpu_create_chunk(pcpu_gfp);
>  		if (!chunk) {
> -- 
> 2.34.1
> 
> 

Acked-by: Dennis Zhou <dennis@kernel.org>

Thanks,
Dennis
  

Patch

diff --git a/mm/percpu.c b/mm/percpu.c
index a3fde4ac03a4..a8121302a79c 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1817,16 +1817,12 @@  static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
 
 	spin_unlock_irqrestore(&pcpu_lock, flags);
 
-	/*
-	 * No space left.  Create a new chunk.  We don't want multiple
-	 * tasks to create chunks simultaneously.  Serialize and create iff
-	 * there's still no empty chunk after grabbing the mutex.
-	 */
 	if (is_atomic) {
 		err = "atomic alloc failed, no space left";
 		goto fail;
 	}
 
+	/* No space left.  Create a new chunk. */
 	if (list_empty(&pcpu_chunk_lists[pcpu_free_slot])) {
 		chunk = pcpu_create_chunk(pcpu_gfp);
 		if (!chunk) {