Skip to contentSkip to conversation

staging: erofs: avoid opened loop codes

PATCH New Chao Yu 2 participants 4 messages Jul 16, 2019 Staging

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 staging: erofs: avoid opened loop codes

Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().

Signed-off-by Chao Yu <yuchao0 at huawei.com>
---
 drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/erofs/unzip_vle.c +8 -9
index f0dab81ff816..3a0dbcb8cc9f 100644
@@ -921,18 +921,17 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		 mutex_trylock(&z_pagemap_global_lock))
 		pages = z_pagemap_global;
 	else {
-repeat:
-		pages = kvmalloc_array(nr_pages, sizeof(struct page *),
-				       GFP_KERNEL);
+		gfp_t flags = GFP_KERNEL;
+
+		if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
+			flags |= __GFP_NOFAIL;
+
+		pages = kvmalloc_array(nr_pages, sizeof(struct page *), flags);
 
 		/* fallback to global pagemap for the lowmem scenario */
 		if (unlikely(!pages)) {
-			if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
-				goto repeat;
-			else {
-				mutex_lock(&z_pagemap_global_lock);
-				pages = z_pagemap_global;
-			}
+			mutex_lock(&z_pagemap_global_lock);
+			pages = z_pagemap_global;
 		}
 	}
 
Signature · 1 line
2.18.0.rc1
#1 lore raw

PATCH 1/1 staging: erofs: avoid opened loop codes

Hi Chao,

Quoted 14 lines · Chao Yu

Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().

Signed-off-by Chao Yu <yuchao0 at huawei.com>
---
 drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/erofs/unzip_vle.c +0 -0
index f0dab81ff816..3a0dbcb8cc9f 100644
@@ -921,18 +921,17 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		 mutex_trylock(&z_pagemap_global_lock))
 		pages = z_pagemap_global;

