Re: [PATCH 1/3] block: introduce blk_queue_nr_active()

Ewan Milne
2023-09-27T14:50:06Z

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.

Or did you mean that the function is too expensive? See other discussions.

-Ewan

On Mon, Sep 25, 2023 at 4:56 PM Bart Van Assche <bvanassche@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.
>
> Thanks,
>
> Bart.
>