All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: wake up discard_thread iff there is a candidate
@ 2017-08-24 19:03 ` Jaegeuk Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2017-08-24 19:03 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch fixes to avoid needless wake ups.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c |  3 +--
 fs/f2fs/segment.h | 25 +++++++++++++++++++++++++
 fs/f2fs/sysfs.c   |  6 +-----
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8306beace7cb..8375257b6b26 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1494,8 +1494,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 		kmem_cache_free(discard_entry_slab, entry);
 	}
 
-	dcc->discard_wake = 1;
-	wake_up_interruptible_all(&dcc->discard_wait_queue);
+	wake_up_discard_thread(sbi, false);
 }
 
 static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b9b4f85ffeb6..5099e12ee808 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -798,3 +798,28 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
 	wbc->nr_to_write = desired;
 	return desired - nr_to_write;
 }
+
+static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
+{
+	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+	bool wakeup = false;
+	int i;
+
+	if (force)
+		goto wake_up;
+
+	mutex_lock(&dcc->cmd_lock);
+	for (i = MAX_PLIST_NUM - 1;
+			i >= 0 && plist_issue(dcc->pend_list_tag[i]); i--) {
+		if (!list_empty(&dcc->pend_list[i])) {
+			wakeup = true;
+			break;
+		}
+	}
+	mutex_unlock(&dcc->cmd_lock);
+	if (wakeup)
+		return;
+wake_up:
+	dcc->discard_wake = 1;
+	wake_up_interruptible_all(&dcc->discard_wait_queue);
+}
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index b9ad9041559f..962735dc9c63 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -178,13 +178,9 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
 	if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
 		f2fs_reset_iostat(sbi);
 	if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
-		struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
-
 		sbi->gc_thread->gc_wake = 1;
 		wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
-
-		dcc->discard_wake = 1;
-		wake_up_interruptible_all(&dcc->discard_wait_queue);
+		wake_up_discard_thread(sbi, true);
 	}
 
 	return count;
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

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

* [PATCH] f2fs: wake up discard_thread iff there is a candidate
@ 2017-08-24 19:03 ` Jaegeuk Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2017-08-24 19:03 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch fixes to avoid needless wake ups.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c |  3 +--
 fs/f2fs/segment.h | 25 +++++++++++++++++++++++++
 fs/f2fs/sysfs.c   |  6 +-----
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8306beace7cb..8375257b6b26 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1494,8 +1494,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 		kmem_cache_free(discard_entry_slab, entry);
 	}
 
-	dcc->discard_wake = 1;
-	wake_up_interruptible_all(&dcc->discard_wait_queue);
+	wake_up_discard_thread(sbi, false);
 }
 
 static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b9b4f85ffeb6..5099e12ee808 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -798,3 +798,28 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
 	wbc->nr_to_write = desired;
 	return desired - nr_to_write;
 }
+
+static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
+{
+	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+	bool wakeup = false;
+	int i;
+
+	if (force)
+		goto wake_up;
+
+	mutex_lock(&dcc->cmd_lock);
+	for (i = MAX_PLIST_NUM - 1;
+			i >= 0 && plist_issue(dcc->pend_list_tag[i]); i--) {
+		if (!list_empty(&dcc->pend_list[i])) {
+			wakeup = true;
+			break;
+		}
+	}
+	mutex_unlock(&dcc->cmd_lock);
+	if (wakeup)
+		return;
+wake_up:
+	dcc->discard_wake = 1;
+	wake_up_interruptible_all(&dcc->discard_wait_queue);
+}
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index b9ad9041559f..962735dc9c63 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -178,13 +178,9 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
 	if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
 		f2fs_reset_iostat(sbi);
 	if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
-		struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
-
 		sbi->gc_thread->gc_wake = 1;
 		wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
-
-		dcc->discard_wake = 1;
-		wake_up_interruptible_all(&dcc->discard_wait_queue);
+		wake_up_discard_thread(sbi, true);
 	}
 
 	return count;
-- 
2.14.0.rc1.383.gd1ce394fe2-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [f2fs-dev] [PATCH] f2fs: wake up discard_thread iff there is a candidate
  2017-08-24 19:03 ` Jaegeuk Kim
@ 2017-08-28  9:45   ` Chao Yu
  -1 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2017-08-28  9:45 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/8/25 3:03, Jaegeuk Kim wrote:
