Skip to contentSkip to conversation

9p: optimize p9_fcall struct

PATCH New Dominique Martinet 2 participants 2 messages Oct 29

Subsystems (2)
lore
Share & tools
lore

Dominique Martinet

author maintainer
#0 lore raw

PATCH 1/1 9p: optimize p9_fcall struct

p9_fcall has a 1 byte hole followed by more data and then a single byte element:

struct p9_fcall {

	u32                        size;                 /*     0     4 */
	u8                         id;                   /*     4     1 */

/* XXX 1 byte hole, try to pack */

u16 tag; /* 6 2 */
size_t offset; /* 8 8 */
size_t capacity; /* 16 8 */
struct kmem_cache * cache; /* 24 8 */
u8 * sdata; /* 32 8 */
bool zc; /* 40 1 */

/* size: 48, cachelines: 1, members: 8 */ /* sum members: 40, holes: 1, sum holes: 1 */ /* padding: 7 */
/* last cacheline: 48 bytes */
};

move zc up to optimize it:

struct p9_fcall {

	u32                        size;                 /*     0     4 */
	u8                         id;                   /*     4     1 */
	bool                       zc;                   /*     5     1 */
	u16                        tag;                  /*     6     2 */
	size_t                     offset;               /*     8     8 */
	size_t                     capacity;             /*    16     8 */
	struct kmem_cache *        cache;                /*    24     8 */
	u8 *                       sdata;                /*    32     8 */
	/* size: 40, cachelines: 1, members: 8 */
	/* last cacheline: 40 bytes */
};

This in turn also makes p9_req_t 16 bytes smaller (152 -> 136) as it contains two of these.

---
 include/net/9p/9p.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/9p/9p.h +1 -1
index 22ab7486795d..067e8a3b38d0 100644
@@ -581,6 +581,7 @@ struct p9_rstatfs {
 struct p9_fcall {
 	u32 size;
 	u8 id;
+	bool zc;
 	u16 tag;
 
 	size_t offset;
@@ -588,7 +589,6 @@ struct p9_fcall {
 
 	struct kmem_cache *cache;
 	u8 *sdata;
-	bool zc;
 };
 
 int p9_errstr2errno(char *errstr, int len);
Signature · 1 line
2.56.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines

p9_fcall has a 1 byte hole followed by more data and then a single byte element:

struct p9_fcall {

	u32                        size;                 /*     0     4 */
	u8                         id;                   /*     4     1 */

/* XXX 1 byte hole, try to pack */

u16 tag; /* 6 2 */
size_t offset; /* 8 8 */
size_t capacity; /* 16 8 */
struct kmem_cache * cache; /* 24 8 */
u8 * sdata; /* 32 8 */
bool zc; /* 40 1 */
[ ... ]

Quoted 4 lines

This in turn also makes p9_req_t 16 bytes smaller (152 -> 136) as it contains two of these.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1