From nobody Sat Feb 7 18:20:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 8D4BA18BC3B for ; Tue, 13 Jan 2026 07:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768290669; cv=none; b=flCRItDV7HYzTtkE2WtQUyaU1P8F0f7+9z0rEN9R5/UKir0+FY9JMWixf6XjUBHOC+qsHWMSRByv6DnAx/fChDoRJ0Y8kRCxrgHrsC8mMnJgYnDD9WLuNUmgAqMbFqNs0uhjVtYli+2BkHx2oDQ/kaLraUKgmXxvIS6E6VEW40A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768290669; c=relaxed/simple; bh=r7Myv+OrkonHcwr5YgDaanmByx+widccHOiWdQOeuhU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=smgLyeTZOdCP5CfWCI0Q1dmS60cSKSFB0csjXflh80iG2gnVUky0BAXTDZ8yj9O0mky0i0JpGe0aLEG0Hqt1tlnhqHLwLj2TC0YalZwrpAywJq5x0fakZRw1K4VglyoAkzAPRlA/z0Y9fcO0ZLXnMTiC2AiJwNoEaYwIXKQZQuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=esbsa05X; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="esbsa05X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1768290667; x=1799826667; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=r7Myv+OrkonHcwr5YgDaanmByx+widccHOiWdQOeuhU=; b=esbsa05XISA3Tz+skDgxC8ekFTYG+J50lyhx8qDVKUv+F0uHdImcKzn0 /WSddn6qBYsXc9WHDuWgmeLQ7eKDAnCtBMX+iKR1grnrZalCpDz+u+7ds pXc2EOJhj3hJcw+5NDZVLlng+yZgOrG8fKUO8b1t6XFhAK6UnYu0W2SwY H1+bEXISvETOyOQiINR61yBDR6SD2UX1jk7TpITcB6lSrDgIsyd6r4kQ+ ZstZwi4sPu8JEQjEWNZstPAa2+0pwifqhdy34SNaw1EtPsZwJQk5Phrfr fvvMl2JWtHLE47NFtUrZ2AsuLv4unA6k5IzlYliSb2OILOu6IrFH+Td+Z g==; X-CSE-ConnectionGUID: wCUSzk2vSrW6rEfvhhULlA== X-CSE-MsgGUID: 1lEuU4+IRZGcu2OxMQFPJQ== X-IronPort-AV: E=McAfee;i="6800,10657,11669"; a="80936494" X-IronPort-AV: E=Sophos;i="6.21,222,1763452800"; d="scan'208";a="80936494" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2026 23:51:06 -0800 X-CSE-ConnectionGUID: LaXVEbtsTDCFkxJOfyWe/A== X-CSE-MsgGUID: C46K9v/ITOCo+cdRbWRFow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,222,1763452800"; d="scan'208";a="208826993" Received: from linux-pnp-server-11.sh.intel.com ([10.239.176.178]) by orviesa004.jf.intel.com with ESMTP; 12 Jan 2026 23:51:03 -0800 From: Wangyang Guo To: K Prateek Nayak , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: linux-kernel@vger.kernel.org, Wangyang Guo , Shrikanth Hegde , Benjamin Lei , Tim Chen , Tianyou Li Subject: [PATCH v2] sched/clock: Avoid false sharing for sched_clock_irqtime Date: Tue, 13 Jan 2026 15:48:07 +0800 Message-ID: <20260113074807.3404180-1-wangyang.guo@intel.com> X-Mailer: git-send-email 2.47.3 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" Read-mostly sched_clock_irqtime may share the same cacheline with frequently updated nohz struct. Mark it as __read_mostly to avoid false sharing issue. Details: We observed ~3% cycles hotspots in irqtime_account_irq when running SPECjbb2015 in a 2-sockets system. Most of cycles spent in reading sched_clock_irqtime, which is a read-mostly var. perf c2c (cachelien view) shows it has false sharing with nohz struct: Num RmtHitm LclHitm Offset records Symbol 6.25% 0.00% 0.00% 0x0 4 [k] _nohz_idle_balance.isra.0 18.75% 100.00% 0.00% 0x8 14 [k] nohz_balance_exit_idle 6.25% 0.00% 0.00% 0x8 8 [k] nohz_balance_enter_idle 6.25% 0.00% 0.00% 0xc 8 [k] sched_balance_newidle 6.25% 0.00% 0.00% 0x10 31 [k] nohz_balancer_kick 6.25% 0.00% 0.00% 0x20 16 [k] sched_balance_newidle 37.50% 0.00% 0.00% 0x38 50 [k] irqtime_account_irq 6.25% 0.00% 0.00% 0x38 47 [k] account_process_tick 6.25% 0.00% 0.00% 0x38 12 [k] account_idle_ticks Offsets: * 0x0 -- nohz.idle_cpu_mask (r) * 0x8 -- nohz.nr_cpus (w) * 0x38 -- sched_clock_irqtime (r), not in nohz, but share cacheline The layout in /proc/kallsyms can also confirm that: ffffffff88600d40 b nohz ffffffff88600d68 B arch_needs_tick_broadcast ffffffff88600d6c b __key.264 ffffffff88600d6c b __key.265 ffffffff88600d70 b dl_generation ffffffff88600d78 b sched_clock_irqtime With the patch applied, irqtime_account_irq hotspot disappear. Changes since V1: - Use __read_mostly instead of __cacheline_aligned to avoid wasting spaces. History: v1: https://lore.kernel.org/all/20260113022958.3379650-1-wangyang.guo@int= el.com/ prev discussions: https://lore.kernel.org/all/20251211055612.4071266-1-wa= ngyang.guo@intel.com/T/#u Suggested-by: Shrikanth Hegde Reported-by: Benjamin Lei Reviewed-by: Tim Chen Reviewed-by: Tianyou Li Signed-off-by: Wangyang Guo Reviewed-by: Shrikanth Hegde --- kernel/sched/cputime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 7097de2c8cda..fc8f8081c48f 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -25,7 +25,7 @@ */ DEFINE_PER_CPU(struct irqtime, cpu_irqtime); =20 -int sched_clock_irqtime; +int sched_clock_irqtime __read_mostly; =20 void enable_sched_clock_irqtime(void) { --=20 2.47.3