Re: [RFC PATCH 0/6] Convert all tasklets to workqueues

From: Oleg Nesterov
Date: Thu Jun 28 2007 - 12:37:54 EST


On 06/28, Steven Rostedt wrote:
>
> I also don't see any nice API to have the priority set for a workqueue
> thread from within the kernel. Looks like one needs to be added,
> otherwise, I need to have the wrapper dig into the workqueue structs to
> find the thread that handles the workqueue.

It is not so trivial to implement properly. Note that CPU_UP creates a new
cwq->thread, so somehow workqueue should "remember" its priority. This means
we should record it in workqueue_struct. The most simple way is to add yet
another parameter to __create_workqueue(), but this is nasty.

So, perhaps we should add "long nice" to "struct workqueue_struct", and then

void set_workqueue_nice(struct workqueue_struct *wq, long nice)
{
const cpumask_t *cpu_map = wq_cpu_map(wq);
struct cpu_workqueue_struct *cwq;
int cpu;

wq->nice = nice;

mutex_lock(&workqueue_mutex);

for_each_cpu_mask(cpu, *cpu_map) {
cwq = per_cpu_ptr(wq->cpu_wq, cpu);
if (cwq->thread)
set_user_nice(cwq->thread, nice);
}

mutex_unlock(&workqueue_mutex);
}

We could use for_each_cpu_online() instead, but then we should check
is_single_threaded().

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/