On Thu, Sep 4, 2008 at 5:54 PM, Krishna Kumar <krikkku@xxxxxxxxx> wrote: > To clarify: Is there a way to do this without looping through all > online cpu's, getting their per cpu variable, compare, etc? Any simple > macro that reverses the variable to say which CPU it is for? > let's discuss. normally per-cpu variable are used when ALL CPU can concurrently access some variables, but to avoid locks implementation, u split the variables up, so they can be independently access. logically each CPU should preferably access its own variable, indexed via its own SMP ID, so that locking is not needed. but when u access another CPU's variable, u will need to lock it, in case it is in the state of modification by another CPU. so here comes the complexity - as u access variable not belonging to your own SMP ID, first lock it, and read the value, compare and unlock it.......with these overhead, it may be more efficient just to have one variable, and apply spinlock per CPU usage. but if u are looking for some data structure that given a value, will always return the CPU ID given a value, it depends on the value range, or whether the mapping is one-to-one, otherwise, if it is many to one, then search algorithm is generally the only way, -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