mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-06-29 23:43:21 -04:00
block: make queue stat accounting a reference
kyber turns on IO statistics when it is loaded on a queue, which means that even if kyber is then later unloaded, we're still stuck with stats enabled on the queue. Change the account enabled from a bool to an int, and pair the enable call with the equivalent disable call. This ensures that stats gets turned off again appropriately. Reviewed-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
0ba4566cd8
commit
68497092bd
3 changed files with 18 additions and 5 deletions
|
@ -15,7 +15,7 @@
|
||||||
struct blk_queue_stats {
|
struct blk_queue_stats {
|
||||||
struct list_head callbacks;
|
struct list_head callbacks;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
bool enable_accounting;
|
int accounting;
|
||||||
};
|
};
|
||||||
|
|
||||||
void blk_rq_stat_init(struct blk_rq_stat *stat)
|
void blk_rq_stat_init(struct blk_rq_stat *stat)
|
||||||
|
@ -161,7 +161,7 @@ void blk_stat_remove_callback(struct request_queue *q,
|
||||||
|
|
||||||
spin_lock_irqsave(&q->stats->lock, flags);
|
spin_lock_irqsave(&q->stats->lock, flags);
|
||||||
list_del_rcu(&cb->list);
|
list_del_rcu(&cb->list);
|
||||||
if (list_empty(&q->stats->callbacks) && !q->stats->enable_accounting)
|
if (list_empty(&q->stats->callbacks) && !q->stats->accounting)
|
||||||
blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
|
blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
|
||||||
spin_unlock_irqrestore(&q->stats->lock, flags);
|
spin_unlock_irqrestore(&q->stats->lock, flags);
|
||||||
|
|
||||||
|
@ -184,13 +184,24 @@ void blk_stat_free_callback(struct blk_stat_callback *cb)
|
||||||
call_rcu(&cb->rcu, blk_stat_free_callback_rcu);
|
call_rcu(&cb->rcu, blk_stat_free_callback_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blk_stat_disable_accounting(struct request_queue *q)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&q->stats->lock, flags);
|
||||||
|
if (!--q->stats->accounting)
|
||||||
|
blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
|
||||||
|
spin_unlock_irqrestore(&q->stats->lock, flags);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(blk_stat_disable_accounting);
|
||||||
|
|
||||||
void blk_stat_enable_accounting(struct request_queue *q)
|
void blk_stat_enable_accounting(struct request_queue *q)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&q->stats->lock, flags);
|
spin_lock_irqsave(&q->stats->lock, flags);
|
||||||
q->stats->enable_accounting = true;
|
if (!q->stats->accounting++)
|
||||||
blk_queue_flag_set(QUEUE_FLAG_STATS, q);
|
blk_queue_flag_set(QUEUE_FLAG_STATS, q);
|
||||||
spin_unlock_irqrestore(&q->stats->lock, flags);
|
spin_unlock_irqrestore(&q->stats->lock, flags);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(blk_stat_enable_accounting);
|
EXPORT_SYMBOL_GPL(blk_stat_enable_accounting);
|
||||||
|
@ -205,7 +216,7 @@ struct blk_queue_stats *blk_alloc_queue_stats(void)
|
||||||
|
|
||||||
INIT_LIST_HEAD(&stats->callbacks);
|
INIT_LIST_HEAD(&stats->callbacks);
|
||||||
spin_lock_init(&stats->lock);
|
spin_lock_init(&stats->lock);
|
||||||
stats->enable_accounting = false;
|
stats->accounting = 0;
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ void blk_stat_add(struct request *rq, u64 now);
|
||||||
|
|
||||||
/* record time/size info in request but not add a callback */
|
/* record time/size info in request but not add a callback */
|
||||||
void blk_stat_enable_accounting(struct request_queue *q);
|
void blk_stat_enable_accounting(struct request_queue *q);
|
||||||
|
void blk_stat_disable_accounting(struct request_queue *q);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blk_stat_alloc_callback() - Allocate a block statistics callback.
|
* blk_stat_alloc_callback() - Allocate a block statistics callback.
|
||||||
|
|
|
@ -433,6 +433,7 @@ static void kyber_exit_sched(struct elevator_queue *e)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
del_timer_sync(&kqd->timer);
|
del_timer_sync(&kqd->timer);
|
||||||
|
blk_stat_disable_accounting(kqd->q);
|
||||||
|
|
||||||
for (i = 0; i < KYBER_NUM_DOMAINS; i++)
|
for (i = 0; i < KYBER_NUM_DOMAINS; i++)
|
||||||
sbitmap_queue_free(&kqd->domain_tokens[i]);
|
sbitmap_queue_free(&kqd->domain_tokens[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue