Realign struct rt_bandwidth to reduce its size by 8 bytes. Total size
is now 88 bytes and remove holes,rt_runtime_lock and rt_period_activeare
frequently accessed together,Placing them in the same cache line can
improve access efficiency.
pahole output before:
struct rt_bandwidth {
raw_spinlock_t rt_runtime_lock; /* 0 4 */
/* XXX 4 bytes hole, try to pack */
ktime_t rt_period; /* 8 8 */
u64 rt_runtime; /* 16 8 */
struct hrtimer rt_period_timer; /* 24 64 */
/* --- cacheline 1 boundary (64 bytes) was 24 bytes ago --- */
unsigned int rt_period_active; /* 88 4 */
/* size: 96, cachelines: 2, members: 5 */
/* sum members: 88, holes: 1, sum holes: 4 */
/* last cacheline: 32 bytes */
}
after:
struct rt_bandwidth {
raw_spinlock_t rt_runtime_lock; /* 0 4 */
unsigned int rt_period_active; /* 4 4 */
u64 rt_runtime; /* 8 8 */
ktime_t rt_period; /* 16 8 */
struct hrtimer rt_period_timer; /* 24 64 */
/* size: 88, cachelines: 2, members: 5 */
/* last cacheline: 24 bytes */
}
Signed-off-by: zenghongling <zenghongling@kylinos.cn>
---
kernel/sched/sched.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index f2773e91438a..a7c49f54e063 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -313,10 +313,10 @@ struct rt_prio_array {
struct rt_bandwidth {
/* nests inside the rq lock: */
raw_spinlock_t rt_runtime_lock;
+ unsigned int rt_period_active;
ktime_t rt_period;
u64 rt_runtime;
struct hrtimer rt_period_timer;
- unsigned int rt_period_active;
};
static inline int dl_bandwidth_enabled(void)
--
2.25.1