> This patch fixes to avoid needless wake ups.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c |  3 +--
>  fs/f2fs/segment.h | 25 +++++++++++++++++++++++++
>  fs/f2fs/sysfs.c   |  6 +-----
>  3 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8306beace7cb..8375257b6b26 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1494,8 +1494,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  		kmem_cache_free(discard_entry_slab, entry);
>  	}
>  
> -	dcc->discard_wake = 1;
> -	wake_up_interruptible_all(&dcc->discard_wait_queue);
> +	wake_up_discard_thread(sbi, false);
>  }
>  
>  static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index b9b4f85ffeb6..5099e12ee808 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -798,3 +798,28 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
>  	wbc->nr_to_write = desired;
>  	return desired - nr_to_write;
>  }
> +
> +static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
> +{
> +	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> +	bool wakeup = false> +	int i;
> +
> +	if (force)
> +		goto wake_up;
> +
> +	mutex_lock(&dcc->cmd_lock);
> +	for (i = MAX_PLIST_NUM - 1;
> +			i >= 0 && plist_issue(dcc->pend_list_tag[i]); i--) {
> +		if (!list_empty(&dcc->pend_list[i])) {
> +			wakeup = true;
> +			break;
> +		}
> +	}
> +	mutex_unlock(&dcc->cmd_lock);
> +	if (wakeup)

if (!wakeup)

Other part looks good to me,

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> +		return;
> +wake_up:
> +	dcc->discard_wake = 1;
> +	wake_up_interruptible_all(&dcc->discard_wait_queue);
> +}
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index b9ad9041559f..962735dc9c63 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -178,13 +178,9 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
>  	if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
>  		f2fs_reset_iostat(sbi);
>  	if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
> -		struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> -
>  		sbi->gc_thread->gc_wake = 1;
>  		wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
> -
> -		dcc->discard_wake = 1;
> -		wake_up_interruptible_all(&dcc->discard_wait_queue);
> +		wake_up_discard_thread(sbi, true);
>  	}
>  
>  	return count;
> 

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

* Re: [f2fs-dev] [PATCH] f2fs: wake up discard_thread iff there is a candidate
@ 2017-08-28  9:45   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2017-08-28  9:45 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/8/25 3:03, Jaegeuk Kim wrote:
> This patch fixes to avoid needless wake ups.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c |  3 +--
>  fs/f2fs/segment.h | 25 +++++++++++++++++++++++++
>  fs/f2fs/sysfs.c   |  6 +-----
>  3 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8306beace7cb..8375257b6b26 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1494,8 +1494,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  		kmem_cache_free(discard_entry_slab, entry);
>  	}
>  
> -	dcc->discard_wake = 1;
> -	wake_up_interruptible_all(&dcc->discard_wait_queue);
> +	wake_up_discard_thread(sbi, false);
>  }
>  
>  static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index b9b4f85ffeb6..5099e12ee808 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -798,3 +798,28 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
>  	wbc->nr_to_write = desired;
>  	return desired - nr_to_write;
>  }
> +
> +static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
> +{
> +	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> +	bool wakeup = false> +	int i;
> +
> +	if (force)
> +		goto wake_up;
> +
> +	mutex_lock(&dcc->cmd_lock);
> +	for (i = MAX_PLIST_NUM - 1;
> +			i >= 0 && plist_issue(dcc->pend_list_tag[i]); i--) {
> +		if (!list_empty(&dcc->pend_list[i])) {
> +			wakeup = true;
> +			break;
> +		}
> +	}
> +	mutex_unlock(&dcc->cmd_lock);
> +	if (wakeup)

if (!wakeup)

Other part looks good to me,

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> +		return;
> +wake_up:
> +	dcc->discard_wake = 1;
> +	wake_up_interruptible_all(&dcc->discard_wait_queue);
> +}
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index b9ad9041559f..962735dc9c63 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -178,13 +178,9 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
>  	if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
>  		f2fs_reset_iostat(sbi);
>  	if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
> -		struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> -
>  		sbi->gc_thread->gc_wake = 1;
>  		wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
> -
> -		dcc->discard_wake = 1;
> -		wake_up_interruptible_all(&dcc->discard_wait_queue);
> +		wake_up_discard_thread(sbi, true);
>  	}
>  
>  	return count;
> 

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

end of thread, other threads:[~2017-08-28  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24 19:03 [PATCH] f2fs: wake up discard_thread iff there is a candidate Jaegeuk Kim
2017-08-24 19:03 ` Jaegeuk Kim
2017-08-28  9:45 ` [f2fs-dev] " Chao Yu
2017-08-28  9:45   ` Chao Yu

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.