On Mon, Aug 19, 2013 at 11:33 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On Mon, 19 Aug 2013, Ming Lei wrote: > >> > As far as I can see, this counter does not need to be exact. Why not >> > simply make it a non-atomic unsigned int? >> >> It may becomes quite inaccurate, and 4.1 of the perfbook mentioned >> that half of counts might be lost with simple non-atomic unsigned int, >> so I think percpu variable is good choice. > > In practice I think that is very unlikely to happen. There would have > to be separate threads running on different CPUs, simultaneously > submitting URBs for the same device and very closely synchronized. Right. > > Also, we don't know how this number gets used. Quite possibly, losing > half of the counts won't matter very much -- maybe the user cares only > about the order of magnitude. Another disadvantage is that accessing the shared variable is still slower than accessing one percpu variable in theory. Thanks, -- Ming Lei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html