函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:kernel\smp.c Create Date:2022-07-27 11:56:09
首页 Copyright©Brick

318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/**
 * smp_call_function_single_async(): Run an asynchronous function on a
 *                   specific CPU.
 * @cpu: The CPU to run on.
 * @csd: Pre-allocated and setup data structure
 *
 * Like smp_call_function_single(), but the call is asynchonous and
 * can thus be done from contexts with disabled interrupts.
 *
 * The caller passes his own pre-allocated data structure
 * (ie: embedded in an object) and is responsible for synchronizing it
 * such that the IPIs performed on the @csd are strictly serialized.
 *
 * NOTE: Be careful, there is unfortunately no current debugging facility to
 * validate the correctness of this serialization.
 */
int smp_call_function_single_async(int cpu, call_single_data_t *csd)
{
    int err = 0;
 
    preempt_disable();
 
    /* We could deadlock if we have to wait here with interrupts disabled! */
    if (WARN_ON_ONCE(csd->flags & CSD_FLAG_LOCK))
        csd_lock_wait(csd);
 
    csd->flags = CSD_FLAG_LOCK;
    smp_wmb();
 
    err = generic_exec_single(cpu, csd, csd->func, csd->info);
    preempt_enable();
 
    return err;
}