[PATCH 1/3] block: introduce blk_queue_nr_active()
Bart Van Assche
bvanassche at acm.org
Wed Sep 27 07:58:24 PDT 2023
On 9/27/23 07:49, Ewan Milne wrote:
> On Mon, Sep 25, 2023 at 4:56 PM Bart Van Assche <bvanassche at acm.org> wrote:
>> On 9/25/23 09:31, Ewan D. Milne wrote:
>>> +static inline unsigned int blk_mq_queue_nr_active(struct request_queue *q)
>>> +{
>>> + unsigned int nr_active = 0;
>>> + struct blk_mq_hw_ctx *hctx;
>>> + unsigned long i;
>>> +
>>> + queue_for_each_hw_ctx(q, hctx, i) {
>>> + if (unlikely(blk_mq_is_shared_tags(hctx->flags)))
>>> + return atomic_read(&q->nr_active_requests_shared_tags);
>>> + nr_active += atomic_read(&hctx->nr_active);
>>> + }
>>> + return nr_active;
>>> +}
>>
>> The above function should never be called from any command submission
>> code path. Hence, I think it should be added in a .c file instead of
>> include/linux/blk-mq.h.
>
> The function is only called in one place by the queue-depth nvme path
> selector in a
> later patch in the series, so it is called in the submission path,
> which is why I made it inline.
Hi Ewan,
In order to keep include/linux/blk-mq.h readable and in order to minimize
the kernel compilation time, nontrivial functions that are not called from
the hot path should occur in a .c file instead of in a .h file.
Thanks,
Bart.
More information about the Linux-nvme
mailing list