From nobody Fri Jun 12 05:53:32 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78ACF3793AC for ; Tue, 21 Apr 2026 07:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776755252; cv=none; b=XVfXoxDfpSfblXTdP8tEYQkGjwOLaf8ra9yv+2VpWW4Ovlzh5MVB6WuCIcXO2mOVhh0PApy+3ydgv6t7tWm35Ouc3QHlLM7F2B75EniiJoQlsPuE2EnVz1GN6T0X+drbrpb4hrfpae6NKxm+onQTnqKiR2HApUWDx5lmOZqrdCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776755252; c=relaxed/simple; bh=fko3S1RoN1pDYdw3hDFHsWZO5eyrPEOltmIMoXP1n6I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OayFcV7mrUSlD8b3dUgh0FYtQq9C5sRfVLzq5NRyPmGyuaWKBcztknFdQ6LKNO5H4odczLwwrCO/0iCZuUnppInedzuKBSjdH4zvXiFBeilzs3ExwnO2ZABtweR5xPYMpSwWP/yOeeG9vUZeoL4SN9HrRNhypMkh930zCOzhHsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: bdd0e47a3d5011f1aa26b74ffac11d73-20260421 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:ff99b6f8-f4f6-4287-8182-3ec1a2aa2db4,IP:0,U RL:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:25 X-CID-META: VersionHash:e7bac3a,CLOUDID:c8f54bb583a3ef4d60c6980985d52a2d,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|898,TC:nil,Content:0|15|50,EDM:5 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: bdd0e47a3d5011f1aa26b74ffac11d73-20260421 X-User: zenghongling@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1981409914; Tue, 21 Apr 2026 15:07:21 +0800 From: Hongling Zeng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, zhongling0719@126.com, zenghongling Subject: [PATCH RESEND v2] sched: adjust the layout of the cfs_bandwith structure to save memory Date: Tue, 21 Apr 2026 15:07:17 +0800 Message-Id: <20260421070717.727890-1-zenghongling@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: zenghongling Using pahole, we can see that there are some padding holes in the current cfs_bandwith structure. Adjusting the layout of cfs_bandwith can reduce these holes, resulting in the size of the structure decreasing to 232 bytes from 240 bytes. This may make period_timer access one more cacheline.but it is already touching so many cachelines and isn't that kind of hot path. Before: struct cfs_bandwidth { raw_spinlock_t lock; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ ktime_t period; /* 8 8 */ u64 quota; /* 16 8 */ u64 runtime; /* 24 8 */ u64 burst; /* 32 8 */ u64 runtime_snap; /* 40 8 */ s64 hierarchical_quota; /* 48 8 */ u8 idle; /* 56 1 */ u8 period_active; /* 57 1 */ u8 slack_started; /* 58 1 */ /* XXX 5 bytes hole, try to pack */ /* --- cacheline 1 boundary (64 bytes) --- */ struct hrtimer period_timer; /* 64 64 */ /* --- cacheline 2 boundary (128 bytes) --- */ struct hrtimer slack_timer; /* 128 64 */ /* --- cacheline 3 boundary (192 bytes) --- */ struct list_head throttled_cfs_rq; /* 192 16 */ int nr_periods; /* 208 4 */ int nr_throttled; /* 212 4 */ int nr_burst; /* 216 4 */ /* XXX 4 bytes hole, try to pack */ u64 throttled_time; /* 224 8 */ u64 burst_time; /* 232 8 */ /* size: 240, cachelines: 4, members: 18 */ /* sum members: 227, holes: 3, sum holes: 13 */ /* paddings: 2, sum paddings: 8 */ /* forced alignments: 2, forced holes: 1, sum forced holes: 5 */ /* last cacheline: 48 bytes */ } After: struct cfs_bandwidth { raw_spinlock_t lock; /* 0 4 */ u8 idle; /* 4 1 */ u8 period_active; /* 5 1 */ u8 slack_started; /* 6 1 */ /* XXX 1 byte hole, try to pack */ ktime_t period; /* 8 8 */ u64 quota; /* 16 8 */ u64 runtime; /* 24 8 */ u64 burst; /* 32 8 */ u64 runtime_snap; /* 40 8 */ s64 hierarchical_quota; /* 48 8 */ struct hrtimer period_timer; /* 56 64 */ /* --- cacheline 1 boundary (64 bytes) was 56 bytes ago --- */ struct hrtimer slack_timer; /* 120 64 */ /* --- cacheline 2 boundary (128 bytes) was 56 bytes ago --- */ struct list_head throttled_cfs_rq; /* 184 16 */ /* --- cacheline 3 boundary (192 bytes) was 8 bytes ago --- */ int nr_periods; /* 200 4 */ int nr_throttled; /* 204 4 */ int nr_burst; /* 208 4 */ /* XXX 4 bytes hole, try to pack */ u64 throttled_time; /* 216 8 */ u64 burst_time; /* 224 8 */ /* size: 232, cachelines: 4, members: 18 */ /* sum members: 227, holes: 2, sum holes: 5 */ /* paddings: 2, sum paddings: 8 */ /* forced alignments: 2 */ /* last cacheline: 40 bytes */ } Reviewed-by: Ben Segall Signed-off-by: zenghongling --- Changes in v2: - fix the commit message. --- --- kernel/sched/sched.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index adfb6e3409d7..55ebd3d868e6 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -444,6 +444,9 @@ static inline u64 default_bw_period_us(void) struct cfs_bandwidth { #ifdef CONFIG_CFS_BANDWIDTH raw_spinlock_t lock; + u8 idle; + u8 period_active; + u8 slack_started; ktime_t period; u64 quota; u64 runtime; @@ -451,9 +454,6 @@ struct cfs_bandwidth { u64 runtime_snap; s64 hierarchical_quota; =20 - u8 idle; - u8 period_active; - u8 slack_started; struct hrtimer period_timer; struct hrtimer slack_timer; struct list_head throttled_cfs_rq; --=20 2.25.1