Hey so I'm looking at this function in the [kernel source code](http://lxr.free-electrons.com/source/include/linux/workqueue.h#L483 "queue_delayed_work"). I'm trying to figure out how Linux handles the situation where a task cannot be scheduled on the local CPU.

```
/**
* queue_delayed_work - queue work on a workqueue after delay
* @wq: workqueue to use
* @dwork: delayable work to queue
* @delay: number of jiffies to wait before queueing
*
* Equivalent to queue_delayed_work_on() but tries to use the local CPU.
*/
static inline bool queue_delayed_work(struct workqueue_struct *wq,
                                      struct delayed_work *dwork,
                                      unsigned long delay)
{
        return queue_delayed_work_on(WORK_CPU_UNBOUND, wq, dwork, delay);
}

```

And here is [`queue_delayed_work_on`](http://lxr.free-electrons.com/source/kernel/workqueue.c#L1512):

```
bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
                           struct delayed_work *dwork, unsigned long delay)
{
        struct work_struct *work = &dwork->work;
        bool ret = false;
        unsigned long flags;

        /* read the comment in __queue_work() */
        local_irq_save(flags);

        if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) {
                __queue_delayed_work(cpu, wq, dwork, delay);
                ret = true;
        }

        local_irq_restore(flags);
        return ret;
}

```

Say if you have 4 CPUs and it can't schedule a task on CPU 1, which one does it choose and where in the source code is this handled? I've been looking for a while and can't find it. Even if you don't understand how it works I'd really appreciate a link to where the magic happens.