* [PATCH] dcache: don't discard dentry_hashtable or d_hash_shift
@ 2024-08-29 18:20 Stephen Brennan
2024-08-30 0:26 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Brennan @ 2024-08-29 18:20 UTC (permalink / raw)
To: Christian Brauner, Alexander Viro
Cc: linux-kernel, linux-fsdevel, linux-debuggers, Jan Kara,
Stephen Brennan, Linus Torvalds
The runtime constant feature removes all the users of these variables,
allowing the compiler to optimize them away. It's quite difficult to
extract their values from the kernel text, and the memory saved by
removing them is tiny, and it was never the point of this optimization.
Since the dentry_hashtable is a core data structure, it's valuable for
debugging tools to be able to read it easily. For instance, scripts built
on drgn, like the dentrycache script[1], rely on it to be able to perform
diagnostics on the contents of the dcache. Annotate it as used, so the
compiler doesn't discard it.
[1]: https://github.com/oracle-samples/drgn-tools/blob/3afc56146f54d09dfd1f6d3c1b7436eda7e638be/drgn_tools/dentry.py#L325-L355
Fixes: e3c92e81711d ("runtime constants: add x86 architecture support")
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
Hi Christian, Al, Linus,
I know this "fix" may seem a bit silly, but reading out the dentry
hashtable contents from a core dump or live system has been a real life
saver when debugging dentry cache bloat issues. Could we do something
like this (even making it opt-in would be great) for v6.11?
Thanks,
Stephen
fs/dcache.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 3d8daaecb6d1a..69404b4d87546 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -96,11 +96,16 @@ EXPORT_SYMBOL(dotdot_name);
*
* This hash-function tries to avoid losing too many bits of hash
* information, yet avoid using a prime hash-size or similar.
+ *
+ * Marking the variables "used" ensures that the compiler doesn't
+ * optimize them away completely on architectures with runtime
+ * constant infrastructure, this allows debuggers to see their
+ * values. But updating these values has no on those arches.
*/
-static unsigned int d_hash_shift __ro_after_init;
+static unsigned int d_hash_shift __ro_after_init __used;
-static struct hlist_bl_head *dentry_hashtable __ro_after_init;
+static struct hlist_bl_head *dentry_hashtable __ro_after_init __used;
static inline struct hlist_bl_head *d_hash(unsigned long hashlen)
{
--
2.43.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dcache: don't discard dentry_hashtable or d_hash_shift
2024-08-29 18:20 [PATCH] dcache: don't discard dentry_hashtable or d_hash_shift Stephen Brennan
@ 2024-08-30 0:26 ` Linus Torvalds
2024-08-30 16:22 ` Stephen Brennan
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2024-08-30 0:26 UTC (permalink / raw)
To: Stephen Brennan
Cc: Christian Brauner, Alexander Viro, linux-kernel, linux-fsdevel,
linux-debuggers, Jan Kara
On Fri, 30 Aug 2024 at 06:21, Stephen Brennan
<stephen.s.brennan@oracle.com> wrote:
>
> I know this "fix" may seem a bit silly, but reading out the dentry
> hashtable contents from a core dump or live system has been a real life
> saver when debugging dentry cache bloat issues. Could we do something
> like this (even making it opt-in would be great) for v6.11?
Sure, applied with fixes to the comment (you seem to have dropped a word).
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dcache: don't discard dentry_hashtable or d_hash_shift
2024-08-30 0:26 ` Linus Torvalds
@ 2024-08-30 16:22 ` Stephen Brennan
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Brennan @ 2024-08-30 16:22 UTC (permalink / raw)
To: Linus Torvalds
Cc: Christian Brauner, Alexander Viro, linux-kernel, linux-fsdevel,
linux-debuggers, Jan Kara
Linus Torvalds <torvalds@linux-foundation.org> writes:
> Sure, applied with fixes to the comment (you seem to have dropped a word).
Thanks for applying, and for the catch & fixup!
Stephen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-30 16:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 18:20 [PATCH] dcache: don't discard dentry_hashtable or d_hash_shift Stephen Brennan
2024-08-30 0:26 ` Linus Torvalds
2024-08-30 16:22 ` Stephen Brennan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).