xen/gnttab: Shrink struct gnttab_copy_buf
PATCH 1/1 xen/gnttab: Shrink struct gnttab_copy_buf
Move the booleans into earlier padding. No functional change.
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
On 64bit, this shrinks from 64 bytes to 56 bytes.
On arm32, it's 40 bytes before and after. Given that we can't reuse the tail-padding from struct gnttab_copy_ptr, I'm not sure there's an obvious improvement to be had:
xen.git/xen$ pahole xen-syms-arm32-after -E -C gnttab_copy_buf
struct gnttab_copy_buf {
struct gnttab_copy_ptr {
union {
/* typedef grant_ref_t -> uint32_t */ unsigned int ref; /* 0 4 */
/* typedef xen_pfn_t -> uint64_t */ long long unsigned int gmfn; /* 0 8 */
} u; /* 0 8 */
/* typedef domid_t -> uint16_t */ short unsigned int domid; /* 8 2 */
/* typedef uint16_t */ short unsigned int offset; /* 10 2 */
}ptr; /* 0 16 */ /* XXX last struct has 4 bytes of padding */
/* typedef uint16_t */ short unsigned int len; /* 16 2 */
_Bool read_only; /* 18 1 */
_Bool have_grant; /* 19 1 */
_Bool have_type; /* 20 1 */
/* XXX 3 bytes hole, try to pack */
struct domain * domain; /* 24 4 */
/* typedef mfn_t */ struct {
long unsigned int mfn; /* 28 4 */
} mfn; /* 28 4 */
struct page_info * page; /* 32 4 */
void * virt; /* 36 4 */
/* size: 40, cachelines: 1, members: 9 */
/* sum members: 37, holes: 1, sum holes: 3 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 40 bytes */
};
---
xen/common/grant_table.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)xen/common/grant_table.c +4 -3
@@ -2927,13 +2927,14 @@ struct gnttab_copy_buf {uint16_t len;/* Mapped etc. */ +bool read_only; +bool have_grant; +bool have_type; +struct domain *domain;mfn_t mfn;struct page_info *page;void *virt; -bool read_only; -bool have_grant; -bool have_type; };static int gnttab_copy_lock_domain (domid_t domid,struct gnttab_copy_buf *buf)
base-commit: 2043d22b7e926f508cc23391b4c75325fa7211e9
Signature · 1 line
2.39.5
Quoted 3 lines · Andrew Cooper
Move the booleans into earlier padding. No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 15 lines
On arm32, it's 40 bytes before and after. Given that we can't reuse the tail-padding from struct
gnttab_copy_ptr, I'm not sure there's an obvious improvement to be had:xen.git/xen$ pahole xen-syms-arm32-after -E -C gnttab_copy_buf struct gnttab_copy_buf { struct gnttab_copy_ptr { union { /* typedef grant_ref_t -> uint32_t */ unsigned int ref; /* 0 4 */ /* typedef xen_pfn_t -> uint64_t */ long long unsigned int gmfn; /* 0 8 */ } u; /* 0 8 */ /* typedef domid_t -> uint16_t */ short unsigned int domid; /* 8 2 */ /* typedef uint16_t */ short unsigned int offset; /* 10 2 */ }ptr; /* 0 16 */
Quoted 6 lines
/* XXX last struct has 4 bytes of padding */
/* typedef
uint16_t*/ short unsigned int len; /* 16 2 */
_Boolread_only; /* 18 1 */
_Boolhave_grant; /* 19 1 */
_Boolhave_type; /* 20 1 */
Making these bitfields would help Arm32.
Jan
PS: Can we also get the other pending gnttab change sorted? As said, feel free to post your patch, and I'll ack it. Alternatively an ack on my variant would be nice.