Re: [PATCH 3/8] char: misc: Introduce misc_sync_register()
From: Tzung-Bi Shih
Date: Sat May 09 2026 - 05:41:00 EST
On Fri, May 08, 2026 at 08:54:44AM -0300, Jason Gunthorpe wrote:
> On Fri, May 08, 2026 at 09:38:38AM +0000, Tzung-Bi Shih wrote:
>
> > I see this as the cost for synchronizing file operations with misc driver
> > registration, as previously mentioned in [2], which I believe is necessary
> > to prevent the race conditions. I'm open to discussing potential
> > optimizations or alternative approaches if you have suggestions.
>
> I think the past threads had many different ideas, I don't know why
> you choose to present this with something that is clearly acceptable..
In previous discussions, we explored using `inode->i_cdev`[3], but that
proved infeasible for misc devices[4]. Since all misc drivers share a
single cdev, we cannot use that approach to store per-miscdevice context.
This led us to the current design.
[3] https://lore.kernel.org/all/20251021121536.GG316284@xxxxxxxxxx
[4] https://lore.kernel.org/all/aQ1xfHuyg1y8eJQ_@xxxxxxxxxx
>
> The drivers ops lookup needs to be O(1) on the system call path.
Achieving O(1) lookup is currently infeasible for the misc subsystem.
This is because misc devices use the minor number[5] as a search key to
determine which miscdevice the file operation is tied to, which
inherently involves a linear search.
[5] https://elixir.bootlin.com/linux/v7.0/source/drivers/char/misc.c#L127