From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Keita Morisaki <keyz@google.com>
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] devres: Fix page faults when tracing devres from unloaded modules
Date: Fri, 27 Sep 2024 19:12:11 +0300 [thread overview]
Message-ID: <ZvbZWzW4I2CYNe3r@smile.fi.intel.com> (raw)
In-Reply-To: <20240927142807.544325-1-keyz@google.com>
On Fri, Sep 27, 2024 at 10:28:07PM +0800, Keita Morisaki wrote:
> The devres ftrace event logs the name of the devres node, which is often a
> function name (e.g., "devm_work_drop") stringified by macros like
> devm_add_action. Currently, ftrace stores this name as a string literal
> address, which can become invalid when the module containing the string is
> unloaded. This results in page faults when ftrace tries to access the name.
>
> This behavior is problematic because the devres ftrace event is designed to
> trace resource management throughout a device driver's lifecycle, including
> during module unload. The event should be available even after the module
> is unloaded to properly diagnose resource issues.
>
> Fix the issue by copying the devres node name into the ftrace ring buffer
> using __assign_str(), instead of storing just the address. This ensures
> that ftrace can always access the name, even if the module is unloaded.
>
> This change increases the memory usage for each of the ftrace entry by
> 12-16 bytes assuming the average devres node name is 20 bytes long,
> depending on the size of const char *.
>
> Note that this change does not affect anything unless all of following
> conditions are met.
> - CONFIG_DEBUG_DEVRES is enabled
> - ftrace tracing is enabled
> - The devres event is enabled in ftrace tracing
LGTM now,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
thanks!
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2024-09-27 16:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-27 14:28 [PATCH v2] devres: Fix page faults when tracing devres from unloaded modules Keita Morisaki
2024-09-27 16:12 ` Andy Shevchenko [this message]
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=ZvbZWzW4I2CYNe3r@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=keyz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/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