diff mbox series

[1/1,SRU,X] bcache: add cond_resched() in __bch_cache_cmp()

Message ID 20191010201940.30382-3-halves@canonical.com
State New
Headers show
Series [1/1,SRU,X] bcache: add cond_resched() in __bch_cache_cmp() | expand

Commit Message

Heitor Alves de Siqueira Oct. 10, 2019, 8:19 p.m. UTC
From: Shile Zhang <shile.zhang@linux.alibaba.com>

BugLink: https://bugs.launchpad.net/bugs/1840043

Read /sys/fs/bcache/<uuid>/cacheN/priority_stats can take very long
time with huge cache after long run.

Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
Tested-by: Heitor Alves de Siqueira <halves@canonical.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(backported from commit d55a4ae9e1af5fb1657e38284ef46c56e668efdb)
Signed-off-by: Heitor Alves de Siqueira <halves@canonical.com>
---
 drivers/md/bcache/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Connor Kuehl Oct. 15, 2019, 5:03 p.m. UTC | #1
On 10/10/19 1:19 PM, Heitor Alves de Siqueira wrote:
> From: Shile Zhang <shile.zhang@linux.alibaba.com>
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index 940ba3e1bad1..057804caeed2 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -820,7 +820,7 @@ SHOW(__bch_cache)
>   
>   	if (attr == &sysfs_priority_stats) {
>   		int cmp(const void *l, const void *r)
> -		{	return *((uint16_t *) r) - *((uint16_t *) l); }
> +		{	cond_resched(); return *((uint16_t *) r) - *((uint16_t *) l); }

Just a nit-pick, but because it's already a backport and now we've got 
two separate statements here, I think they should each be on their own 
lines. Aside from that it looks good to me and my ack will be sent to 
the patch cover letter in just a moment.

>   
>   		struct bucket *b;
>   		size_t n = ca->sb.nbuckets, i;
>
diff mbox series

Patch

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 940ba3e1bad1..057804caeed2 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -820,7 +820,7 @@  SHOW(__bch_cache)
 
 	if (attr == &sysfs_priority_stats) {
 		int cmp(const void *l, const void *r)
-		{	return *((uint16_t *) r) - *((uint16_t *) l); }
+		{	cond_resched(); return *((uint16_t *) r) - *((uint16_t *) l); }
 
 		struct bucket *b;
 		size_t n = ca->sb.nbuckets, i;