LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] percpu: remove the unnecessary operation for bitmaps in finding suitable region
@ 2021-08-15  3:20 Junhua Huang
  2021-08-15 16:19 ` Dennis Zhou
  0 siblings, 1 reply; 2+ messages in thread
From: Junhua Huang @ 2021-08-15  3:20 UTC (permalink / raw)
  To: dennis, tj, cl; +Cc: linux-mm, linux-kernel, Junhua Huang

From: Junhua Huang <huang.junhua@zte.com.cn>

We use pcpu_next_fit_region to find the next fit region for alloc. Once
return, the region fit the request and then break the loop, or get the
next start offset from pcpu_is_populated. So there is no necessary to
add bits to bit_off. At the same time, bits will set 0 in 
pcpu_next_fit_region each time, so I think it is unnecessary to 
set bits zero in pcpu_for_each_fit_region loops.

Signed-off-by: Junhua Huang <huang.junhua@zte.com.cn>
---
 mm/percpu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 7f2e0151c4e2..ec7a5d10f6c9 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -489,7 +489,6 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits,
 	for (pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
 				  &(bits));				      \
 	     (bit_off) < pcpu_chunk_map_bits((chunk));			      \
-	     (bit_off) += (bits),					      \
 	     pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
 				  &(bits)))
 
@@ -1126,7 +1125,6 @@ static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int alloc_bits,
 			break;
 
 		bit_off = next_off;
-		bits = 0;
 	}
 
 	if (bit_off == pcpu_chunk_map_bits(chunk))
-- 
2.25.1



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

* Re: [PATCH] percpu: remove the unnecessary operation for bitmaps in finding suitable region
  2021-08-15  3:20 [PATCH] percpu: remove the unnecessary operation for bitmaps in finding suitable region Junhua Huang
@ 2021-08-15 16:19 ` Dennis Zhou
  0 siblings, 0 replies; 2+ messages in thread
From: Dennis Zhou @ 2021-08-15 16:19 UTC (permalink / raw)
  To: Junhua Huang; +Cc: dennis, tj, cl, linux-mm, linux-kernel, Junhua Huang

Hello,

On Sat, Aug 14, 2021 at 08:20:18PM -0700, Junhua Huang wrote:
> From: Junhua Huang <huang.junhua@zte.com.cn>
> 
> We use pcpu_next_fit_region to find the next fit region for alloc. Once
> return, the region fit the request and then break the loop, or get the
> next start offset from pcpu_is_populated. So there is no necessary to
> add bits to bit_off. At the same time, bits will set 0 in 
> pcpu_next_fit_region each time, so I think it is unnecessary to 
> set bits zero in pcpu_for_each_fit_region loops.
> 

I think you're right in this instance, but I don't think this change is
correct as a whole.

> Signed-off-by: Junhua Huang <huang.junhua@zte.com.cn>
> ---
>  mm/percpu.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 7f2e0151c4e2..ec7a5d10f6c9 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -489,7 +489,6 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits,
>  	for (pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
>  				  &(bits));				      \
>  	     (bit_off) < pcpu_chunk_map_bits((chunk));			      \
> -	     (bit_off) += (bits),					      \

Removing this makes the iterator by itself wrong. While correct in the
current usage, it could potentially be wrong for the next.

>  	     pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
>  				  &(bits)))
>  
> @@ -1126,7 +1125,6 @@ static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int alloc_bits,
>  			break;
>  
>  		bit_off = next_off;
> -		bits = 0;
>  	}
>  
>  	if (bit_off == pcpu_chunk_map_bits(chunk))
> -- 
> 2.25.1
> 
> 

Thanks,
Dennis

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

end of thread, other threads:[~2021-08-15 16:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-15  3:20 [PATCH] percpu: remove the unnecessary operation for bitmaps in finding suitable region Junhua Huang
2021-08-15 16:19 ` Dennis Zhou

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).