[openib-general] [PATCH] Convert idr's internal locking to _irqsave variant

Andrew Morton akpm at osdl.org
Thu Jul 13 18:30:47 PDT 2006


On Thu, 13 Jul 2006 18:18:35 -0700
Andrew Morton <akpm at osdl.org> wrote:

> > Having the caller hold a chunk of memory in a stack variable was the
> > trick I came up with to get around that.
> 
> Yes, that certainly works.


Problem is, I think, you'll need to preallocate IDR_FREE_MAX items.  And
then free them all again when none of them were consumed (usual).

Yes, storing the preallocated nodes in the idr itself requires locking. 
But that locking is 100% private to the IDR implementation.  It locks only
the preload list and not the user's stuff.

radix_tree_preload() effectively does this.  Except the preload list is
kernel-wide.  It's split across CPUs and uses
local_irq_disable/preempt_disable locking tricks as a performance
optimisation.  But conceptually it's the same.

Simply copying that would give something which is known to work...  It
seems like a large amount of fuss, but when you think about it the problem
isn't simple.




More information about the general mailing list