mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-15 13:49:36 +02:00
UPSTREAM: mm: optimize CONFIG_PER_VMA_LOCK member placement in vm_area_struct
Currently, we end up wasting some memory in each vm_area_struct. Pahole
states that:
[...]
int vm_lock_seq; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
struct vma_lock * vm_lock; /* 48 8 */
bool detached; /* 56 1 */
/* XXX 7 bytes hole, try to pack */
[...]
Let's reduce the holes and memory wastage by moving the bool:
[...]
bool detached; /* 40 1 */
/* XXX 3 bytes hole, try to pack */
int vm_lock_seq; /* 44 4 */
struct vma_lock * vm_lock; /* 48 8 */
[...]
Effectively shrinking the vm_area_struct with CONFIG_PER_VMA_LOCK by
8 byte.
Likely, we could place "detached" in the lowest bit of vm_lock, but at
least on 64bit that won't really make a difference, so keep it simple.
Link: https://lkml.kernel.org/r/20240327143548.744070-1-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 3b612c8f06
)
Bug: 161210518
Change-Id: Iea2457eefef1b10a4bd2ba925baeb827bb3c0759
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
7789c9e4ab
commit
96532f839a
|
@ -615,6 +615,9 @@ struct vm_area_struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PER_VMA_LOCK
|
#ifdef CONFIG_PER_VMA_LOCK
|
||||||
|
/* Flag to indicate areas detached from the mm->mm_mt tree */
|
||||||
|
bool detached;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can only be written (using WRITE_ONCE()) while holding both:
|
* Can only be written (using WRITE_ONCE()) while holding both:
|
||||||
* - mmap_lock (in write mode)
|
* - mmap_lock (in write mode)
|
||||||
|
@ -631,9 +634,6 @@ struct vm_area_struct {
|
||||||
*/
|
*/
|
||||||
int vm_lock_seq;
|
int vm_lock_seq;
|
||||||
struct vma_lock *vm_lock;
|
struct vma_lock *vm_lock;
|
||||||
|
|
||||||
/* Flag to indicate areas detached from the mm->mm_mt tree */
|
|
||||||
bool detached;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user