函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:block\blk-mq.c Create Date:2022-07-27 18:45:07
首页 Copyright©Brick

1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
{
    int srcu_idx;
 
    /*
     * We should be running this queue from one of the CPUs that
     * are mapped to it.
     *
     * There are at least two related races now between setting
     * hctx->next_cpu from blk_mq_hctx_next_cpu() and running
     * __blk_mq_run_hw_queue():
     *
     * - hctx->next_cpu is found offline in blk_mq_hctx_next_cpu(),
     *   but later it becomes online, then this warning is harmless
     *   at all
     *
     * - hctx->next_cpu is found online in blk_mq_hctx_next_cpu(),
     *   but later it becomes offline, then the warning can't be
     *   triggered, and we depend on blk-mq timeout handler to
     *   handle dispatched requests to this hctx
     */
    if (!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
        cpu_online(hctx->next_cpu)) {
        printk(KERN_WARNING "run queue from wrong CPU %d, hctx %s\n",
            raw_smp_processor_id(),
            cpumask_empty(hctx->cpumask) ? "inactive": "active");
        dump_stack();
    }
 
    /*
     * We can't run the queue inline with ints disabled. Ensure that
     * we catch bad users of this early.
     */
    WARN_ON_ONCE(in_interrupt());
 
    might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
 
    hctx_lock(hctx, &srcu_idx);
    blk_mq_sched_dispatch_requests(hctx);
    hctx_unlock(hctx, srcu_idx);
}