* [PATCH] staging: erofs: avoid opened loop codes
@ 2019-07-16 8:52 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2019-07-16 8:52 UTC (permalink / raw)
To: gregkh, devel; +Cc: Chao Yu, linux-erofs, chao
Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index f0dab81ff816..3a0dbcb8cc9f 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -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;
}
}
--
2.18.0.rc1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] staging: erofs: avoid opened loop codes
@ 2019-07-16 8:52 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2019-07-16 8:52 UTC (permalink / raw)
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(-)
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index f0dab81ff816..3a0dbcb8cc9f 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -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;
}
}
--
2.18.0.rc1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: erofs: avoid opened loop codes
2019-07-16 8:52 ` Chao Yu
@ 2019-07-16 9:12 ` Gao Xiang
-1 siblings, 0 replies; 8+ messages in thread
From: Gao Xiang @ 2019-07-16 9:12 UTC (permalink / raw)
To: Chao Yu, gregkh, devel; +Cc: chao, linux-erofs
Hi Chao,
On 2019/7/16 16:52, Chao Yu wrote:
> Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
> index f0dab81ff816..3a0dbcb8cc9f 100644
> --- a/drivers/staging/erofs/unzip_vle.c
> +++ b/drivers/staging/erofs/unzip_vle.c
> @@ -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);
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
>
> /* 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;
> }
> }
>
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] staging: erofs: avoid opened loop codes
@ 2019-07-16 9:12 ` Gao Xiang
0 siblings, 0 replies; 8+ messages in thread
From: Gao Xiang @ 2019-07-16 9:12 UTC (permalink / raw)
Hi Chao,
On 2019/7/16 16:52, Chao Yu wrote:
> 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(-)
>
> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
> index f0dab81ff816..3a0dbcb8cc9f 100644
> --- a/drivers/staging/erofs/unzip_vle.c
> +++ b/drivers/staging/erofs/unzip_vle.c
> @@ -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);
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
>
> /* 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;
> }
> }
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: erofs: avoid opened loop codes
2019-07-16 9:12 ` Gao Xiang
@ 2019-07-16 9:27 ` Chao Yu
-1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2019-07-16 9:27 UTC (permalink / raw)
To: Gao Xiang, gregkh, devel; +Cc: chao, linux-erofs
Hi Xiang,
On 2019/7/16 17:12, Gao Xiang wrote:
> Hi Chao,
>
> On 2019/7/16 16:52, Chao Yu wrote:
>> Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
>> 1 file changed, 8 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
>> index f0dab81ff816..3a0dbcb8cc9f 100644
>> --- a/drivers/staging/erofs/unzip_vle.c
>> +++ b/drivers/staging/erofs/unzip_vle.c
>> @@ -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);
>
> 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?
>
> 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,
>
> Thanks,
> Gao Xiang
>
>>
>> /* 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;
>> }
>> }
>>
>>
> .
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] staging: erofs: avoid opened loop codes
@ 2019-07-16 9:27 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2019-07-16 9:27 UTC (permalink / raw)
Hi Xiang,
On 2019/7/16 17:12, Gao Xiang wrote:
> Hi Chao,
>
> On 2019/7/16 16:52, Chao Yu wrote:
>> 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(-)
>>
>> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
>> index f0dab81ff816..3a0dbcb8cc9f 100644
>> --- a/drivers/staging/erofs/unzip_vle.c
>> +++ b/drivers/staging/erofs/unzip_vle.c
>> @@ -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);
>
> 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?
>
> 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,
>
> Thanks,
> Gao Xiang
>
>>
>> /* 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;
>> }
>> }
>>
>>
> .
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: erofs: avoid opened loop codes
2019-07-16 9:27 ` Chao Yu
@ 2019-07-16 9:35 ` Gao Xiang
-1 siblings, 0 replies; 8+ messages in thread
From: Gao Xiang @ 2019-07-16 9:35 UTC (permalink / raw)
To: Chao Yu, gregkh, devel; +Cc: chao, linux-erofs
On 2019/7/16 17:27, Chao Yu wrote:
> Hi Xiang,
>
> On 2019/7/16 17:12, Gao Xiang wrote:
>> Hi Chao,
>>
>> On 2019/7/16 16:52, Chao Yu wrote:
>>> Use __GFP_NOFAIL to avoid opened loop codes in z_erofs_vle_unzip().
>>>
>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>> ---
>>> drivers/staging/erofs/unzip_vle.c | 17 ++++++++---------
>>> 1 file changed, 8 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
>>> index f0dab81ff816..3a0dbcb8cc9f 100644
>>> --- a/drivers/staging/erofs/unzip_vle.c
>>> +++ b/drivers/staging/erofs/unzip_vle.c
>>> @@ -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);
>>
>> 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?
Be better, I prefer to omitting this variable, gfp_flags looks good as well.
>
>>
>> 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
>
> Thanks,
>
>>
>> Thanks,
>> Gao Xiang
>>
>>>
>>> /* 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;
>>> }
>>> }
>>>
>>>
>> .
>>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] staging: erofs: avoid opened loop codes
@ 2019-07-16 9:35 ` Gao Xiang
0 siblings, 0 replies; 8+ messages in thread
From: Gao Xiang @ 2019-07-16 9:35 UTC (permalink / raw)
On 2019/7/16 17:27, Chao Yu wrote:
> Hi Xiang,
>
> On 2019/7/16 17:12, Gao Xiang wrote:
>> Hi Chao,
>>
>> On 2019/7/16 16:52, Chao Yu wrote:
>>> 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(-)
>>>
>>> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
>>> index f0dab81ff816..3a0dbcb8cc9f 100644
>>> --- a/drivers/staging/erofs/unzip_vle.c
>>> +++ b/drivers/staging/erofs/unzip_vle.c
>>> @@ -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);
>>
>> 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?
Be better, I prefer to omitting this variable, gfp_flags looks good as well.
>
>>
>> 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
>
> Thanks,
>
>>
>> Thanks,
>> Gao Xiang
>>
>>>
>>> /* 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;
>>> }
>>> }
>>>
>>>
>> .
>>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-07-16 9:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 8:52 [PATCH] staging: erofs: avoid opened loop codes Chao Yu
2019-07-16 8:52 ` Chao Yu
2019-07-16 9:12 ` Gao Xiang
2019-07-16 9:12 ` Gao Xiang
2019-07-16 9:27 ` Chao Yu
2019-07-16 9:27 ` Chao Yu
2019-07-16 9:35 ` Gao Xiang
2019-07-16 9:35 ` Gao Xiang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.