From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 465613090CC for ; Tue, 13 Jan 2026 07:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768290890; cv=none; b=BFHSuM+ssoFB9ESodbMqbNdIY9wkMMl5K382w/qhE3Uyq/QlcuOqDLplutR9Z7SSEGv3AfteWplF6HUKiedlTqfh3fWFlyrj2L94d2pAQW6eSH/ljYfQwb0k3oAVsMF2yH3ypD0CjrLg2JD+HNBSaqgxChWuzDROypjEGhw6SbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768290890; c=relaxed/simple; bh=mZhtOo1+tDEsdHcHyA0RNvOfN5E8CYjcRAbnQSix1Cc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ugo8f3nwVGbFrAKhxQln5qMY/ugToPimTUxm+X1lHnXlDlBUqkzhQwj9xsLf5sH5iPX6ZXMSkr02tXstyVdCJfOy2y8oiR1kX4VfB5SwDCT8967rJIJxxcV0Ul/dgMgpszsz3igCkKc7FzNMmND+zzmbeGSPw1xnA/l18Z41f2k= 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=TCmJ7N9B; arc=none smtp.client-ip=192.198.163.9 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="TCmJ7N9B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1768290888; x=1799826888; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=mZhtOo1+tDEsdHcHyA0RNvOfN5E8CYjcRAbnQSix1Cc=; b=TCmJ7N9Bxguczp9LMhnZVV5QgNXABkOYzQQU9VuLA8Bvyf8oJiBsLtPj jpBhiW3kz2Z3bCkyTL/P/IBQwKOPga7XFl6E+0f7SXUSvpJ3jnIQApgAc 4G+SB1BuVokHc19frYwJB4ATqHwx2CjUJIuzF6IVRmkuFrkf87hYepc7m 59fuH5B6J+wGfch/XCK6bJtKcEPrOTm9RXL+SBLlLO4moqrTH9y/cOdBA GuaPURuMTS3UV/Hy7rOAP/AwAx9QIVooIcmfDobTejDtkvCilYJOlHfl+ Ej8CigOh4ch/CaKSk6YRrw4LeRYPw6e82pK90wd8yRaaSrJ3EcSpTvAd3 w==; X-CSE-ConnectionGUID: QFnOHRSzS6i0HQpuQaCU1Q== X-CSE-MsgGUID: ZPUCHzqwS1i1LEldPekOJg== X-IronPort-AV: E=McAfee;i="6800,10657,11669"; a="80291036" X-IronPort-AV: E=Sophos;i="6.21,222,1763452800"; d="scan'208";a="80291036" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2026 23:54:48 -0800 X-CSE-ConnectionGUID: DpTNdnHOSrO605EA8sy0ew== X-CSE-MsgGUID: 3Xs46/SQTB2F7SbzF9wt2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,222,1763452800"; d="scan'208";a="208477284" Received: from unknown (HELO [10.238.1.186]) ([10.238.1.186]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2026 23:54:44 -0800 Message-ID: Date: Tue, 13 Jan 2026 15:54:41 +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] sched/clock: Avoid false sharing for sched_clock_irqtime 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, Shrikanth Hegde , Benjamin Lei , Tim Chen , Tianyou Li References: <20260113030634.3419465-1-wangyang.guo@intel.com> Content-Language: en-US From: "Guo, Wangyang" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/13/2026 12:26 PM, K Prateek Nayak wrote: > Hello Wangyang, > > On 1/13/2026 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. > > nit. > > Since you mention this is a "Read-mostly" data ... > > [..snip..] > >> 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; > > Have you tried annotating it with "__ro_after_init" or "__read_mostly"? > > That should also ensure "sched_clock_irqtime" doesn't have false-sharing > with the nohz struct without using an entire cacheline worth of space. __read_mostly works and avoids wasting spaces. It's better than __cacheline_aligned, patch v2 is sent out as: https://lore.kernel.org/all/20260113074807.3404180-1-wangyang.guo@intel.com/ BR Wangyang