- /* FIXME: Do we really need this, why? */
- if (cpu_migrate(cpu)) {
- ERROR("Could not migrate to CPU %d", cpu);
- return -ERR_CPU_MIGRATE;
+ /*
+ * If we need to do multiple read, let's migrate to the CPU
+ * Otherwise, we would lose time calling functions on another CPU
+ *
+ * If we are not yet initialized (cpu_affinity_setsize = 0),
+ * we need to skip this optimisation.
+ */
+ if (multiple_read && cpu_affinity_setsize) {
+ CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set);
+ CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set);
+ if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) {
+ ERROR("Could not migrate to CPU %d", cpu);
+ return -ERR_CPU_MIGRATE;
+ }