What does "CPU dies" (not hardware-related) mean?

141 views Asked by At

Recently working with workqueue of the Linux kernel, and I found something ("CPU dies") that I'm not sure what it is, even googling it.

Does it means particular CPU core is currently not available or something similar?

Following is the context of the problem I'm asking (full-version):

/**
 * queue_work - queue work on a workqueue
 * @wq: workqueue to use
 * @work: work to queue
 *
 * Returns %false if @work was already on a queue, %true otherwise.
 *
 * We queue the work to the CPU on which it was submitted, but if the CPU dies
 * it can be processed by another CPU.
 */
static inline bool queue_work(struct workqueue_struct *wq,
                  struct work_struct *work)
{
    return queue_work_on(WORK_CPU_UNBOUND, wq, work);
}
1

There are 1 answers

1
Guillaume D On BEST ANSWER

Per-cpu workqueues are generally preferred because they tend to show better performance.

The work queue is submitted on one CPU, but if this CPU goes into IDLE, then the workqueue is moved to another CPU.

A worker goes in IDLE if its workqueue (one workqueue per each worker) is empty.

Each worker-pool bound to an actual CPU implements concurrency management by hooking into the scheduler. The worker-pool is notified whenever an active worker wakes up or sleeps and keeps track of the number of the currently runnable workers. Generally, work items are not expected to hog a CPU and consume many cycles. That means maintaining just enough concurrency to prevent work processing from stalling should be optimal. As long as there are one or more runnable workers on the CPU, the worker-pool doesn’t start execution of a new work, but, when the last running worker goes to sleep, it immediately schedules a new worker so that the CPU doesn’t sit idle while there are pending work items. This allows using a minimal number of workers without losing execution bandwidth.

See here