drivers/staging/erofs/unzip_vle.c static int z_erofs_vle_unzip(struct super_block *sb, · line 929

Quoted 10 lines
drivers/staging/erofs/unzip_vle.c +6 -3
 	else {
-repeat:
-		pages = kvmalloc_array(nr_pages, sizeof(struct page *),
-				       GFP_KERNEL);
+		gfp_t flags = GFP_KERNEL;
+
+		if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
+			flags |= __GFP_NOFAIL;
+
+		pages = kvmalloc_array(nr_pages, sizeof(struct page *), flags);

How about omitting variable flags' since it's only used once, or rename it since flags' is too general? some thoughts?

BTW, This piece of code has been changed in
"[PATCH v2 00/24] erofs: promote erofs from staging", I will sync the code after some guys takes a look at v2....

Thanks,
Gao Xiang

Quoted 15 lines
drivers/staging/erofs/unzip_vle.c +2 -6
 		/* fallback to global pagemap for the lowmem scenario */
 		if (unlikely(!pages)) {
-			if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
-				goto repeat;
-			else {
-				mutex_lock(&z_pagemap_global_lock);
-				pages = z_pagemap_global;
-			}
+			mutex_lock(&z_pagemap_global_lock);
+			pages = z_pagemap_global;
 		}
 	}
 
 
author
#2 lore raw

PATCH 1/1 staging: erofs: avoid opened loop codes

Hi Xiang,

Quoted 22 lines · Gao Xiang

Hi Chao,

Quoted 19 lines · Chao Yu

Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().

Signed-off-by Chao Yu <yuchao0 at huawei.com>
---
 drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/erofs/unzip_vle.c +1 -3
index f0dab81ff816..3a0dbcb8cc9f 100644
@@ -921,18 +921,17 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		 mutex_trylock(&z_pagemap_global_lock))
 		pages = z_pagemap_global;
 	else {
-repeat:
-		pages = kvmalloc_array(nr_pages, sizeof(struct page *),
-				       GFP_KERNEL);
+		gfp_t flags = GFP_KERNEL;
Quoted 8 lines

drivers/staging/erofs/unzip_vle.c static int z_erofs_vle_unzip(struct super_block *sb, · line 929

Quoted 5 lines
drivers/staging/erofs/unzip_vle.c +5 -0
+
+		if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
+			flags |= __GFP_NOFAIL;
+
+		pages = kvmalloc_array(nr_pages, sizeof(struct page *), flags);

How about omitting variable flags' since it's only used once, or rename it since flags' is too general? some thoughts?

That's minor thing, if you do care about this, I guess 'gfp_flags' maybe?

Quoted 4 lines

BTW, This piece of code has been changed in
"[PATCH v2 00/24] erofs: promote erofs from staging", I will sync the code after some guys takes a look at v2....

We have enough time to merge modified staging codes to generic fs one till next merge window, so don't worry, you can do the merge in batch.

Thanks,

Quoted 21 lines

Thanks,
Gao Xiang

Quoted 5 lines
drivers/staging/erofs/unzip_vle.c +0 -2
 		/* fallback to global pagemap for the lowmem scenario */
 		if (unlikely(!pages)) {
-			if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
-				goto repeat;

drivers/staging/erofs/unzip_vle.c static int z_erofs_vle_unzip(struct super_block *sb,

Quoted 10 lines
drivers/staging/erofs/unzip_vle.c +2 -4
-			else {
-				mutex_lock(&z_pagemap_global_lock);
-				pages = z_pagemap_global;
-			}
+			mutex_lock(&z_pagemap_global_lock);
+			pages = z_pagemap_global;
 		}
 	}
 
 

.

#3 lore raw

PATCH 1/1 staging: erofs: avoid opened loop codes

Quoted 34 lines · Chao Yu

Hi Xiang,

Quoted 22 lines · Gao Xiang

Hi Chao,

Quoted 19 lines · Chao Yu

Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().

Signed-off-by Chao Yu <yuchao0 at huawei.com>
---
 drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/erofs/unzip_vle.c +1 -3
index f0dab81ff816..3a0dbcb8cc9f 100644
@@ -921,18 +921,17 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		 mutex_trylock(&z_pagemap_global_lock))
 		pages = z_pagemap_global;
 	else {
-repeat:
-		pages = kvmalloc_array(nr_pages, sizeof(struct page *),
-				       GFP_KERNEL);
+		gfp_t flags = GFP_KERNEL;
Quoted 8 lines

drivers/staging/erofs/unzip_vle.c static int z_erofs_vle_unzip(struct super_block *sb, · line 929

Quoted 5 lines
drivers/staging/erofs/unzip_vle.c +5 -0
+
+		if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
+			flags |= __GFP_NOFAIL;
+
+		pages = kvmalloc_array(nr_pages, sizeof(struct page *), flags);

How about omitting variable flags' since it's only used once, or rename it since flags' is too general? some thoughts?

Quoted 1 line

That's minor thing, if you do care about this, I guess 'gfp_flags' maybe?

Be better, I prefer to omitting this variable, gfp_flags looks good as well.

Quoted 8 lines
Quoted 5 lines

BTW, This piece of code has been changed in
"[PATCH v2 00/24] erofs: promote erofs from staging", I will sync the code after some guys takes a look at v2....

We have enough time to merge modified staging codes to generic fs one till next merge window, so don't worry, you can do the merge in batch.

Yes, you are right. Actually I am not too worry about the staging merges but how to catch Viro's eye (sigh...)...

Thanks,
Gao Xiang

Quoted 24 lines

Thanks,

Quoted 21 lines

Thanks,
Gao Xiang

Quoted 5 lines
drivers/staging/erofs/unzip_vle.c +0 -2
 		/* fallback to global pagemap for the lowmem scenario */
 		if (unlikely(!pages)) {
-			if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
-				goto repeat;

drivers/staging/erofs/unzip_vle.c static int z_erofs_vle_unzip(struct super_block *sb,

Quoted 10 lines
drivers/staging/erofs/unzip_vle.c +2 -4
-			else {
-				mutex_lock(&z_pagemap_global_lock);
-				pages = z_pagemap_global;
-			}
+			mutex_lock(&z_pagemap_global_lock);
+			pages = z_pagemap_global;
 		}
 	}
 
 

.