mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Chao Yu <yuchao0@huawei.com>, <devel@driverdev.osuosl.org>,
	LKML <linux-kernel@vger.kernel.org>,
	<linux-erofs@lists.ozlabs.org>, Chao Yu <chao@kernel.org>,
	Miao Xie <miaoxie@huawei.com>, <weidu.du@huawei.com>,
	"Fang Wei" <fangwei1@huawei.com>
Subject: Re: [PATCH] staging: erofs: remove rcu_read_lock() in erofs_try_to_free_cached_page
Date: Wed, 20 Feb 2019 10:38:53 +0800	[thread overview]
Message-ID: <fc058e45-a645-c680-2ce0-19de83fffc2e@huawei.com> (raw)
In-Reply-To: <20190216084650.33841-1-gaoxiang25@huawei.com>

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;
>  }
> 

  parent reply	other threads:[~2019-02-20  2:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16  8:46 Gao Xiang
2019-02-20  1:26 ` Chao Yu
2019-02-20  2:38 ` Gao Xiang [this message]
2019-02-20 10:20   ` Greg Kroah-Hartman
2019-02-20 10:33     ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc058e45-a645-c680-2ce0-19de83fffc2e@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=chao@kernel.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=fangwei1@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=weidu.du@huawei.com \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome