From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 5D7612F12AB for ; Tue, 13 Jan 2026 04:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768279715; cv=none; b=DqhdhwuIjM+Fd9yhjy7tZWlOQc49pakZ2Wd28OGxPPEE+sfDo0RxyZclAA2/ICUp8qVQWGqpOBn8RpQkgbqEP1OACKaaMpXmlwSI1hxfqGThqSIROpSyjnqzu5LD9UFNO22A/pDJTh5k/6qNt9epFpmUIDdJyjzmcAzIrx/iIpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768279715; c=relaxed/simple; bh=/6/dKk8fxRmMTsH3KpGgUlNeANrbftOpZlmuOuupMQ8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rE8bqNTp0oqR008A9VNQl0yUBmviLf2L0rLxKOofdlKXmlBAYNqaUD0DMRlVqRPxiAN3esNdrudUVp6mnLNIJ6T5ZovCmW6QNa8+q0MGIf8DcH71nOZTB7LSyBnY2sEhxC+BoyKH+ul+/8Un5ACsdWKsUOaE/+lbNBHkudZ7yIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=fpnnTPJf; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="fpnnTPJf" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 60CLsN3Q024688; Tue, 13 Jan 2026 04:48:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=33eq4i kpBMwSFWyUE+KOin/WtTbwGBUfvDiA6WK9FXo=; b=fpnnTPJfFwVOjRHpTeD3zt wQAmDqRAfJyxuMbZXSKIwP+pEZmOQOZuH5aAyf30I3fpc+Q9voWD5DeVglJKqH/0 WETiXJg4yTBWHsYLe7ACJuBGPqfZNr+vprDtjW5CJzLjzSpYpSebLZzkVoVYd4Xl bvM51ZG1CX2bPJ+sSJ1VRvfpzgMh2PpjRsiWIs6h2ScgtkMKKYppImsxupYWUG9U zX+gkU/hCbQH0Y9GQ3zhSbDefQRfnDCIZZpB/AilpNAWNCq2D7Ax8lpxE7sjV1pr u+4FEc/p53Ggzma6aVlhMFCS22KCpltHeS2nDvAZlZcMKJCsat1AWe2aD4rVYytQ == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4bkeeptptd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 04:48:18 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 60D4j7Up022365; Tue, 13 Jan 2026 04:48:17 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4bkeeptptc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 04:48:17 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 60D3BqC8031299; Tue, 13 Jan 2026 04:48:16 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4bm3t1hw1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 04:48:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 60D4mFE827918826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jan 2026 04:48:15 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D2F820043; Tue, 13 Jan 2026 04:48:15 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B4DB20040; Tue, 13 Jan 2026 04:48:12 +0000 (GMT) Received: from [9.124.220.174] (unknown [9.124.220.174]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Jan 2026 04:48:11 +0000 (GMT) Message-ID: <4eb66482-b1ec-48ad-9d14-0bbd1dd50dbc@linux.ibm.com> Date: Tue, 13 Jan 2026 10:18:11 +0530 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] sched/clock: Avoid false sharing for sched_clock_irqtime To: Wangyang Guo Cc: linux-kernel@vger.kernel.org, Benjamin Lei , Tim Chen , Tianyou Li , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider References: <20260113030634.3419465-1-wangyang.guo@intel.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260113030634.3419465-1-wangyang.guo@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=DI6CIiNb c=1 sm=1 tr=0 ts=6965ce92 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=QyXUC8HyAAAA:8 a=VnNF1IyMAAAA:8 a=3XoYeNF2x3M5Qf99c0oA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: y8ydOCntSiNEliljqxJA6PF_D0gYtm1D X-Proofpoint-ORIG-GUID: EinNFnM_FAF55O9qLzIRT4I4JYeHVEdk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDAzNyBTYWx0ZWRfXyJrSo2dSYKBT /HNOF8EKsSbsX7itxcr7cT1jPwm5XEDu0QvtoATFf7N64RY1GRqhzt/6fzk6xlnzlX8vro7kJUy RMQ3LSA+uxyQPNqi3Zj7gD8xUABv/z8SeF6FiqFlLoINiqUJDuxO0Jwc6g+7zkdLfhh8Uv2Gb3n SqthjzTcQIwm+rvsbs5PLC0m9HT65UfmisDLv44CLvXNawj1IpN7bT3Dn4E/pDazDyulnCeCUnO DrMj6wqaUvuwK4oE+igdWjjKHx7UXsstnfNrnxpMFsV8W3hdNYuNNuiaojkbaSivdhICQuujaMM XQHDtQokevzSKYg83u5unvkEBwYpkMG6BjvmpszSMnT8QigwASfg8zKL0vvHEZTJ1Luy6HCn6TY z2waB8KMRBH+aB+KAtXbHVN8DNsz2rmILNtMDghCR4k06UEMaNIxMMKk94qFHde4bPoPxT4W6Y8 Ob13xLXbV2q3G7Hwi8g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-12_07,2026-01-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2512120000 definitions=main-2601130037 Hi Wangyang. On 1/13/26 8:36 AM, Wangyang Guo wrote: > Read-mostly sched_clock_irqtime may share the same cacheline with > frequently updated nohz struct. Make it as cache aligned 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. > > Previous Discussion: > https://lore.kernel.org/all/20251211055612.4071266-1-wangyang.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 > --- > 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..34d15972f5fb 100644 > --- a/kernel/sched/cputime.c > +++ b/kernel/sched/cputime.c > @@ -25,7 +25,7 @@ > */ > DEFINE_PER_CPU(struct irqtime, cpu_irqtime); > > -int sched_clock_irqtime; > +int sched_clock_irqtime __cacheline_aligned; > > void enable_sched_clock_irqtime(void) > { Could you please apply this and see if you observe the issue still. https://lore.kernel.org/all/20260112050442.138446-1-sshegde@linux.ibm.com/ You have CONFIG_CPUMASK_OFFSTACK=y. You still might see occasional cache misses with the patch applied, but it would be quite less.