how to bind CPU with taskqueue thread

View: New views
3 Messages — Rating Filter:   Alert me  

how to bind CPU with taskqueue thread

by Ji-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I use "taskqueue_start_threads(&tq, 1, PI_NET, tq_name)" to create a
thread working for the task queue, and I have multiple CPUs.
Can I bind the thread with a specific CPU so that the thread is only
running on that CPU permanently? Thank you a lot.
I tried sched_bind(FIRST_THREAD_IN_PROC(*tq->tq_pproc), 1) but it does
not work. BTW, the kernel uses ULE scheduler.
Thanks.

Ji

.
_______________________________________________
freebsd-smp@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-smp
To unsubscribe, send any mail to "freebsd-smp-unsubscribe@..."

Re: how to bind CPU with taskqueue thread

by Ray Mihm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

See cpuset(2)

-rm

On Wed, Aug 20, 2008 at 5:09 PM, Ji <lijimlee@...> wrote:

> Hi all,
>
> I use "taskqueue_start_threads(&tq, 1, PI_NET, tq_name)" to create a
> thread working for the task queue, and I have multiple CPUs.
> Can I bind the thread with a specific CPU so that the thread is only
> running on that CPU permanently? Thank you a lot.
> I tried sched_bind(FIRST_THREAD_IN_PROC(*tq->tq_pproc), 1) but it does
> not work. BTW, the kernel uses ULE scheduler.
> Thanks.
>
> Ji
>
> .
> _______________________________________________
> freebsd-smp@... mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-smp
> To unsubscribe, send any mail to "freebsd-smp-unsubscribe@..."
>
_______________________________________________
freebsd-smp@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-smp
To unsubscribe, send any mail to "freebsd-smp-unsubscribe@..."

Re: how to bind CPU with taskqueue thread

by John Baldwin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 20 August 2008 08:09:14 pm Ji wrote:
> Hi all,
>
> I use "taskqueue_start_threads(&tq, 1, PI_NET, tq_name)" to create a
> thread working for the task queue, and I have multiple CPUs.
> Can I bind the thread with a specific CPU so that the thread is only
> running on that CPU permanently? Thank you a lot.
> I tried sched_bind(FIRST_THREAD_IN_PROC(*tq->tq_pproc), 1) but it does
> not work. BTW, the kernel uses ULE scheduler.
> Thanks.

With sched_bind() you can only bind curthread.  What you can do for your case
since you have 1 thread is to queue a task whose function does:

        struct thread *td;

        td = curthread;
        thread_lock(td);
        sched_bind(td, 1);
        thread_unlock(td);

For a queue with multiple threads there isn't a good way to do that currently,
though you might can have a task function that does a bind and then blocks on
a condition variable after bumping up a counter, except that if the counter
hits N, you do a wakeup on the cv instead.  This would ensure that N threads
run the tasks (i.e. no thread runs two of the bind tasks).

--
John Baldwin
_______________________________________________
freebsd-smp@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-smp
To unsubscribe, send any mail to "freebsd-smp-unsubscribe@..."