Re: [RESEND PATCH v7 1/8] kernfs: Introduce interface to access global kernfs_open_file_mutex.

From: Tejun Heo
Date: Wed Apr 06 2022 - 13:18:45 EST


Hello,

On Wed, Apr 06, 2022 at 02:54:44PM +0000, Al Viro wrote:
> On Wed, Apr 06, 2022 at 02:54:19PM +1000, Imran Khan wrote:
>
> > > BTW, speaking of kernfs_notify() - can calls of that come from NMI handlers?
> > > If not, I'd consider using llist for kernfs_notify_list...
> >
> > I see it gets invoked from 3 places only: cgroup_file_notify,
> > sysfs_notify and sysfs_notify_dirent. So kernfs_notify should not be
> > getting invoked in NMI context. I will make the llist transition in next
> > version.
>
> Er... Are you sure neither of those is ever called from something that is
> called from .... from NMI?
>
> It might never happen, but there's a plenty of callchains leading to that
> thing and no obvious obstacles for some of those to come from NMI context;
> I don't see it documented anywhere either.
>
> Tejun, could you comment on that one?

I don't know any case off the top of my head and expectedly all the common
cases don't involved nmi. If we're worried about being called from nmis, I'd
go for just adding WARN_ON_ONCE(in_nmi()).

Thanks.

--
tejun