[PATCH 01/34] drm: Convert drm_minors_idr to XArray

Matthew Wilcox willy at infradead.org
Fri Feb 22 15:13:25 UTC 2019


On Fri, Feb 22, 2019 at 10:11:14AM +0100, Daniel Vetter wrote:
> On Thu, Feb 21, 2019 at 10:41:21AM -0800, Matthew Wilcox wrote:
> > Divide all the indices by 64 to save memory.
> > 
> > Signed-off-by: Matthew Wilcox <willy at infradead.org>
> 
> Pretty sure this goes boom. Our char device minor allocation scheme is
> 
> device 0: card0=0, renderD0=64
> device 1: card1=1, renderD1=65
> ...
> 
> I think your scheme aliases all devices with the first one.
> 
> And yes the minor(cardX) + 64 == minor(renderDX) is uapi :-)
> 
> If you want to save space we'd need to move the minor allocation from
> drm_minor to drm_device (with a very strange allocation scheme of blocks
> of 64 entries, every 128 entries). That would also solve the issue with
> the current scheme potentially racing if you load multiple drivers at the
> same time (except for drm_global_mutex, but that's more an accident than
> intention). Not sure if worth the bother.
> 
> Or maybe coffee hasn't kicked in yet over here and I'm missing something?

I'm the one who needed moar coffee.  I misread:

> > -	r = idr_alloc(&drm_minors_idr,
> > -		      NULL,
> > -		      64 * type,
> > -		      64 * (type + 1),
> > -		      GFP_NOWAIT);

As (64 * type) + 1.  So I'll redo this patch.



More information about the dri-devel mailing list