Re: [PATCH v3 3/8] workqueue: Implement BH workqueues to eventually replace tasklets

From: Hillf Danton
Date: Sun Feb 04 2024 - 23:49:18 EST


On Sun, 4 Feb 2024 11:28:06 -1000 Tejun Heo <tj@xxxxxxxxxx>
> +static void bh_worker(struct worker *worker)
> +{
> + struct worker_pool *pool = worker->pool;
> + int nr_restarts = BH_WORKER_RESTARTS;
> + unsigned long end = jiffies + BH_WORKER_JIFFIES;
> +
> + raw_spin_lock_irq(&pool->lock);
> + worker_leave_idle(worker);
> +
> + /*
> + * This function follows the structure of worker_thread(). See there for
> + * explanations on each step.
> + */
> + if (!need_more_worker(pool))
> + goto done;
> +
> + WARN_ON_ONCE(!list_empty(&worker->scheduled));
> + worker_clr_flags(worker, WORKER_PREP | WORKER_REBOUND);
> +
> + do {
> + struct work_struct *work =
> + list_first_entry(&pool->worklist,
> + struct work_struct, entry);
> +
> + if (assign_work(work, worker, NULL))
> + process_scheduled_works(worker);
> + } while (keep_working(pool) &&
> + --nr_restarts && time_before(jiffies, end));
> +
> + worker_set_flags(worker, WORKER_PREP);
> +done:
> + worker_enter_idle(worker);
> + kick_pool(pool);
> + raw_spin_unlock_irq(&pool->lock);
> +}

I see no need to exec bh works for 2ms with irq disabled.