lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 17 Feb 2023 09:01:38 +0100
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        kvm@...r.kernel.org
Subject: [PATCH] KVM: Reorder fields in 'struct kvm_mmu_memory_cache'

Group some variables based on their sizes to reduce hole and avoid padding.
On x86_64, this shrinks the size from 40 to 32 bytes.

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Using pahole

Before:
======
struct kvm_mmu_memory_cache {
	int                        nobjs;                /*     0     4 */
	gfp_t                      gfp_zero;             /*     4     4 */
	gfp_t                      gfp_custom;           /*     8     4 */

	/* XXX 4 bytes hole, try to pack */

	struct kmem_cache *        kmem_cache;           /*    16     8 */
	int                        capacity;             /*    24     4 */

	/* XXX 4 bytes hole, try to pack */

	void * *                   objects;              /*    32     8 */

	/* size: 40, cachelines: 1, members: 6 */
	/* sum members: 32, holes: 2, sum holes: 8 */
	/* last cacheline: 40 bytes */
};
---
 include/linux/kvm_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index 2728d49bbdf6..76af8425dbc6 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -94,8 +94,8 @@ struct kvm_mmu_memory_cache {
 	int nobjs;
 	gfp_t gfp_zero;
 	gfp_t gfp_custom;
-	struct kmem_cache *kmem_cache;
 	int capacity;
+	struct kmem_cache *kmem_cache;
 	void **objects;
 };
 #endif
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