Re: [PATCH v2 1/3] interconnect: debugfs: replace writable string helper

Yichong Chen <[email protected]>
Newsgroups dev.linux.lists.driver-core,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm,org.kernel.vger.linux-sound
Message-ID <[email protected]>
On Thu, Aug 06, 2026 at 11:01:07AM +0200, Greg KH wrote:
> On Thu, Aug 06, 2026 at 04:48:52PM +0800, Yichong Chen wrote:
> > +	mutex_lock(&debugfs_lock);
> > +	copy = kstrdup(*node ?: "", GFP_KERNEL);
> > +	mutex_unlock(&debugfs_lock);
> 
> scoped guard?

Yes, scoped guard would be cleaner here.  I can use it in the next version.

> > -	src = kstrdup(src, GFP_ATOMIC);
> > -	dst = kstrdup(dst, GFP_ATOMIC);
> > -	rcu_read_unlock();
> > +	src = kstrdup(src_node, GFP_KERNEL);
> > +	dst = kstrdup(dst_node, GFP_KERNEL);
> 
> Why is GFP_KERNEL now ok, while GFP_ATOMIC wasn't?  Is this the rcu
> stuff interacting somehow?

Yes.  The old code duplicated the strings while still inside the RCU
read-side critical section, so it had to use GFP_ATOMIC.

After this change, src_node and dst_node are protected by debugfs_lock
instead of RCU.  The duplication is done while holding that mutex, so the
allocation can sleep and GFP_KERNEL should be OK.

I will make this clearer in the changelog when sending the next version.

Thanks,
Yichong
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.