linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 7/7] f2fs: optimize shrink count
@ 2022-06-30 11:26 Guowei Du
  2022-07-01  0:50 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Guowei Du @ 2022-06-30 11:26 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, duguowei, linux-f2fs-devel

From: duguowei <duguowei@xiaomi.com>

Remove the local variable 'run_no', add comments for better
reading.

Signed-off-by: duguowei <duguowei@xiaomi.com>
---
 fs/f2fs/shrinker.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index dd3c3c7a90ec..7e439496dfca 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -76,18 +76,18 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
 	unsigned long nr = sc->nr_to_scan;
 	struct f2fs_sb_info *sbi;
 	struct list_head *p;
-	unsigned int run_no;
 	unsigned long freed = 0;
 
 	spin_lock(&f2fs_list_lock);
-	do {
-		run_no = ++shrinker_run_no;
-	} while (run_no == 0);
+	shrinker_run_no++;
+	/* if overflow, next loop needs to skip number 0 */
+	if (!shrinker_run_no)
+		shrinker_run_no = 1;
 	p = f2fs_list.next;
 	while (p != &f2fs_list) {
 		sbi = list_entry(p, struct f2fs_sb_info, s_list);
 
-		if (sbi->shrinker_run_no == run_no)
+		if (sbi->shrinker_run_no == shrinker_run_no)
 			break;
 
 		/* stop f2fs_put_super */
@@ -97,7 +97,7 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
 		}
 		spin_unlock(&f2fs_list_lock);
 
-		sbi->shrinker_run_no = run_no;
+		sbi->shrinker_run_no = shrinker_run_no;
 
 		/* shrink extent cache entries */
 		freed += f2fs_shrink_extent_tree(sbi, nr >> 1);
-- 
2.36.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH 7/7] f2fs: optimize shrink count
  2022-06-30 11:26 [f2fs-dev] [PATCH 7/7] f2fs: optimize shrink count Guowei Du
@ 2022-07-01  0:50 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2022-07-01  0:50 UTC (permalink / raw)
  To: Guowei Du, jaegeuk; +Cc: linux-kernel, duguowei, linux-f2fs-devel

On 2022/6/30 19:26, Guowei Du wrote:
> From: duguowei <duguowei@xiaomi.com>
> 
> Remove the local variable 'run_no', add comments for better
> reading.

Not sure, I guess original implementation considers the race condition for
f2fs_shrink_scan vs f2fs_shrink_scan case? so it uses a local variable to
keep the per-round context info?

Jaegeuk, please help to check that.

Thanks,

> 
> Signed-off-by: duguowei <duguowei@xiaomi.com>
> ---
>   fs/f2fs/shrinker.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
> index dd3c3c7a90ec..7e439496dfca 100644
> --- a/fs/f2fs/shrinker.c
> +++ b/fs/f2fs/shrinker.c
> @@ -76,18 +76,18 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
>   	unsigned long nr = sc->nr_to_scan;
>   	struct f2fs_sb_info *sbi;
>   	struct list_head *p;
> -	unsigned int run_no;
>   	unsigned long freed = 0;
>   
>   	spin_lock(&f2fs_list_lock);
> -	do {
> -		run_no = ++shrinker_run_no;
> -	} while (run_no == 0);
> +	shrinker_run_no++;
> +	/* if overflow, next loop needs to skip number 0 */
> +	if (!shrinker_run_no)
> +		shrinker_run_no = 1;
>   	p = f2fs_list.next;
>   	while (p != &f2fs_list) {
>   		sbi = list_entry(p, struct f2fs_sb_info, s_list);
>   
> -		if (sbi->shrinker_run_no == run_no)
> +		if (sbi->shrinker_run_no == shrinker_run_no)
>   			break;
>   
>   		/* stop f2fs_put_super */
> @@ -97,7 +97,7 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
>   		}
>   		spin_unlock(&f2fs_list_lock);
>   
> -		sbi->shrinker_run_no = run_no;
> +		sbi->shrinker_run_no = shrinker_run_no;
>   
>   		/* shrink extent cache entries */
>   		freed += f2fs_shrink_extent_tree(sbi, nr >> 1);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-01  0:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 11:26 [f2fs-dev] [PATCH 7/7] f2fs: optimize shrink count Guowei Du
2022-07-01  0:50 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).