Skip to content

Commit

Permalink
kernfs: Rearrange kernfs_node fields to reduce its size on 64bit
Browse files Browse the repository at this point in the history
Moving .flags and .mode right below .hash makes kernfs_node smaller by 8
bytes on 64bit. To avoid creating a hole from 8 bytes alignment on 32bit
archs, .priv is moved below so that there are two 32bit pointers after the
64bit .id field.

v2: Updated to avoid size increase on 32bit noticed by Geert.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
htejun authored and gregkh committed Jan 30, 2024
1 parent 41bccc9 commit 1c9f2c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/linux/kernfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,22 @@ struct kernfs_node {

const void *ns; /* namespace tag */
unsigned int hash; /* ns + name hash */
unsigned short flags;
umode_t mode;

union {
struct kernfs_elem_dir dir;
struct kernfs_elem_symlink symlink;
struct kernfs_elem_attr attr;
};

void *priv;

/*
* 64bit unique ID. On 64bit ino setups, id is the ino. On 32bit,
* the low 32bits are ino and upper generation.
*/
u64 id;

unsigned short flags;
umode_t mode;
void *priv;
struct kernfs_iattrs *iattr;
};

Expand Down

0 comments on commit 1c9f2c7

Please sign in to comment.