lkml.org 
[lkml]   [2021]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] blk-cgroup: prevent rcu_sched detected stalls warnings while iterating blkgs
Hello, Yu.

On Fri, Jul 02, 2021 at 12:04:44PM +0800, Yu Kuai wrote:
> blkcg_activate_policy() and blkcg_deactivate_policy() might have the
> same problem, fix them the same way.

Given that these are basically only called from module init/exit paths,
let's leave them alone for now.

> +#define BLKG_BATCH_OP_NUM 64

Can we do BLKG_DESTRY_BATCH_SIZE instead?

> static void blkg_destroy_all(struct request_queue *q)
> {
> struct blkcg_gq *blkg, *n;
> + int count = BLKG_BATCH_OP_NUM;
>
> +restart:
> spin_lock_irq(&q->queue_lock);
> list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) {
> struct blkcg *blkcg = blkg->blkcg;
> @@ -430,6 +434,17 @@ static void blkg_destroy_all(struct request_queue *q)
> spin_lock(&blkcg->lock);
> blkg_destroy(blkg);
> spin_unlock(&blkcg->lock);
> +
> + /*
> + * in order to avoid holding the spin lock for too long, release
> + * it when a batch of blkgs are destroyed.
> + */
> + if (!(--count)) {
> + count = BLKG_BATCH_OP_NUM;
> + spin_unlock_irq(&q->queue_lock);
> + cond_resched();
> + goto restart;
> + }
> }

This part looks good otherwise.

Thanks.

--
tejun

\
 
 \ /
  Last update: 2021-07-06 19:57    [W:0.039 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site