lkml.org 
[lkml]   [2021]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: debugfs: was: Re: [PATCH v4] printk: Userspace format enumeration support
Petr Mladek writes:
>> > > + debugfs_remove(ps->file);
>> >
>> > IMHO, we should remove the file before we remove the way how
>> > to read it. This should be done in the opposite order
>> > than in store_printk_fmt_sec().
>>
>> There is a subtle issue with doing this as-is: debugfs_remove(ps->file)
>> cannot be called under printk_fmts_mutex, because we may deadlock due to a
>> pinned debugfs refcnt if debugfs_remove() and _show happen at the same time.
>
>Do we need to call debugfs_remove(ps->file) under printk_fmts_mutex?

Ah, my concern was simultaneous entries into remove_printk_fmt_sec (which would
require setting a separate flag under the mutex), but now I think about it, the
module notifier synchronously waits, so that can't happen anyway.

As such it should be safe to just do:

remove()
{
mutex_lock(&printk_fmts_mutex);
ps = find_printk_fmt_sec();
mutex_unlock(&printk_fmts_mutex);

if (!ps)
return;

/* waits for _show */
debugfs_remove(ps->file);

mutex_lock(&printk_fmts_mutex);
/* Do the data structure teardown */
mutex_unlock(&printk_fmts_mutex);
}

Sounds good to me, I'll do that for v5. Thanks! :-)

\
 
 \ /
  Last update: 2021-02-17 16:51    [W:0.057 / U:6.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site