[v1,1/2] mm/zsmalloc: use ARRAY_SIZE in isolate_zspage()

Message ID 20230516095029.49036-1-avromanov@sberdevices.ru
State New
Headers
Series [v1,1/2] mm/zsmalloc: use ARRAY_SIZE in isolate_zspage() |

Commit Message

Alexey Romanov May 16, 2023, 9:50 a.m. UTC
  Better not to use hardcoded constants.

Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Sergey Senozhatsky May 16, 2023, 9:53 a.m. UTC | #1
On (23/05/16 12:50), Alexey Romanov wrote:
>  mm/zsmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 702bc3fd687a..f23c2da55368 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source)
>  		fg[1] = ZS_ALMOST_EMPTY;
>  	}
>  
> -	for (i = 0; i < 2; i++) {
> +	for (i = 0; i < ARRAY_SIZE(fg); i++) {
>  		zspage = list_first_entry_or_null(&class->fullness_list[fg[i]],
>  							struct zspage, list);
>  		if (zspage) {

This patch needs to be dropped. We don't have that function anymore.
  
Alexey Romanov May 16, 2023, 10:11 a.m. UTC | #2
Hello!

On Tue, May 16, 2023 at 06:53:27PM +0900, Sergey Senozhatsky wrote:
> On (23/05/16 12:50), Alexey Romanov wrote:
> >  mm/zsmalloc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index 702bc3fd687a..f23c2da55368 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source)
> >  		fg[1] = ZS_ALMOST_EMPTY;
> >  	}
> >  
> > -	for (i = 0; i < 2; i++) {
> > +	for (i = 0; i < ARRAY_SIZE(fg); i++) {
> >  		zspage = list_first_entry_or_null(&class->fullness_list[fg[i]],
> >  							struct zspage, list);
> >  		if (zspage) {
> 
> This patch needs to be dropped. We don't have that function anymore.

Do I need to sumbit v2 without this patch, or will Andrew just take
only the 2/2 patch into the branch?
  
Sergey Senozhatsky May 16, 2023, 12:29 p.m. UTC | #3
On (23/05/16 10:11), Alexey Romanov wrote:
> > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > > index 702bc3fd687a..f23c2da55368 100644
> > > --- a/mm/zsmalloc.c
> > > +++ b/mm/zsmalloc.c
> > > @@ -1888,7 +1888,7 @@ static struct zspage *isolate_zspage(struct size_class *class, bool source)
> > >  		fg[1] = ZS_ALMOST_EMPTY;
> > >  	}
> > >  
> > > -	for (i = 0; i < 2; i++) {
> > > +	for (i = 0; i < ARRAY_SIZE(fg); i++) {
> > >  		zspage = list_first_entry_or_null(&class->fullness_list[fg[i]],
> > >  							struct zspage, list);
> > >  		if (zspage) {
> > 
> > This patch needs to be dropped. We don't have that function anymore.
> 
> Do I need to sumbit v2 without this patch, or will Andrew just take
> only the 2/2 patch into the branch?

Let's hear from Andrew, but I think v2 won't be necessary.
  

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 702bc3fd687a..f23c2da55368 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1888,7 +1888,7 @@  static struct zspage *isolate_zspage(struct size_class *class, bool source)
 		fg[1] = ZS_ALMOST_EMPTY;
 	}
 
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < ARRAY_SIZE(fg); i++) {
 		zspage = list_first_entry_or_null(&class->fullness_list[fg[i]],
 							struct zspage, list);
 		if (zspage) {