Am 22.11.2010 22:16, schrieb Andriy Gapon:
If I need to call a function func on a specific CPU which one of the following I
should use?

1.
smp_rendezvous_cpus(1<<  cpuid, ..., func, ...);

2.
sched_bind(cpuid);
func();
sched_unbind();

Or does it depend on some additional factors?
What are the main differences here?

And also by extension.
If I need to execute func() on all CPUs - which one is better again -
smp_rendezvous_cpus() or CPU_FOREACH+sched_bind?

It depends on what you are trying to do in func() really. One huge caveat against smp_rendezvous is that func will be running from interrupt context in an unknown lock state with interrupts disabled.

Most of the time sched_bind() should be sufficient/preferrable. You should think of smp_rendezvous as a basic building block rather than a general purpose API ... unless you really need the rendezvous part and the preemption and all that other stuff ... stay clear of it.

It might make sense to have one of the deferred action APIs (callout/taskqueue/...) provide means to run a task on a specific CPU/all of them ...

I hope this helps.

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

Reply via email to