On Tue, Mar 11, 2014 at 11:34:21PM +0800, Ming Lei wrote:
> >> In theory, it still might cause percpu_ida_alloc(TASK_RUNNING) failed,
> >> looks it isn't a big deal for the case.
> >>
> >> But I am wondering why cpumask_set_cpu() isn't called with
> >> holding lock inside percpu_ida_free()? Looks 'nr_free == 1'
> >> shouldn't have happened frequently.
> >
> > Because bouncing on the lock is more expensive than occasionally putting
> > a thread into sleep.
> 
> I mean the below block can be put inside the previous lock:
> 
>          if (nr_free == 1)
>              cpumask_set_cpu()
> 
> As I mentioned, 'nr_free == 1' doesn't happen frequently, so
> it won't be big deal, will it?

No. The lock will be taken *each* time in your suggestion, which is bad.

-- 
Regards,
Alexander Gordeev
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to