lkml.org 
[lkml]   [2001]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: optimize DNAME_INLINE_LEN
Andreas Dilger wrote:
>
> You can also do preprocessor macro tricks to get something like an unnamed
> union in a struct, but it is also a bit ugly.
>
I'd prefer that (patch attached, tested with egcs-1.1.2)

Unless I receive complaints, I'll send it to Linus tomorrow, and then
backport to 2.4 after Linus merged it.

--
Manfred--- 2.5/include/linux/dcache.h Thu Oct 11 15:20:18 2001
+++ build-2.5/include/linux/dcache.h Thu Dec 13 23:39:32 2001
@@ -61,25 +61,33 @@
return end_name_hash(hash);
}

-#define DNAME_INLINE_LEN 16
+#define DENTRY_MEMBERS \
+ atomic_t d_count; \
+ unsigned int d_flags; \
+ struct inode * d_inode; /* Where the name belongs to - NULL is negative */ \
+ struct dentry * d_parent; /* parent directory */ \
+ struct list_head d_hash; /* lookup hash list */ \
+ struct list_head d_lru; /* d_count = 0 LRU list */ \
+ struct list_head d_child; /* child of parent list */ \
+ struct list_head d_subdirs; /* our children */ \
+ struct list_head d_alias; /* inode alias list */ \
+ int d_mounted; \
+ struct qstr d_name; \
+ unsigned long d_time; /* used by d_revalidate */ \
+ struct dentry_operations *d_op; \
+ struct super_block * d_sb; /* The root of the dentry tree */ \
+ unsigned long d_vfs_flags; \
+ void * d_fsdata; /* fs-specific data */
+
+struct dentry_nameless {
+ DENTRY_MEMBERS
+};
+/* +15 to guarantee a minimal inline len of 16 bytes */
+#define DNAME_INLINE_LEN \
+ (15 + L1_CACHE_BYTES - (15+sizeof(struct dentry_nameless))%L1_CACHE_BYTES)

struct dentry {
- atomic_t d_count;
- unsigned int d_flags;
- struct inode * d_inode; /* Where the name belongs to - NULL is negative */
- struct dentry * d_parent; /* parent directory */
- struct list_head d_hash; /* lookup hash list */
- struct list_head d_lru; /* d_count = 0 LRU list */
- struct list_head d_child; /* child of parent list */
- struct list_head d_subdirs; /* our children */
- struct list_head d_alias; /* inode alias list */
- int d_mounted;
- struct qstr d_name;
- unsigned long d_time; /* used by d_revalidate */
- struct dentry_operations *d_op;
- struct super_block * d_sb; /* The root of the dentry tree */
- unsigned long d_vfs_flags;
- void * d_fsdata; /* fs-specific data */
+ DENTRY_MEMBERS
unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
};
\
 
 \ /
  Last update: 2005-03-22 13:14    [W:0.077 / U:0.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site