On Mon, 9 Dec 2024 at 14:28, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > Do you have any objections to the diff below? I'd split it up a bit more, and in particular, I think I'd want DNAME_INLINE_LEN to be defined in terms of the long-words, rather than doing it the other way around with that BUILD_BUG_ON(DNAME_INLINE_LEN != sizeof(struct short_name_store)); IOW, I'd *start* with something like the attached, and then build on that.. (By all means turn that unsigned long d_iname_words[DNAME_INLINE_WORDS]; into a struct so that you can then do the struct assignment for it - I just hate the pattern of starting with a byte size and then doing "DNAME_INLINE_LEN / sizeof(unsigned long)". Hmm? Linus
fs/dcache.c | 2 +- include/linux/dcache.h | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index b4d5e9e1e43d..d6a451325133 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -3196,7 +3196,7 @@ static void __init dcache_init(void) */ dentry_cache = KMEM_CACHE_USERCOPY(dentry, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_ACCOUNT, - d_iname); + d_iname_words); /* Hash may have been set up in dcache_init_early */ if (!hashdist) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index bff956f7b2b9..0daaecd53353 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -68,15 +68,17 @@ extern const struct qstr dotdot_name; * large memory footprint increase). */ #ifdef CONFIG_64BIT -# define DNAME_INLINE_LEN 40 /* 192 bytes */ +# define DNAME_INLINE_WORDS 5 /* 192 bytes */ #else # ifdef CONFIG_SMP -# define DNAME_INLINE_LEN 36 /* 128 bytes */ +# define DNAME_INLINE_WORDS 9 /* 128 bytes */ # else -# define DNAME_INLINE_LEN 44 /* 128 bytes */ +# define DNAME_INLINE_WORDS 11 /* 128 bytes */ # endif #endif +#define DNAME_INLINE_LEN (DNAME_INLINE_WORDS*sizeof(unsigned long)) + #define d_lock d_lockref.lock struct dentry { @@ -88,7 +90,10 @@ struct dentry { struct qstr d_name; struct inode *d_inode; /* Where the name belongs to - NULL is * negative */ - unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ + union { /* small names */ + unsigned long d_iname_words[DNAME_INLINE_WORDS]; + DECLARE_FLEX_ARRAY(unsigned char, d_iname); + }; /* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */ /* Ref lookup also touches following */