From: Greg KH <gregkh@linuxfoundation.org>
To: Zxyan Zhu <zxyan20@163.com>
Cc: broonie@kernel.org, rafael@kernel.org, dakr@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] regmap: debugfs: Fix name collision without atomic operations
Date: Wed, 5 Mar 2025 15:22:20 +0100 [thread overview]
Message-ID: <2025030531-spilt-duchess-0fa5@gregkh> (raw)
In-Reply-To: <20250305133251.44082-1-zxyan20@163.com>
On Wed, Mar 05, 2025 at 09:32:52PM +0800, Zxyan Zhu wrote:
> Thanks for the feedback! I think using atomic_t is a better fit here
> than idr because:
> 1. It's lighter and simpler for our basic indexing needs.
No, idr, and ida (don't remember which is which for this use case, but
one of them is the right one) was explicitly written for this exact type
of functionality.
> 2. No extra resource management is needed. If we use idr, we'd have to
> handle resource cleanup and add locks for debugfs_init/debugfs_exit
> concurrency.
The idr has a lock in it, right? Use that.
> 3. As Mark mentioned, id continuity isn't a hard requirement, so we
> can even skip the atomic_dec on kasprintf failure.
Again, use the data structure designed for this very thing. To ignore
that feels very odd.
Drivers should almost NEVER use atomic values, as there are other apis
to use instead that are correct. If you find yourself using one, always
verify that you really should be doing that.
thanks,
greg k-h
next prev parent reply other threads:[~2025-03-05 14:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 13:32 Zxyan Zhu
2025-03-05 14:22 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-05 13:27 Zxyan Zhu
2025-03-05 14:03 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025030531-spilt-duchess-0fa5@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=zxyan20@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®