From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 2CFC3242D6A for ; Mon, 26 Jan 2026 02:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394513; cv=none; b=NvQna5LW5d3/8GXux9FhQen57giHaUIOe6n3aFXne+cpPyWfp6YplIdwUMBYvvodAVHnwv0p+HpaMTFeQn07Umq0cZFdfZSdm/T2tsu0BAprS1hi+iZ0zy6d5aLYkFQ4PmTtJfTyDIsm9GgbiI+JKfGncGv28cpgeS2lgubJJZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394513; c=relaxed/simple; bh=MQBDX+ybLakEt8WnpS+jHZUJwhZwhx7495ga5zrttBc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KdbJ+6JUD+k8DgZM/wy5hoY2BumGPE2bjIQVtIFNNqwpMJ1yV6AuwduebowriQIUaM3I3AvIqKk1mVLpJwRop6tydOxmERg7H8c4K2y2lTI/LZEx1DFwWfu6Vd6Dno1LbwdoApXKvg6rlgGm+oJ+dc1WwUOod09JmWL2P9DuBOw= 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=HwunQN4V; arc=none smtp.client-ip=192.198.163.15 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="HwunQN4V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769394512; x=1800930512; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=MQBDX+ybLakEt8WnpS+jHZUJwhZwhx7495ga5zrttBc=; b=HwunQN4VHGey9d73sv8fli38kATL+fnUTJr0RJO0q/iTSRTxMupb8Uf+ mRXg1FOnma3cB2IHRSm7bmmdZu+nfyJ07Bqi6umTWDWpLgvTP+Fds5w1i GtMOfTvIdcAf+S5Vi5hShh9r32Zc9ciESZoaRsdDsU/nr4FSLMuHTogu4 F6JMSTtvkwt2Pq2VC1jwUEg51cO7NEuALMqzqZs7ewPu7Y+5vQiCFbydG ncygQBuHN0QA8SkCaL/4EDti6tYgHPU8goVtpBzOK32MtmpiLaSQ2DClt E4Hz+dZq3vpbcsabdjGN4lf3OYZm8KTEiTunFeCD9DodcNft9Xd/j4rXu Q==; X-CSE-ConnectionGUID: Grxv/heQTWSWpBwH6Pferw== X-CSE-MsgGUID: C4T58xYESQiiItqxMgfuIw== X-IronPort-AV: E=McAfee;i="6800,10657,11682"; a="70668440" X-IronPort-AV: E=Sophos;i="6.21,254,1763452800"; d="scan'208";a="70668440" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2026 18:28:31 -0800 X-CSE-ConnectionGUID: wDI6xHjiScClUNx+Iy+//A== X-CSE-MsgGUID: E4f6VehhTIi1KxPKUJbqlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,254,1763452800"; d="scan'208";a="207820788" Received: from unknown (HELO [10.238.1.186]) ([10.238.1.186]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2026 18:28:28 -0800 Message-ID: Date: Mon, 26 Jan 2026 10:28:26 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] sched/clock: Avoid false sharing for sched_clock_irqtime To: Shrikanth Hegde Cc: linux-kernel@vger.kernel.org, Benjamin Lei , Tim Chen , Tianyou Li , K Prateek Nayak , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider References: <20260116023945.1849329-1-wangyang.guo@intel.com> <7277bf6a-eebf-4b76-801a-8d1bab16d911@linux.ibm.com> Content-Language: en-US From: "Guo, Wangyang" In-Reply-To: <7277bf6a-eebf-4b76-801a-8d1bab16d911@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/17/2026 12:58 AM, Shrikanth Hegde wrote: > Hi Wangyang. > > On 1/16/26 8:09 AM, Wangyang Guo wrote: >> Read-mostly sched_clock_irqtime may share the same cacheline with >> frequently updated nohz struct. Make it as static_key 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) > > This is recently removed. > >> * 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. >> > > This changelog likely needs to change with recent removal of nohz.nr_cpus. > Please re-run it once with latest sched/core. > (atleast offsets etc) > > The patch has merit on its own since the variable doesn't update often. Thanks for the reminder, I have add kernel version info in the changelog (v4) to avoid the confusing. BR Wangyang