Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dcache: keep dentry_hashtable or d_hash_shift even when not used

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.

Link: https://github.com/oracle-samples/drgn-tools/blob/3afc56146f54d09dfd1f6d3c1b7436eda7e638be/drgn_tools/dentry.py#L325-L355 [1]
Fixes: e3c92e81711d ("runtime constants: add x86 architecture support")
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Stephen Brennan and committed by
Linus Torvalds
04c8abae 3b9dfd9e

+7 -2
+7 -2
fs/dcache.c
··· 96 96 * 97 97 * This hash-function tries to avoid losing too many bits of hash 98 98 * information, yet avoid using a prime hash-size or similar. 99 + * 100 + * Marking the variables "used" ensures that the compiler doesn't 101 + * optimize them away completely on architectures with runtime 102 + * constant infrastructure, this allows debuggers to see their 103 + * values. But updating these values has no effect on those arches. 99 104 */ 100 105 101 - static unsigned int d_hash_shift __ro_after_init; 106 + static unsigned int d_hash_shift __ro_after_init __used; 102 107 103 - static struct hlist_bl_head *dentry_hashtable __ro_after_init; 108 + static struct hlist_bl_head *dentry_hashtable __ro_after_init __used; 104 109 105 110 static inline struct hlist_bl_head *d_hash(unsigned long hashlen) 106 111 {