From nobody Fri Dec 19 20:52:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 D10542F12DD for ; Wed, 3 Dec 2025 23:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764802915; cv=none; b=AmWzQXbFY2sN5heLcp4s9rWoLO7pjURsg464nsA8jjoqA5nJagwpJv9G+UJULof1tTaFgz2GmAr0hHkABofj6ydnfXE2fd4hRRYb7GE+M+4gERnZr5wAJOQw/zTEmxBeWSSE5iNgbAWmM054GBUn6MCdpITYzuKbb1BP7b3L3sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764802915; c=relaxed/simple; bh=heewblv8+VUSifHzkX3W2P+i26TuBbpse5E1oodIHu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xpw0JLbgiphYf3Sab645eHcm9Luo+Mx2FuFXrjcPsXJxnYfglU5zHbY1C3nGcYUTlQht3caQEhhC7tRceDrXIkNZHUg5zn5pvhgic99RbM9RtmxCAUWRJKHEvQHILxmwPExiCxVB0m/pqwl8+stVV67Gqhqd6Lhw1hT41ldDB9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Cxg4oTl4; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Cxg4oTl4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764802913; x=1796338913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=heewblv8+VUSifHzkX3W2P+i26TuBbpse5E1oodIHu8=; b=Cxg4oTl4FXmQXHOKywDD1PXh0TwFbaiKduxzegiGnyiEGbaHQGeStB45 heDXhCr5sdgqIhbxUFp1vM0glTwn0l4/6ZiEL/dgHN9LNlGjaYsII9jc1 2qGZ9JRhqrUWqdc8Jm6fWF0Wuz16A6ncwR05z1/osHOGjbKNCnVNF9Y0l 4FSdn5Pg7wz/0mo5Tfd9kz21TLqYSS8tlCVsn5MnhfbvMVKYOtZOb0WKR 3KiZKcH2I7DsvpgO/euP9zAwOTpRdP8eIGES5K1LCg7I6oiUiavAKbHWR nP3xATAIJENhZb+rdETusA0Fs1MIUcnKK88Vr8NJIw3yCIQUWh4CdT9qz A==; X-CSE-ConnectionGUID: 32GrqILbQRmayJvwXZJ8Bg== X-CSE-MsgGUID: F77VqvbYTl+X7/J43cXgzw== X-IronPort-AV: E=McAfee;i="6800,10657,11631"; a="77136713" X-IronPort-AV: E=Sophos;i="6.20,247,1758610800"; d="scan'208";a="77136713" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2025 15:01:53 -0800 X-CSE-ConnectionGUID: U2qPsSdSRnej2tO9wNUi2g== X-CSE-MsgGUID: YiZKZfnpSMaNZy2O6pI9Xg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,247,1758610800"; d="scan'208";a="199763990" Received: from b04f130c83f2.jf.intel.com ([10.165.154.98]) by fmviesa004.fm.intel.com with ESMTP; 03 Dec 2025 15:01:52 -0800 From: Tim Chen To: Peter Zijlstra , Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot Cc: Chen Yu , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Tim Chen , Aubrey Li , Zhao Liu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , linux-kernel@vger.kernel.org Subject: [PATCH v2 21/23] -- DO NOT APPLY!!! -- sched/cache/stats: Add schedstat for cache aware load balancing Date: Wed, 3 Dec 2025 15:07:40 -0800 Message-Id: <71b94a7547f7843230270e20b84ecb0a540ab604.1764801860.git.tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: 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: Chen Yu Debug patch only. With cache-aware load balancing enabled, statistics related to its activity are exposed via /proc/schedstat and debugfs. For instance, if users want to verify metrics like the number of exceeding RSS and nr_running limits, they can filter the output of /sys/kernel/debug/sched/debug and compute the requ= ired statistics manually: llc_exceed_cap SUM: 6 llc_exceed_nr SUM: 4531 Furthermore, these statistics exposed in /proc/schedstats can be queried ma= nually or via perf sched stats[1] with minor modifications. Link: https://lore.kernel.org/all/20250909114227.58802-1-swapnil.sapkal@amd= .com #1 Signed-off-by: Chen Yu Signed-off-by: Tim Chen --- include/linux/sched/topology.h | 1 + kernel/sched/fair.c | 1 + kernel/sched/stats.c | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 0ba4697d74ba..8702c1e731a0 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -108,6 +108,7 @@ struct sched_domain { unsigned int lb_imbalance_util[CPU_MAX_IDLE_TYPES]; unsigned int lb_imbalance_task[CPU_MAX_IDLE_TYPES]; unsigned int lb_imbalance_misfit[CPU_MAX_IDLE_TYPES]; + unsigned int lb_imbalance_llc[CPU_MAX_IDLE_TYPES]; unsigned int lb_gained[CPU_MAX_IDLE_TYPES]; unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES]; unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES]; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a2e2d6742481..742e455b093e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12684,6 +12684,7 @@ static void update_lb_imbalance_stat(struct lb_env = *env, struct sched_domain *sd __schedstat_add(sd->lb_imbalance_misfit[idle], env->imbalance); break; case migrate_llc_task: + __schedstat_add(sd->lb_imbalance_llc[idle], env->imbalance); break; } } diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c index d1c9429a4ac5..3736f6102261 100644 --- a/kernel/sched/stats.c +++ b/kernel/sched/stats.c @@ -104,7 +104,7 @@ void __update_stats_enqueue_sleeper(struct rq *rq, stru= ct task_struct *p, * Bump this up when changing the output format or the meaning of an exist= ing * format, so that tools can adapt (or abort) */ -#define SCHEDSTAT_VERSION 17 +#define SCHEDSTAT_VERSION 18 =20 static int show_schedstat(struct seq_file *seq, void *v) { @@ -139,7 +139,7 @@ static int show_schedstat(struct seq_file *seq, void *v) seq_printf(seq, "domain%d %s %*pb", dcount++, sd->name, cpumask_pr_args(sched_domain_span(sd))); for (itype =3D 0; itype < CPU_MAX_IDLE_TYPES; itype++) { - seq_printf(seq, " %u %u %u %u %u %u %u %u %u %u %u", + seq_printf(seq, " %u %u %u %u %u %u %u %u %u %u %u %u", sd->lb_count[itype], sd->lb_balanced[itype], sd->lb_failed[itype], @@ -147,6 +147,7 @@ static int show_schedstat(struct seq_file *seq, void *v) sd->lb_imbalance_util[itype], sd->lb_imbalance_task[itype], sd->lb_imbalance_misfit[itype], + sd->lb_imbalance_llc[itype], sd->lb_gained[itype], sd->lb_hot_gained[itype], sd->lb_nobusyq[itype], --=20 2.32.0