* [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
@ 2019-02-16 8:46 Gao Xiang
2019-02-20 1:26 ` Chao Yu
2019-02-20 2:38 ` Gao Xiang
0 siblings, 2 replies; 5+ messages in thread
From: Gao Xiang @ 2019-02-16 8:46 UTC (permalink / raw)
To: Chao Yu, Greg Kroah-Hartman, devel
Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei,
Gao Xiang
page_private(page) cannot be changed if page lock is taken.
Besides, the corresponding workgroup won't be freed
if the page is already protected by page lock, therefore
no need to take rcu read lock.
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
drivers/staging/erofs/unzip_vle.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index 2b5951f233db..a127d8db76d8 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -238,14 +238,9 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
{
struct erofs_sb_info *const sbi = EROFS_SB(mapping->host->i_sb);
const unsigned int clusterpages = erofs_clusterpages(sbi);
-
- struct z_erofs_vle_workgroup *grp;
+ struct z_erofs_vle_workgroup *const grp = (void *)page_private(page);
int ret = 0; /* 0 - busy */
- /* prevent the workgroup from being freed */
- rcu_read_lock();
- grp = (void *)page_private(page);
-
if (erofs_workgroup_try_to_freeze(&grp->obj, 1)) {
unsigned int i;
@@ -257,12 +252,11 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
}
}
erofs_workgroup_unfreeze(&grp->obj, 1);
- }
- rcu_read_unlock();
- if (ret) {
- ClearPagePrivate(page);
- put_page(page);
+ if (ret) {
+ ClearPagePrivate(page);
+ put_page(page);
+ }
}
return ret;
}
--
2.14.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
2019-02-16 8:46 [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page Gao Xiang
@ 2019-02-20 1:26 ` Chao Yu
2019-02-20 2:38 ` Gao Xiang
1 sibling, 0 replies; 5+ messages in thread
From: Chao Yu @ 2019-02-20 1:26 UTC (permalink / raw)
To: Gao Xiang, Greg Kroah-Hartman, devel
Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei
On 2019/2/16 16:46, Gao Xiang wrote:
> page_private(page) cannot be changed if page lock is taken.
>
> Besides, the corresponding workgroup won't be freed
> if the page is already protected by page lock, therefore
> no need to take rcu read lock.
>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
2019-02-16 8:46 [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page Gao Xiang
2019-02-20 1:26 ` Chao Yu
@ 2019-02-20 2:38 ` Gao Xiang
2019-02-20 10:20 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2019-02-20 2:38 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Chao Yu, devel, LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du,
Fang Wei
Hi Greg,
Could you consider take some time on these two patches for linux-5.1-rc1?
1) staging: erofs: fix race of initializing xattrs of a inode at the same time
2) staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
It will be of great help, especially patch 1 (it could cause potential memleak
in the race condition without it).
If something (eg, resend these patches in a new patchset) is needed, I'm happy
to do that. :)
Thanks,
Gao Xiang
On 2019/2/16 16:46, Gao Xiang wrote:
> page_private(page) cannot be changed if page lock is taken.
>
> Besides, the corresponding workgroup won't be freed
> if the page is already protected by page lock, therefore
> no need to take rcu read lock.
>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> ---
> drivers/staging/erofs/unzip_vle.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
> index 2b5951f233db..a127d8db76d8 100644
> --- a/drivers/staging/erofs/unzip_vle.c
> +++ b/drivers/staging/erofs/unzip_vle.c
> @@ -238,14 +238,9 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
> {
> struct erofs_sb_info *const sbi = EROFS_SB(mapping->host->i_sb);
> const unsigned int clusterpages = erofs_clusterpages(sbi);
> -
> - struct z_erofs_vle_workgroup *grp;
> + struct z_erofs_vle_workgroup *const grp = (void *)page_private(page);
> int ret = 0; /* 0 - busy */
>
> - /* prevent the workgroup from being freed */
> - rcu_read_lock();
> - grp = (void *)page_private(page);
> -
> if (erofs_workgroup_try_to_freeze(&grp->obj, 1)) {
> unsigned int i;
>
> @@ -257,12 +252,11 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
> }
> }
> erofs_workgroup_unfreeze(&grp->obj, 1);
> - }
> - rcu_read_unlock();
>
> - if (ret) {
> - ClearPagePrivate(page);
> - put_page(page);
> + if (ret) {
> + ClearPagePrivate(page);
> + put_page(page);
> + }
> }
> return ret;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
2019-02-20 2:38 ` Gao Xiang
@ 2019-02-20 10:20 ` Greg Kroah-Hartman
2019-02-20 10:33 ` Gao Xiang
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-20 10:20 UTC (permalink / raw)
To: Gao Xiang
Cc: devel, Chao Yu, linux-erofs, Chao Yu, LKML, weidu.du, Fang Wei,
Miao Xie
On Wed, Feb 20, 2019 at 10:38:53AM +0800, Gao Xiang wrote:
> Hi Greg,
>
> Could you consider take some time on these two patches for linux-5.1-rc1?
> 1) staging: erofs: fix race of initializing xattrs of a inode at the same time
> 2) staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
>
> It will be of great help, especially patch 1 (it could cause potential memleak
> in the race condition without it).
Ok, I'll queue them up now, I was waiting for reviewed-by tags from
others to show up :)
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
2019-02-20 10:20 ` Greg Kroah-Hartman
@ 2019-02-20 10:33 ` Gao Xiang
0 siblings, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2019-02-20 10:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, Chao Yu, linux-erofs, Chao Yu, LKML, weidu.du, Fang Wei,
Miao Xie
On 2019/2/20 18:20, Greg Kroah-Hartman wrote:
> On Wed, Feb 20, 2019 at 10:38:53AM +0800, Gao Xiang wrote:
>> Hi Greg,
>>
>> Could you consider take some time on these two patches for linux-5.1-rc1?
>> 1) staging: erofs: fix race of initializing xattrs of a inode at the same time
>> 2) staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
>>
>> It will be of great help, especially patch 1 (it could cause potential memleak
>> in the race condition without it).
>
> Ok, I'll queue them up now, I was waiting for reviewed-by tags from
> others to show up :)
Thanks! :)
Gao Xiang
>
> greg k-h
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-20 10:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-16 8:46 [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page Gao Xiang
2019-02-20 1:26 ` Chao Yu
2019-02-20 2:38 ` Gao Xiang
2019-02-20 10:20 ` Greg Kroah-Hartman
2019-02-20 10:33 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox