From nobody Sun Feb 8 09:22:49 2026 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2063.outbound.protection.outlook.com [40.107.236.63]) (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 3D4FF17C9F1; Fri, 20 Dec 2024 06:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676417; cv=fail; b=QNaLqBi9B2QWmOXUVO8mSims/I4usxsWJPrcpUSAebsWtXzLJcHU29/gItgdAyCtLw01p7/z73l+NM+UQFDCJEHRLlVNFrJ2nY40NWnkR5rWf/F9/67xOJyv8hBmWUFSy97foLEXEm0F3eAg4SZYNXgtVdO/QMLqoPSPtIZqdUI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676417; c=relaxed/simple; bh=9daBPYkeQ3TrSUSd0AVbSj+LLkWO8+Pcrz9b3TtyAWk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XriCs1w4ZlFwHe6V5uLsh9DmNYAx3IjL/olUL4HkEfooYv9TriVEwzKa6J2G3RZg+DlnWTEjqiRTkSUk/jjyZOx76M5a7Uf0ueBRGcIkeoc8GGZAeGKQgI2+oykBe8cS2CHyvUFpJowA78l3Gsn8rUcJ43b8iJS1hpUYhsV2l1k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2nLkrw6/; arc=fail smtp.client-ip=40.107.236.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2nLkrw6/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZFN5qoidNjS5Vz6MhjOve2TeuHjGyYuO/YkX8BhMQYoWzrlfZ8LXwNMZdabr4e+MYocmXXPa6qsOMhcbTp71XVchRf8R6qMwHeYN1TQNCer1Y0yYCD+n1o9/tUVVBbKF+Hqfrca2Yr8uaK9THJe2hIe5S+8mAjc//fPz1tKTvHVabWczsg7j8yQ5jdAQgjIkTMQcx+hMO4SLm/33WY92nuMt5xLClnGJM3jvSaTBB/pEu03a5yj4pVv/a2cSaME0crRvo6gGENUs//TiB6w16xxz14/qnvtH5J+1L/4wUvxWsWTIJq+5wDazfE+VYWYM81QpWg9Xzed9d+fChCyqlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vsoL+DZ+qfzpg+7EK/iXOfYqC1dudSac2cOLJeyUccc=; b=Nm61fZXmKEjhsfsiCw4YqICJEd/XVULS8UESDE8rm9yOipk8Nil1Ju1i1Nb65pVA2VggMtlQW7DvPEX9sGxk5yHuHnZb0WEtBiyTJ6aFVraKYBuhTx8apeTMi8MO8I+XTgWuX5L8QV/7L3vkQJv9k0chAKg35IkRmIaZBFWHGykITZafd64JGnf7Mkd8be/+PvLH8rftnan6XQity1ED6EOwiIjRMzAtf+GckzRJ7YNl6/pe2eFRPDiTvXsYAXH6P7ogjkZkpWQu6Da2fUKDLmJan7Z2qVBDmeaAi3sQvJ6ACAI0sUSWzZWgbIpaTayEMjGqsWlzvywrZx/oHfDWqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vsoL+DZ+qfzpg+7EK/iXOfYqC1dudSac2cOLJeyUccc=; b=2nLkrw6/F6w60tID9+rUVzOlr9ccUqWr4nNNxkti+dvyjdYxMp+j+Kk0eG7wAAwwd+Wdxu/9ySQGngLbPjLa7un63zm1nj9n1db/+7zfKvfNhPV3TD8uXbEgLw44soXzAA/cpCGBqvr/3sHLcHyvdfPUJjS9K0qxqLTi7iLUEp8= Received: from BY1P220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::14) by PH7PR12MB5808.namprd12.prod.outlook.com (2603:10b6:510:1d4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 06:33:32 +0000 Received: from SJ1PEPF00001CEA.namprd03.prod.outlook.com (2603:10b6:a03:59d:cafe::a0) by BY1P220CA0001.outlook.office365.com (2603:10b6:a03:59d::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.17 via Frontend Transport; Fri, 20 Dec 2024 06:33:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CEA.mail.protection.outlook.com (10.167.242.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:33:32 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:33:25 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 1/6] sched/fair: Fix value reported by hot tasks pulled in /proc/schedstat Date: Fri, 20 Dec 2024 06:32:19 +0000 Message-ID: <20241220063224.17767-2-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CEA:EE_|PH7PR12MB5808:EE_ X-MS-Office365-Filtering-Correlation-Id: 7789d226-9ce9-4e73-6cec-08dd20c03934 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|7416014|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?00umrY3y0T97pxzSneP9yFYorNEKx4+w72Xs8mB9Fuwq4vZ77ukViQVXeVq5?= =?us-ascii?Q?qT++BTSUP5Ykbg6tpxJOHbldFZFpJX8cWHpYDgpriNk5FN3NKleIFrSrO2Bb?= =?us-ascii?Q?erCOUpWnOzg4Cg+Z41ifrpi5PJafuj5QWNEm4nliIDFXL7KopzaFbLAAfPHc?= =?us-ascii?Q?g7rb5KOteK2ysyRs4iH6g/ej/uesVN2w15kldUds373JUPK2sGr9956srKb9?= =?us-ascii?Q?80AdaCsxpDdwyTc/CMV5Ji8KJS1FUhXarm8d8Px8sH/FUe+a43UUil3cqsFh?= =?us-ascii?Q?YAbpRadhC9qReFXaKCaWApW5mbR/ynd2p5uFjbkFZ94ohwhF2iVnSWby+MHx?= =?us-ascii?Q?sJBSnPIZCYVn9vCxy7i9IiMG3I8oCUGLs6OIswLqJi6TnTGBUA/+qqLB8Bj8?= =?us-ascii?Q?E0qemRBhuuZdEkoKDHmKUQGzqiyPVBa41ytXWtkkA2uDN1xAvOQPahfDXNsV?= =?us-ascii?Q?2BgIem+InkNWw+OX9D2gLicBbelvrU7UzAUpWJONfqpvjXrEGEb2fzt6Kj3t?= =?us-ascii?Q?BLRumAARAdxE8CUq0TquIYh6jKlsPd30wPJ4vcsIlPyr9Twb9QIPYAa42C9T?= =?us-ascii?Q?PhVcP4LpltCBBdi5zs1YhfWf5sxC23TZVmsh8mpGfsy5qlRwfjzmK7i6Qawx?= =?us-ascii?Q?dvI79q4PnJKfSTQWa8ce3vBHCz2hkmUU59N5X+WYj49iIQ/Xgynxgpy9CreQ?= =?us-ascii?Q?58i0HcxPaLbso6xyrsmAU0XcI2X5Xjh0xht78ZNMDkqIOAVzDKsSJH44gYAg?= =?us-ascii?Q?GW8v1FmJAsoJi/CE5d4YePdkYNS2XvjCsCE4r7fzuJNyCynXxtfyTRdyB3c8?= =?us-ascii?Q?Pzk/xlrZxTbYT7nTnvwm4nSB43Ja4Arq4ESqBhG1kzxGfQzi56a0tFayU0UR?= =?us-ascii?Q?zlEbGtpapc2GbavUc68bH4IUxABMmM89Ivo1cxFuUQGLDBvKNl1sQ1sgyn9H?= =?us-ascii?Q?VzRDeSvqA+sLq+AsgYBjl9Sc/80h7YYfifepg5PoyLuhFZPBAXHSonOVhBoL?= =?us-ascii?Q?GvmdjLsqxbnhBV5eGGi2AbGoDveNW9ob94nfLxKH/U6HlJBD1/PoCs/9meT0?= =?us-ascii?Q?Zf1gqIlwxXWS78xx5L6H/IomGyrEwUcbBRUqPhOMWY26V0BsEHTmnW2uf9uf?= =?us-ascii?Q?Ii3mLw0bI7lpHKaYHCVeQJqvzI3W3zWEO8+pVZcP/sG2hpeLHx9QVhhdnoQ8?= =?us-ascii?Q?PPc2PvGaL0ulSZzzGA1yWLBkbC5Jp5rArmicRrYh3EjwfPQjSV4guqpH2ymD?= =?us-ascii?Q?iFOnZpT0SGFyLKhpoh5iOwuLwFOxmIZKCxjfE6x2W3FVYbq+rs0R8JrkAVPe?= =?us-ascii?Q?950yIr0Ssu+u6Vjgeu1R5RE+sbpSjn28xVZnoG1jUDL9nbKSW6p8j5/1sqyw?= =?us-ascii?Q?Tao1Fps8JOtSEkaxEqiPlJOtRAVhwyuWjgdF2SXHfmuodbHvEV3sJH2fXn+y?= =?us-ascii?Q?emrHsN9WYTEyu15TowKHDG/tXBWRVszidqP29kcOjKft+4sTBa5mGLf9sLnZ?= =?us-ascii?Q?sZDljvRkFhnTZKY=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(7416014)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:33:32.0618 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7789d226-9ce9-4e73-6cec-08dd20c03934 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CEA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5808 Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra In /proc/schedstat, lb_hot_gained reports the number hot tasks pulled during load balance. This value is incremented in can_migrate_task() if the task is migratable and hot. After incrementing the value, load balancer can still decide not to migrate this task leading to wrong accounting. Fix this by incrementing stats when hot tasks are detached. This issue only exists in detach_tasks() where we can decide to not migrate hot task even if it is migratable. However, in detach_one_task(), we migrate it unconditionally. Link: https://lore.kernel.org/all/20230619092228.GK4253@hirez.programming.k= icks-ass.net/ [Swapnil: Handled the case where nr_failed_migrations_hot was not accounted= properly and wrote commit log] Fixes: d31980846f96 ("sched: Move up affinity check to mitigate useless red= oing overhead") Reported-by: Gautham R. Shenoy Not-yet-signed-off-by: Peter Zijlstra Signed-off-by: Swapnil Sapkal --- include/linux/sched.h | 1 + kernel/sched/fair.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index b5916be49f62..8c6a2ed9f80e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -937,6 +937,7 @@ struct task_struct { unsigned sched_reset_on_fork:1; unsigned sched_contributes_to_load:1; unsigned sched_migrated:1; + unsigned sched_task_hot:1; =20 /* Force alignment to the next boundary: */ unsigned :0; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2c4ebfc82917..e66b10da7ac5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9390,6 +9390,8 @@ int can_migrate_task(struct task_struct *p, struct lb= _env *env) int tsk_cache_hot; =20 lockdep_assert_rq_held(env->src_rq); + if (p->sched_task_hot) + p->sched_task_hot =3D 0; =20 /* * We do not migrate tasks that are: @@ -9466,10 +9468,8 @@ int can_migrate_task(struct task_struct *p, struct l= b_env *env) =20 if (tsk_cache_hot <=3D 0 || env->sd->nr_balance_failed > env->sd->cache_nice_tries) { - if (tsk_cache_hot =3D=3D 1) { - schedstat_inc(env->sd->lb_hot_gained[env->idle]); - schedstat_inc(p->stats.nr_forced_migrations); - } + if (tsk_cache_hot =3D=3D 1) + p->sched_task_hot =3D 1; return 1; } =20 @@ -9484,6 +9484,12 @@ static void detach_task(struct task_struct *p, struc= t lb_env *env) { lockdep_assert_rq_held(env->src_rq); =20 + if (p->sched_task_hot) { + p->sched_task_hot =3D 0; + schedstat_inc(env->sd->lb_hot_gained[env->idle]); + schedstat_inc(p->stats.nr_forced_migrations); + } + deactivate_task(env->src_rq, p, DEQUEUE_NOCLOCK); set_task_cpu(p, env->dst_cpu); } @@ -9644,6 +9650,9 @@ static int detach_tasks(struct lb_env *env) =20 continue; next: + if (p->sched_task_hot) + schedstat_inc(p->stats.nr_failed_migrations_hot); + list_move(&p->se.group_node, tasks); } =20 --=20 2.43.0 From nobody Sun Feb 8 09:22:49 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) (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 7F10A17B50A; Fri, 20 Dec 2024 06:34:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676447; cv=fail; b=p7edUnm4T+YLPCsHrvWbWb+nQlmB3XrqJ5/SfCW3hW3RgjOUfIcIZ93Nw+c0Vk5B75IdhEwCfOXCbb5jDtzPjc3VVGkgF3lvmZ9sz7o/mFS1NNZE2AYpp6AtZLklNY+X6yLFRvGOncxkSRby8GMZkfox8Y3by1yD9B7+yRgthWE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676447; c=relaxed/simple; bh=KOTpUXDEOVWUKodQYHLEnpD+DByWLZhmed66VmrTYY4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EdCWNObG6ODkaEtrtjlsOVyt5ejCXc4vbwgcKlatj1mD7p7sUzHJrhgk01IxIstFv4my0sRg6Jc3XbAHElX/20vf6nzP3EmO4jTWrbY5GVyFGsGO2zM5OeZYhlPxEBmktMJqEAqsF1tJNyyq12bgbfoCoOckgDyg81fH/H/LyXw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=xcCyoY3J; arc=fail smtp.client-ip=40.107.223.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="xcCyoY3J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FZgc+6BIp5MTKWAaEHvuxQCuBD3mqzyUHAK+Rfm8dVBYuer6V2tJcR1p5GlKRHUmAzNDaqCC8pZB1h8WxpdyVRuCOX3hzwxnJ4wugNfEWyjvM/0eIZtV9+KUwZjpAKU+IwqUWWavup2liPBuoTkDgcYD8QlgpjWEcc4MydmxincUS21w0Fl8wtfAYL5Eta463/c6Lh+tL5ucBAAhE7Dj6gJPcwSd9dtEiSPU4qbx85B+UB1mzU6RpHSFw9hyKZZ9deubUkIixWXuoYi5tWcJkNzwC4/7iwcCSd0GUZ71vjyktZnzl27045J8YMpTdbCpYgVuOsaU3A3sLahs4ReUBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=opEvCtK6ycrjSwNX7TPg2f36SVCSU2W7KkI1hU+2p6o=; b=gzA0UQM2t3WNd/1bToddqoaj9Bb5K5dZFanJfUI/pOkYqcKZDT2SUQ8OnAA5zjSzyFlud/D+ojdHmMk+xX/zdIDth3V2gNym5OaiW9osiVPovZkqYK54lxvV7Mz7cAZmSBwmYLXEqyKTzvfxitJFUknHRPwDgmRCp/bIBxesK7CfVP4qImvkL5xAaDXnkaTnZp/i3LjY6xbVoZxV4k9jOMTRRdHPM33CI/YHgH3ySuhqV3jp5dppD5xj894SYYEt8V1REqLOohI7XaIQPrAyrAGdxgFdII7ePd2C4cb+sMQUDbvult7GRmazFOvfcUA4cY1SV2oK5jbbIOyNjUJuCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=opEvCtK6ycrjSwNX7TPg2f36SVCSU2W7KkI1hU+2p6o=; b=xcCyoY3JTGBXZ3YY22jibidzscgqag0xJrV8NRtrkOH9PFVJDqQnBEby45Th8VeLFdJcv3HT/HvH65RxluPlwseKCOfr03WDEfpAwvHcpIu3PRnjRMy7NFbdEZCVouv0yUyBb55hEOfC70t34f0goKY6nOoAE1EWcTnstCabHrc= Received: from MW4P223CA0026.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::31) by PH8PR12MB7374.namprd12.prod.outlook.com (2603:10b6:510:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 06:33:56 +0000 Received: from SJ1PEPF00001CE8.namprd03.prod.outlook.com (2603:10b6:303:80:cafe::85) by MW4P223CA0026.outlook.office365.com (2603:10b6:303:80::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 06:33:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE8.mail.protection.outlook.com (10.167.242.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:33:55 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:33:50 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 2/6] sched/fair: Cleanup in migrate_degrades_locality() to improve readability Date: Fri, 20 Dec 2024 06:32:20 +0000 Message-ID: <20241220063224.17767-3-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE8:EE_|PH8PR12MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: c6b94eee-bbac-45de-a11c-08dd20c0475b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3leTKRoWLQ18Yxw5sE2kh2q6HqDN20dhJfW/cnk/uc1t0M8BUIbBERhSlA0l?= =?us-ascii?Q?vF6K77OHRBQRy/jKIyn8fWMggmyv3EJsb5uw6gziVYVLYMsVaIdItZelW/4a?= =?us-ascii?Q?ptAxCiGiThsQrZE8XWgjDeXhS6QpMcPVKdYPQwtna1BcSxiOZQHDsBOvT81W?= =?us-ascii?Q?CtZzy1dJH30DDu4xputdJxXazcSJ793LC/FLo+UcZ080fcte3pNm3HMInxJU?= =?us-ascii?Q?mSJWsYa+Wh4J1xZAJOycc3BB+7mBq3VyayYzI4toJKAlXvjH+kXVxbe12yI4?= =?us-ascii?Q?wZRtdTKlGxoro455GdKq0TToPjgb8euY3Qc6ErzG569q/vacEunVen9rKI9e?= =?us-ascii?Q?BD1lMEovleLnrIFFl9nJ7fDdd1vrry/8S3bD5M92SOz+GGn71tQsoxpBRoPH?= =?us-ascii?Q?rJO+EXrFI+Xibbu5jpeO7U6nFHEe4GcEC3XHQHlr/LsrjtSJ/CJIh1ds89Ce?= =?us-ascii?Q?jVZsHZQxzyFcJKdsGNxj0Bdq7w6kT6uLSzGQy4z58GojKtcb6zF0QSWZgXD+?= =?us-ascii?Q?0M/2K8ZV+4flnZ7DH7e/m0wVTaSp4+poDYXulw6FfJHn7vUUZ72xmljxns2R?= =?us-ascii?Q?INd0gNIYTbTwB+mOJz6qqWDR01UUUjxii2t8338ecva2n3z10WAPXC0FP/HG?= =?us-ascii?Q?XCJ/PLGbEgClIVhWhFUzkkMIRvf4m1kp4YA+qtOttBc/ELIW1Z1t1hiJshMC?= =?us-ascii?Q?LetjhxqLe/m/i8lTUIMyrFd6CEYdPhovPmLVDa0EaYwdrzf72NiMBY813uxr?= =?us-ascii?Q?lWdj73t4in7LZh4LFSKBey77rIceebhtQytyx3My9SUZJELWI0IX06WNOoUJ?= =?us-ascii?Q?DaK+gS4v+HETJ1DCOncY4W38zdxzNPVMkWRQbbEi5fsBV1V3aNL9g64iUdgy?= =?us-ascii?Q?NyHrraLuwug71qjLug4MjQ4j8L3METhg0P6h9U0CYRPlxIjHRkyZPDotC2Lo?= =?us-ascii?Q?9LpdWXNPvSAnBipMYFhv7cu3a+QAOU6ZL4ly6OwOLX+AmkfJWc7zrgwuRwG+?= =?us-ascii?Q?H1wDmQVLQhfOgMTymCAZNo+lAshueJ0GXDs6NbQaAVJ2wWRRiserKTmbBw2b?= =?us-ascii?Q?ux1guZwZbVPYOVoLDX2vX5k74wuHsui0l8X3AjvLOM8quLwK57mo/ZQj9b7x?= =?us-ascii?Q?MzI6EnoEbThEe7aCxeGM/JDKBj2aXM5bmB0n7zXOv39n/+b2UeEHM3Alkt6h?= =?us-ascii?Q?mV4cML0zU4Lsvie3xg2rq+V+hT0Kr3QHt62pqQcHl28A+CJXpYkPe2nZG43U?= =?us-ascii?Q?rNnE0PGKEx+sPgkYGAVtMGED3ovjXxjQKMNJwIxai6Yh7I4Q/3K+mAgY1ENo?= =?us-ascii?Q?5FhOAvgCR0RlBgAvpWnuEclS1W8SLqds8y76KYNoEuFmkH/UBB1wUqTF0tsK?= =?us-ascii?Q?6NcIxSyB9/2ZkZvp8vy3iUIX9PcczukKb3SEhe3FQRVlIIVpgdRFPbibIKzA?= =?us-ascii?Q?2RO7QXvwQf1DQdlIQ7PNBO8nGiXYUHhaNWURoX0qI59l9X5THc8Usa2IU/+0?= =?us-ascii?Q?5D8nv/KVLFDe14U=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:33:55.8225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6b94eee-bbac-45de-a11c-08dd20c0475b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7374 Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra migrate_degrade_locality() would return {1, 0, -1} respectively to indicate that migration would degrade-locality, would improve locality, would be ambivalent to locality improvements. This patch improves readability by changing the return value to mean: * Any positive value degrades locality * 0 migration doesn't affect locality * Any negative value improves locality Link: https://lore.kernel.org/all/20230619094529.GL4253@hirez.programming.k= icks-ass.net/ [Swapnil: Fixed comments around code and wrote commit log] Not-yet-signed-off-by: Peter Zijlstra Signed-off-by: Swapnil Sapkal --- kernel/sched/fair.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e66b10da7ac5..2ca3f098552c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9323,43 +9323,43 @@ static int task_hot(struct task_struct *p, struct l= b_env *env) =20 #ifdef CONFIG_NUMA_BALANCING /* - * Returns 1, if task migration degrades locality - * Returns 0, if task migration improves locality i.e migration preferred. - * Returns -1, if task migration is not affected by locality. + * Returns a positive value, if task migration degrades locality. + * Returns 0, if task migration is not affected by locality. + * Returns a negative value, if task migration improves locality i.e migra= tion preferred. */ -static int migrate_degrades_locality(struct task_struct *p, struct lb_env = *env) +static long migrate_degrades_locality(struct task_struct *p, struct lb_env= *env) { struct numa_group *numa_group =3D rcu_dereference(p->numa_group); unsigned long src_weight, dst_weight; int src_nid, dst_nid, dist; =20 if (!static_branch_likely(&sched_numa_balancing)) - return -1; + return 0; =20 if (!p->numa_faults || !(env->sd->flags & SD_NUMA)) - return -1; + return 0; =20 src_nid =3D cpu_to_node(env->src_cpu); dst_nid =3D cpu_to_node(env->dst_cpu); =20 if (src_nid =3D=3D dst_nid) - return -1; + return 0; =20 /* Migrating away from the preferred node is always bad. */ if (src_nid =3D=3D p->numa_preferred_nid) { if (env->src_rq->nr_running > env->src_rq->nr_preferred_running) return 1; else - return -1; + return 0; } =20 /* Encourage migration to the preferred node. */ if (dst_nid =3D=3D p->numa_preferred_nid) - return 0; + return -1; =20 /* Leaving a core idle is often worse than degrading locality. */ if (env->idle =3D=3D CPU_IDLE) - return -1; + return 0; =20 dist =3D node_distance(src_nid, dst_nid); if (numa_group) { @@ -9370,14 +9370,14 @@ static int migrate_degrades_locality(struct task_st= ruct *p, struct lb_env *env) dst_weight =3D task_weight(p, dst_nid, dist); } =20 - return dst_weight < src_weight; + return src_weight - dst_weight; } =20 #else -static inline int migrate_degrades_locality(struct task_struct *p, +static inline long migrate_degrades_locality(struct task_struct *p, struct lb_env *env) { - return -1; + return 0; } #endif =20 @@ -9387,7 +9387,7 @@ static inline int migrate_degrades_locality(struct ta= sk_struct *p, static int can_migrate_task(struct task_struct *p, struct lb_env *env) { - int tsk_cache_hot; + long degrades, hot; =20 lockdep_assert_rq_held(env->src_rq); if (p->sched_task_hot) @@ -9462,13 +9462,14 @@ int can_migrate_task(struct task_struct *p, struct = lb_env *env) if (env->flags & LBF_ACTIVE_LB) return 1; =20 - tsk_cache_hot =3D migrate_degrades_locality(p, env); - if (tsk_cache_hot =3D=3D -1) - tsk_cache_hot =3D task_hot(p, env); + degrades =3D migrate_degrades_locality(p, env); + if (!degrades) + hot =3D task_hot(p, env); + else + hot =3D degrades > 0; =20 - if (tsk_cache_hot <=3D 0 || - env->sd->nr_balance_failed > env->sd->cache_nice_tries) { - if (tsk_cache_hot =3D=3D 1) + if (!hot || env->sd->nr_balance_failed > env->sd->cache_nice_tries) { + if (hot) p->sched_task_hot =3D 1; return 1; } --=20 2.43.0 From nobody Sun Feb 8 09:22:49 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) (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 21443156F3F; Fri, 20 Dec 2024 06:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676469; cv=fail; b=slC+zX703khNhsd5je4kxNVkLt6QXJ91JD9x/J3AvUEq+2afbNSVn8TDVXjyPzKzvMFTm96U4URVglPKNuvxGyoPysO+HCu2KJ6m3jbDE26Y3H4RxngblYEv5dC9qGEg9ssSqiKpHBDtGONbf2rvwzuQG6GhYwLymyvHGfUAris= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676469; c=relaxed/simple; bh=jurCLl3fsIBkjLbXXXO+NlBxUQznbG8299fMfSO1akg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WtH8q9df9e6FSx6LAZvoydrts1+Xr9eFCZ8UG/30hi+yKZZlNe1kvn4L8NzYwz0Q7r8S0uc5wHk+Bsn5U3P8bKauG3JtmQvsNjqkblzqLBBmtxF2m9QD6QzWU/jdJaD3ltYnVmbq/pJxvNEruAGSUCZ+/Nt+jOoc2lj2QexJMKo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=etRmqMFd; arc=fail smtp.client-ip=40.107.237.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="etRmqMFd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BrfFLb4fH0cMkKO/3Ze2c0YnVeBwMzoHExfcnCtgFAhqYNOW6XFVzzQyQfdYM5NfP+8/6DCi9oH26tNYnpMeNC/+JAjHAYg5C030LrLMKA/JcBFN0sJ40DVg2vdoVuENC3Z0Jb81gCjiIc6xg1neDo4abll3vHixzKH4m1UTYi7IoyUVnJjMljCye+hV+UDKB7e6hv5Xe8BSm72jz55OL0xV6vOUocmnkA6TgLIsT8o9EvyginFDG1byH8JLhIPZLzBIXrNBI0vfrx5+2SVTEizBQXEzsWCLkDo6YvHvwQXQl2//K29n6XiUkDA/kZzhpRyTQZieQSuPAtWyObdPYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CvrT1OYZQZbC0lFEU3j+Bh22hRSC2bnndzc3DYLZwn8=; b=OYvDyCRqSak1caSvqWKePFiblR3jyW1tJwIPd+lqTjihNT33kFVKzMSRcytj0AK+FlRyk6N2aH4peEMk/nfhjhx47T6f2TduuOZ1V8188sPPl7SUuqHD9fGsIeflrXg5gscJbh9HZAq3zhzlQBVWN8thg8sK92tAgu4rxrGM08Ts6o+TQPEwlQBJ/B+76tSQ2wO2t3koKOsrLk/+C+QzMT79f5htRFvsby2tceXicQks5trwyKWhST09nXSLu8OqKPadTb2ReR1Bto8VePwLHrlJjsrZZYMMZluOqSwdpVsMerEIyrD08KhBoNMRfUCtzlHEB0aASl4+VlZ+6j6xNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CvrT1OYZQZbC0lFEU3j+Bh22hRSC2bnndzc3DYLZwn8=; b=etRmqMFd2++6Lv8urZRFLOcWsTM49o0QDkCpT1LOdqtljPNv55XC1sYd5ZWx6Oe193fcRFrUxUm8X7YFBBh9yk4CwcVMpxcuUlcEX7aSzN4SxqHixW1jhBnV5GDtfRkdD1yd0w0Ynzc11dYoO80rzoKuKRs/7b+qqJ8gYR5F7jM= Received: from BY1P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::13) by IA1PR12MB8336.namprd12.prod.outlook.com (2603:10b6:208:3fc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 06:34:20 +0000 Received: from SJ1PEPF00001CEA.namprd03.prod.outlook.com (2603:10b6:a03:59d:cafe::1c) by BY1P220CA0007.outlook.office365.com (2603:10b6:a03:59d::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.16 via Frontend Transport; Fri, 20 Dec 2024 06:34:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CEA.mail.protection.outlook.com (10.167.242.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:34:19 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:34:13 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 3/6] sched: Report the different kinds of imbalances in /proc/schedstat Date: Fri, 20 Dec 2024 06:32:21 +0000 Message-ID: <20241220063224.17767-4-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CEA:EE_|IA1PR12MB8336:EE_ X-MS-Office365-Filtering-Correlation-Id: 04e771e0-e65b-4908-16c1-08dd20c055b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KCmCHmNMv8nFnLwu+e550R4IQuHVdzArW0j0rPWM4gjYvjv5wtgCuIKZpido?= =?us-ascii?Q?RKh/WN3KmD7aoHV7cng87yYshDVe/JFNMhMWNxdlanhuUwHJ+9R+Lqb2/G63?= =?us-ascii?Q?87RP/ImVlcSlJdv6GgOC8AZI0UbUYP9QdaJ1hmbGEsd5nmWeH+eo5PhXMNc3?= =?us-ascii?Q?UMH5rDirRB26lZ2TSN9GObPSiq71p4Ev+kDo9KaSzQvV77WRSkEM7fZihvWu?= =?us-ascii?Q?WGPatvdFR+nZFEb6dWykL8aTeZzRZwLmpuceAwYlTbknLldPIfFNj5yRttsI?= =?us-ascii?Q?hPgmYA+HJ6d19GhsyRniE6VuWHDdHgTkXTxl4GwVmbT99mevUpYyDrWKGvQr?= =?us-ascii?Q?PeAjiDtSAwQBucvluOOa1OAe48DzWBLTjTzLpMDN4Hi5LwtIWVoqCOtEJxR2?= =?us-ascii?Q?EI0gIyc0QyIFeVVJZWl3Bv/e2faiDMHw+92PFgzAqPCQvu6CuWhfJqIONl7G?= =?us-ascii?Q?fxtfOnqp0DLIoumuGcwAw89u24TgSfx21YNljl/uMDNYsoKNA9siSOWLvN5i?= =?us-ascii?Q?JwOMwp+Ec6/5e4Digp+fPG85KAcpNrAt9a2lgVcMBcFjwXLe3yo3FAJpfwiM?= =?us-ascii?Q?a8dwhNM8B9+5FFyrFjbsXvsYe77lQvO6WU7sB6tfivhRAYB5dTJKDXA7FJvf?= =?us-ascii?Q?lDDYAbYJ26Xd/zF0FFb60xwPrIdfrCiMoLQu260qUqGfGt7Tu3qnsTGbFjOM?= =?us-ascii?Q?ABVoA08nWizWdxBdp+G781FGJdXeoNsCYs/KNVTHXHvsiecABZXVpreAnEYh?= =?us-ascii?Q?9jTWDB6Y/YqIWcAQ9YFAhc2hFCbYHQ0oMOPNiIhxszWZk27d78XVVnCLKUKP?= =?us-ascii?Q?/bd3yoEQkjFoAoSeFvuUsi+PfhWCTp5uJWD638atiamqOpoNueAvbZA/jfT1?= =?us-ascii?Q?JiSC52AaR/KCqNyeU5I842HTvYVSMKrYxcGsVUwtJF6jA+iGwTlHdRp09wDd?= =?us-ascii?Q?1Lu1PP4EOkJD/SopdsN95Ik6kXUo9MQua0ylKLhO4SYFP6G1pRl36cX9Pf4p?= =?us-ascii?Q?NSozAMN7XnLeDtLqCJfcAiuOl9FShSj977mZDnDfpRbDmDKMyFbOFOHV8pN5?= =?us-ascii?Q?OJCe6y882sAT6abAj10WJ8rXDX5BEGV6beW2b+COTQnH/D6KMaWBIg2whjKI?= =?us-ascii?Q?lf0D9/dMb2oin/9zDCn5WtdGyJKt+j9eaFrupUx5p19F49unpiHSFdoep8Od?= =?us-ascii?Q?cjlABXdoweC/f9YpqPIfHbqmmTp4lN6hcnJx7SsVYI0zVzy1goRWuK/guEQ0?= =?us-ascii?Q?eqXokTYUWB/EQZl4Kf4xBjcrGozRJgFjmEswikvr0tBsOIUXZILxgxbJhLL1?= =?us-ascii?Q?Fo1Ar5VanWvSHXrMbufnqb8wo8d/w/24MGshs0ZLXB9aR2UDNcoGMs/b6Oe+?= =?us-ascii?Q?Ci50wWnznOQZBOfm/fzEH5Jhh5tYZnKBCgvgFsZRXvlByLaariwylmm4ksfg?= =?us-ascii?Q?UB+MyVxhTsBArCKiRcz3PiSr8CuJNq+N56irHZfV3P4BnHDlFm7HGAsoeMM1?= =?us-ascii?Q?yYotGiVoAGBRM9s=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:34:19.8591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04e771e0-e65b-4908-16c1-08dd20c055b4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CEA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8336 Content-Type: text/plain; charset="utf-8" In /proc/schedstat, lb_imbalance reports the sum of imbalances discovered in sched domains with each call to sched_balance_rq(), which is not very useful because lb_imbalance does not mention whether the imbalance is due to load, utilization, nr_tasks or misfit_tasks. Remove this field from /proc/schedstat. Currently there is no field in /proc/schedstat to report different types of imbalances. Introduce new fields in /proc/schedstat to report the total imbalances in load, utilization, nr_tasks or misfit_tasks. Added fields to /proc/schedstat: - lb_imbalance_load: Total imbalance due to load. - lb_imbalance_util: Total imbalance due to utilization. - lb_imbalance_task: Total imbalance due to number of tasks. - lb_imbalance_misfit: Total imbalance due to misfit tasks. Reviewed-by: Shrikanth Hegde Signed-off-by: Swapnil Sapkal --- include/linux/sched/topology.h | 5 ++++- kernel/sched/fair.c | 24 +++++++++++++++++++++++- kernel/sched/stats.c | 7 +++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 4237daa5ac7a..76a662e1ec24 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -114,7 +114,10 @@ struct sched_domain { unsigned int lb_count[CPU_MAX_IDLE_TYPES]; unsigned int lb_failed[CPU_MAX_IDLE_TYPES]; unsigned int lb_balanced[CPU_MAX_IDLE_TYPES]; - unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES]; + unsigned int lb_imbalance_load[CPU_MAX_IDLE_TYPES]; + 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_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 2ca3f098552c..5e7e4fe81648 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11699,6 +11699,28 @@ static int should_we_balance(struct lb_env *env) return group_balance_cpu(sg) =3D=3D env->dst_cpu; } =20 +static void update_lb_imbalance_stat(struct lb_env *env, struct sched_doma= in *sd, + enum cpu_idle_type idle) +{ + if (!schedstat_enabled()) + return; + + switch (env->migration_type) { + case migrate_load: + __schedstat_add(sd->lb_imbalance_load[idle], env->imbalance); + break; + case migrate_util: + __schedstat_add(sd->lb_imbalance_util[idle], env->imbalance); + break; + case migrate_task: + __schedstat_add(sd->lb_imbalance_task[idle], env->imbalance); + break; + case migrate_misfit: + __schedstat_add(sd->lb_imbalance_misfit[idle], env->imbalance); + break; + } +} + /* * Check this_cpu to ensure it is balanced within domain. Attempt to move * tasks if there is an imbalance. @@ -11749,7 +11771,7 @@ static int sched_balance_rq(int this_cpu, struct rq= *this_rq, =20 WARN_ON_ONCE(busiest =3D=3D env.dst_rq); =20 - schedstat_add(sd->lb_imbalance[idle], env.imbalance); + update_lb_imbalance_stat(&env, sd, idle); =20 env.src_cpu =3D busiest->cpu; env.src_rq =3D busiest; diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c index eb0cdcd4d921..802bd9398a2e 100644 --- a/kernel/sched/stats.c +++ b/kernel/sched/stats.c @@ -141,11 +141,14 @@ static int show_schedstat(struct seq_file *seq, void = *v) seq_printf(seq, "domain%d %*pb", dcount++, 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", + seq_printf(seq, " %u %u %u %u %u %u %u %u %u %u %u", sd->lb_count[itype], sd->lb_balanced[itype], sd->lb_failed[itype], - sd->lb_imbalance[itype], + sd->lb_imbalance_load[itype], + sd->lb_imbalance_util[itype], + sd->lb_imbalance_task[itype], + sd->lb_imbalance_misfit[itype], sd->lb_gained[itype], sd->lb_hot_gained[itype], sd->lb_nobusyq[itype], --=20 2.43.0 From nobody Sun Feb 8 09:22:49 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) (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 9004270818; Fri, 20 Dec 2024 06:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676488; cv=fail; b=oqR4REobw3UllcdUEKHQw1BjEiV0/TJacqz9xr7JE+3ok1TpAsN+pbKB6ljuIPkaWhFXdr5zwvvYK+VMu6vE9kBuwTBxUDVDrNlZrOCaaz4o3WFPtYpo7kyxSZLUn6SbA2DbZ6xfI6cctwNsQjzzSQpcHPAQfYmqIFcwdpkmJv8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676488; c=relaxed/simple; bh=QzvYnxLggdomgx0I/3ZLNFQBVVmxRDDubP0cL3ikqqc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TKFQmySawCR0M1J2ti+qi9bqINo5bQuyM3OuT6eeoytr8X05H4KtH2SUjZlJVAKExzQ6mHoxpB+mbU+YJPxSyA309ZIQ/A50SjxlrIGlweL1pXjnXDTlGeAMvYUhs4Bn3ijW8N7uIJBM0O566JkSKjRfMcEKg7RPAeXEzaPpHvE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=eGqN1T38; arc=fail smtp.client-ip=40.107.244.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="eGqN1T38" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LyinjkF4vnAe3txxF34WEObP+Oje2vP54cw7zUaZl+NayBaVFdbEA3/+YL6nfq7BRS4LXViggkxbih7zIuCObDa9l4VjYG81k4hZv0/u2E9EF1VguvU553ANbQNw+OwahNTIZD0DTX0YFjPdXjxR24jF1oGzpYmtyyenSZ/k8kyX/0dldkq28ZE1FIzZhYwKyimD3LUZ+qxddtnslesZkVCKTwsMlkPaAmPgZCGBhVAEyzNCGNUUvuX1zP55rG0C5tU84HZkBY++7F5UFburqe8L3uO5hHpTsJiXwh3HYmb7Kr6ylr335XnDllG+M7vwv0SvvTvj3JYWi6sKnJ8+MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r/8dnpWCsPDcDBlVNBQ03ePZnGE2WchNolW8p8yZILM=; b=EFtJEJOihYgy/7D52OdAHrSrr7tGteJ99i/sPi81BKJhI1SMDeWSQXKSlRcG5SUXGXf6a+qNuCc2F7fgQ18I9Y4ZLbt4ZNhadTCW8bF6d6UDB1/llvyUguhj1odua1/19HPC4ahJtCZRGej3iIUR1nv3QDlWB3chSqtmDXA4P4RP7oxTkWWj04DG0itE4S0a1tT63UabIARG9EquZZHjkP9az2nYzuLYF0AoDpD5EbLlEBKctiY6UgP1vqOed0btNji3iQ/mjV52lml/QRKqEhcrngAe3W6IRhd4B4s0edxNZ2JCcrpvBw4n0Qb5Z2K7md25Wr0o3jm3HRDDVVseuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r/8dnpWCsPDcDBlVNBQ03ePZnGE2WchNolW8p8yZILM=; b=eGqN1T38xwftVMvtm1bbJMrc2QqWVZWr/si693yk7lbvUYuBHTNDw9Q0quqGoX/PEeXf/nnKNvWgRFMGC6v0NSYfidzcciB1F8jeBb5M1ao1h7eUf3R4QoX/xXrLkkqOY/hUS0BEBimloHWnTxaCMtPqDWobo+3HT6hfhCQSy/Y= Received: from MW4P223CA0014.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::19) by CY5PR12MB6478.namprd12.prod.outlook.com (2603:10b6:930:35::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 06:34:43 +0000 Received: from SJ1PEPF00001CE8.namprd03.prod.outlook.com (2603:10b6:303:80:cafe::bc) by MW4P223CA0014.outlook.office365.com (2603:10b6:303:80::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 06:34:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE8.mail.protection.outlook.com (10.167.242.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:34:43 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:34:37 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 4/6] sched: Move sched domain name out of CONFIG_SCHED_DEBUG Date: Fri, 20 Dec 2024 06:32:22 +0000 Message-ID: <20241220063224.17767-5-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE8:EE_|CY5PR12MB6478:EE_ X-MS-Office365-Filtering-Correlation-Id: f91b242c-6e59-4992-4215-08dd20c0638a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2sIaiQlckuiDuOxNISGMfmVh/uaJ7avHklgayX+uVJPKwNQCx24Ya/Zngx4q?= =?us-ascii?Q?JC01swe8s5fsTw74vEJapxSw7I9dqa8Gl8Kpyn7IHAowVdryeZe8I/B/29N2?= =?us-ascii?Q?NyfAxfPUd/MiJVcI0rcV+rnzr8Sd/9Cs4+olP4EFZO1mfLUyKQraQYC2Rq49?= =?us-ascii?Q?1sdMNgYyYTjq2N06ZC+h4u4qo19ze8UiCyNXcnFlEFWaiYDZ+5OjZQgtmlIK?= =?us-ascii?Q?m8kmuxa+blU+vT9K0r5m/dpKyArzcMSFsj5VWnqnRC85yAf6IS9pd9V/X/nq?= =?us-ascii?Q?GMY57XRz+IMCu3vBxcr/o6l+MGkBW6xjahSW2IInvQ1Px/CXAZ8b31mZihr2?= =?us-ascii?Q?5yzkkUYkg03y25QICuB5sNykEBfcZWQBr2kfb7UuX5aUBm7dCUAp75wRVD1W?= =?us-ascii?Q?Xs5pasteJQOxdtBGG9KtzEEjgv/h4jO6vti1LnE1yMm/PhuDPJue6y9YWlas?= =?us-ascii?Q?AgJy/tQAtFY6yXvDUB6SXiG2jhgLTrmDnQYbe/4CQE0kiNqEOmWM+YXDSEMf?= =?us-ascii?Q?CsLqeYSJwJ6baldMjKMp7UKCJjo7i0j9u247bc5C1ay6dGuWU4jIyNODplsy?= =?us-ascii?Q?Ur7/lNJ0F0TAOYqPW2Q2kdTfQzsjvg4HvrZrk6KQmXmU85ARd+DchC9kzzt4?= =?us-ascii?Q?og5lLi9D/WCCtFkM8jw20MvprajAyG/2UkBpEaQ1zpgSx50ntLruuZSPXFeG?= =?us-ascii?Q?GeTi28PpYLARI8Y5qWlOp3OynRK8EeWqTMoT4Pw+ajfvI1kw3RnBnBNDf/Cp?= =?us-ascii?Q?uoBo9Tnk3f5EBy5vYlqDrYMuE8kXdL5IIbvofXMFYz8lH4NORaqPq5sfIy9x?= =?us-ascii?Q?+hiKnxEaVqYi+EydD9AnRyjVjpqeOfF+AbsRBEm+KWFagDwrznJPIPH7sdWi?= =?us-ascii?Q?tRugDwp/ZABoBEdTSEKoNV4hgjqCHf4mevheQFKX2FXDCioLZm/Vr5JI2Yoi?= =?us-ascii?Q?GOVnqhJUxBbQLUFT8YNc67scLBFZiSpfzjL24PV/3lF5ew5GOtxP+JrHlCk5?= =?us-ascii?Q?b7kGS42DEzaBQZk7suH1cu0H7thy7pnmCzPPBJyUQzPITaCO28S1j2rQyBsJ?= =?us-ascii?Q?glzWFWiCbGN1yUoUmxgXZgjmzQxvIvs7se3Fc1D8WKUsPstDaXyEhxsKg6+7?= =?us-ascii?Q?jZ3ol9sS+f/6wwbtSz/yQzuRdwbHYyZdDe4CaAWmaz+SVP8cbFzqkSU7Voyd?= =?us-ascii?Q?PZwI5n64ALI93aewkQ5CwRbBFSmYT34MxjF8ChND7nEsyPr9mPvNCa/bWhx1?= =?us-ascii?Q?ZVdmFEF1OCpEXkw9OOQDpyYlqZkSGbmn2lcomcjzyiCtQtw2P5SFIiqQNi5x?= =?us-ascii?Q?s8Wb86iphxOMrkqF7y4lMzCOJzbKygUcZ+bTohBzO7GaXxMOPmgqvyLl/TfG?= =?us-ascii?Q?agZoR4c8kblwZ4FBf0QMq6p92e+M+Iqvu1rfZQJ5D4vvVHXkHnr2yg9zlbjw?= =?us-ascii?Q?R7sAjRzaqlRschiY16OAQsalL5JsocjnwwCuCsLZ9nU781VwMn25d7ugz5Tf?= =?us-ascii?Q?u8BrOqpSV4iovYc=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:34:43.0730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f91b242c-6e59-4992-4215-08dd20c0638a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6478 Content-Type: text/plain; charset="utf-8" /proc/schedstat file shows cpu and sched domain level scheduler statistics. It does not show domain name instead shows domain level. It will be very useful for tools like `perf sched stats`[1] to aggragate domain level stats if domain names are shown in /proc/schedstat. But sched domain name is guarded by CONFIG_SCHED_DEBUG. As per the discussion[2], move sched domain name out of CONFIG_SCHED_DEBUG. [1] https://lore.kernel.org/lkml/20241122084452.1064968-1-swapnil.sapkal@am= d.com/ [2] https://lore.kernel.org/lkml/fcefeb4d-3acb-462d-9c9b-3df8d927e522@amd.c= om/ Suggested-by: Gautham R. Shenoy Signed-off-by: Swapnil Sapkal --- include/linux/sched/topology.h | 8 -------- kernel/sched/topology.c | 4 ---- 2 files changed, 12 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 76a662e1ec24..7f3dbafe1817 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -143,9 +143,7 @@ struct sched_domain { unsigned int ttwu_move_affine; unsigned int ttwu_move_balance; #endif -#ifdef CONFIG_SCHED_DEBUG char *name; -#endif union { void *private; /* used during construction */ struct rcu_head rcu; /* used during destruction */ @@ -201,18 +199,12 @@ struct sched_domain_topology_level { int flags; int numa_level; struct sd_data data; -#ifdef CONFIG_SCHED_DEBUG char *name; -#endif }; =20 extern void __init set_sched_topology(struct sched_domain_topology_level *= tl); =20 -#ifdef CONFIG_SCHED_DEBUG # define SD_INIT_NAME(type) .name =3D #type -#else -# define SD_INIT_NAME(type) -#endif =20 #else /* CONFIG_SMP */ =20 diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 9c405f0e7b26..da33ec9e94ab 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1635,9 +1635,7 @@ sd_init(struct sched_domain_topology_level *tl, .max_newidle_lb_cost =3D 0, .last_decay_max_lb_cost =3D jiffies, .child =3D child, -#ifdef CONFIG_SCHED_DEBUG .name =3D tl->name, -#endif }; =20 sd_span =3D sched_domain_span(sd); @@ -2338,10 +2336,8 @@ static struct sched_domain *build_sched_domain(struc= t sched_domain_topology_leve if (!cpumask_subset(sched_domain_span(child), sched_domain_span(sd))) { pr_err("BUG: arch topology borken\n"); -#ifdef CONFIG_SCHED_DEBUG pr_err(" the %s domain not a subset of the %s domain\n", child->name, sd->name); -#endif /* Fixup, ensure @sd has at least @child CPUs. */ cpumask_or(sched_domain_span(sd), sched_domain_span(sd), --=20 2.43.0 From nobody Sun Feb 8 09:22:49 2026 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) (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 BCD3713B5AE; Fri, 20 Dec 2024 06:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676509; cv=fail; b=t/TJHFxslBFpSNIUkr8c6mNHCjh20y+y07AexjPgRBC8c9Kj0Gzxc/BuquCqR9u1mq7a95L2GF9KL7hGHnmoICMLOOsF8ZCrmjKsWZ6aILo60kDtdg8CX7V4JjTO4KCRWwa9yv6qHQdzJieYCaOwBqDLA/Gv+L3fFUlnRbCsEu4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676509; c=relaxed/simple; bh=5imA6ZNBxOsT9LZjKmWlgFdgED6D46Xy4pzn2iVYwhs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sinc8mzZkLKBR9Z4If9Byo+hbIUojB4A4eAs1EQ+0+ca4dncuvxQd6EnRvOuR+15RuKRbSaaIFrav7+Mex17cMiiwQzBMVJf8uvCQpnMGkDlfTRvItOFdLQ3uQLIgkK4ag3+Awo7tQEwlqdBvLfuONY6sosKlvDYNkgHJk/FFz0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mujix//+; arc=fail smtp.client-ip=40.107.101.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mujix//+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dlL5OHj90awPP39VXJCMYFGSMXrLxUmwEL0x3S5zFfxj18Rol10cSOGPTIv7DP4dOQW6XySX6LAb2a+DujwLxd5P54MZjEw7m2MKpjWF9gV6gKk/OwI9eI9pJx6XeQEP0vB4OE910oedhHeCVKrfQae9T3ub5pRaIohL0YRs6U8IDTCIOHiJ+aAt39rRP0Aoq2WiiU+YY0l+/HPhgfyDfxrmNi3ufdv9i5OsTeNM2O1aW9uLiu3OrJG1M96a0WiUZj9adyYE3nvo/0uX/ncZxD9wSe8nUEKItN0ZIN/VAvhq4YOyrlDItWtMy8BozF/ZO46tii7g09r/8d0hwVOyDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0S47izQ13tMfqzj0XwrdzOi5U7G5peNUHpWyQWl/b/c=; b=DFEnkGMrz0N1EEHrUSV640SNe51UTmQ2k8Y5m5PpxtpzaSE9GYDpFvi6FQEXGWQcWMR2IbFEva9eEmueGNIIXJs/pTDZHvahn0AMTcL+jVY/mIILI9Q/wtVbOGjhaiBdVpZWq4vdt/HkfkB7eEgVQcVPrXryBymkqK6A3+ICRv37hiSMBY+/7ZOteIIrs9oNii8tDV65hzq7P2aBK9dS2LgQY5skst4knvga9jCw3ILuO5oWPmpm0bIUx4jReUDHtLAOt27XM4zcifT8ZN0hz/yx8VCaZlLmqckvf08LjILOFQTLIC2jjPDtAl3QIBarTqXWgVjZeCHIIT2zQt6ckw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0S47izQ13tMfqzj0XwrdzOi5U7G5peNUHpWyQWl/b/c=; b=mujix//+8jmB3nLFxSjZS5jJEUZ5+EkvNrtGeiklDzqLJqAN34LdRsSQMQUnODtN88dRbwby3Dh8gq6HQbBCI4lf1YK3fNIC8r4mi/ZNvBrX+dxAxF7lgjthVcdNoNVEfba3hGiTp6BY9n2pk99UbpREYsw8f+8zchHwvUDZd2w= Received: from MW4PR03CA0115.namprd03.prod.outlook.com (2603:10b6:303:b7::30) by SJ1PR12MB6049.namprd12.prod.outlook.com (2603:10b6:a03:48c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 06:35:04 +0000 Received: from SJ1PEPF00001CE4.namprd03.prod.outlook.com (2603:10b6:303:b7:cafe::bc) by MW4PR03CA0115.outlook.office365.com (2603:10b6:303:b7::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.21 via Frontend Transport; Fri, 20 Dec 2024 06:35:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE4.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:35:04 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:34:57 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , , James Clark Subject: [PATCH v2 5/6] sched/stats: Print domain name in /proc/schedstat Date: Fri, 20 Dec 2024 06:32:23 +0000 Message-ID: <20241220063224.17767-6-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE4:EE_|SJ1PR12MB6049:EE_ X-MS-Office365-Filtering-Correlation-Id: cb04f288-c9b0-42a0-f69a-08dd20c07057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1PU4UnlWT7zO6YlNWUpR0lBlWTpu8Op2X2dhDQxIsuDx2bdopoAEmcKkGkE4?= =?us-ascii?Q?6Mna4P/CMrfXzr+j0hZ6ziP9AaSEjsIEQbetn+hJI07lQYpWeRVqVzfa7vLn?= =?us-ascii?Q?wB6MrIN/ft/0t02bOavit07GBZ3QgVkwwHCzF0yeFypH+Vp+DWmt6cSmjL34?= =?us-ascii?Q?8JnDYcPh1EAQ84U+kKr664BmkorxaFpc1RTmK+3Ml+R/iFd6ciuhrLqYaT5l?= =?us-ascii?Q?n8/Vdh1d2BH1kqVHYJh1RPmB+KKnokY/wJLBmIXylWmmtIxG31OS46zgZ6wh?= =?us-ascii?Q?WJJHrs15hS5fUi3eXuLT2WEOyYco9IQ05O4gVCkGqPpaNYv+p/LOcecX4CY5?= =?us-ascii?Q?suAmU2xbUtUpttNNimXWHP6asiddxBR6niTHnjZLDGLRfJKx+8EuRNbM77xB?= =?us-ascii?Q?rK6hdu1OEWusHC88YMj6F0/ZTPUylytx9JBXv7J9aL0kP9w0m6LFIx49kVE9?= =?us-ascii?Q?IQfeVWR/+egWnAiFWiMA1BrBiIEmu4Zw0E2sTsHCBg8yYTT+9+TQdV2oFJr/?= =?us-ascii?Q?Cvw1IIHLdXzeB12elooIXTSiAahTfcSkqj5V7WbBkgkUpJn/5y6A/VtNd96o?= =?us-ascii?Q?BQ7UOrv9kJmGf2mEbGIhXRytLR56TzXP4ENe4/m3xf5N4GFdrsL8ysC2k/kc?= =?us-ascii?Q?pQyPQZRXqT+wMXdaCo/82W5hecovCR7/b7L6BrSH/3uNZUtPBMpUzHqE+C0y?= =?us-ascii?Q?s2mwMlFBy/oRIh+kicwfaGgTgSOvt0oR9sYsKfxO0LKsuVIxAJSOzoiQWdoI?= =?us-ascii?Q?LlvVl4V1rceFQmjpL7aA4Zm+a2gNSPZd179JTveF4pG4Kc+mlzfryNDos4+x?= =?us-ascii?Q?woGNR6d+NKemZf5SdLJ4h4t8HqWgvwtowV1UaWLON3niii1xb5W/rnjoLTe1?= =?us-ascii?Q?Wn91kRi0jt5lMpA4fuWrHr3wclRBdGpjjM11TmkNAcO1TCcj1QMXEVEB1TS5?= =?us-ascii?Q?Jadr3NG8Q3pQEfE1W+LKgpFIFfi5JQme/EPpUYipsmzu2+3CWGEcehF05xGp?= =?us-ascii?Q?bGuMa5x0uj/r1OoQGejnaCg/d2i+HCN9o1cG7Mr4nrueY/EawMzZUymVMn+G?= =?us-ascii?Q?G8oVMgHnIwJBlo6bFywWjFnGPrEejh1mcKWj9Wu64B43S53kVPb3BYzCReF+?= =?us-ascii?Q?pySFGFhEcrowzGpwHTw4EJEWOGJa1R80BhTf+yTSoecLmOKG/IEgvzMctcPG?= =?us-ascii?Q?3H32koEzJkGlpJTfZwGUoL012+QAmzuVTuQoyTfpzrzvfdPuVYYD4CWfKcc8?= =?us-ascii?Q?xFUJaXDVKFlkWedJlb2XrC6kBhJl7zXa65uwv5aLomrLOoZHhI/ofecGNgrY?= =?us-ascii?Q?f9DHih37iLOVY1ShkLQCkMvtmQSj+z8Smaw5RPc+rXsPC1RyIT0gGrVbuS6j?= =?us-ascii?Q?Nxpyonn4EhWwD6tlRzNHKaydmlCQtKDu1gmUUINhMVzGNM5vUYZvu24AIRHd?= =?us-ascii?Q?dAD5fx3+AQ3FeqVHgl/J0luNEf2TLYGToWOdMKy3PM/Pl2YkqY8g4LZiVJTf?= =?us-ascii?Q?QOqptG471/v+dY0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:35:04.5538 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb04f288-c9b0-42a0-f69a-08dd20c07057 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6049 Content-Type: text/plain; charset="utf-8" From: K Prateek Nayak Currently, there does not exist a straightforward way to extract the names of the sched domains and match them to the per-cpu domain entry in /proc/schedstat other than looking at the debugfs files which are only visible after enabling "verbose" debug after commit 34320745dfc9 ("sched/debug: Put sched/domains files under the verbose flag") Since tools like `perf sched stats`[1] require displaying per-domain information in user friendly manner, display the names of sched domain, alongside their level in /proc/schedstat. Domain names also makes the /proc/schedstat data unambiguous when some of the cpus are offline. For example, on a 128 cpus AMD Zen3 machine where CPU0 and CPU64 are SMT siblings and CPU64 is offline: Before: cpu0 ... domain0 ... domain1 ... cpu1 ... domain0 ... domain1 ... domain2 ... After: cpu0 ... domain0 MC ... domain1 PKG ... cpu1 ... domain0 SMT ... domain1 MC ... domain2 PKG ... [1] https://lore.kernel.org/lkml/20241122084452.1064968-1-swapnil.sapkal@am= d.com/ Signed-off-by: K Prateek Nayak Signed-off-by: Ravi Bangoria Signed-off-by: Swapnil Sapkal Tested-by: James Clark --- kernel/sched/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c index 802bd9398a2e..5f563965976c 100644 --- a/kernel/sched/stats.c +++ b/kernel/sched/stats.c @@ -138,7 +138,7 @@ static int show_schedstat(struct seq_file *seq, void *v) for_each_domain(cpu, sd) { enum cpu_idle_type itype; =20 - seq_printf(seq, "domain%d %*pb", dcount++, + 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", --=20 2.43.0 From nobody Sun Feb 8 09:22:49 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) (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 79EB3156F3F; Fri, 20 Dec 2024 06:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676531; cv=fail; b=qPjpbt2Vj02WnUqWdJW2TTa+cKJ50hguA8TpRDaXZtR/ZzLPLvsYfKIaa/JpBw73wi5qECfxc9B49Y0ZrQ5RT4yKj9LTLD854IBq51AVveGWMXGsp+aXhfMEJ3pHXwsx/9W3JU8gdO+pDzg2GXsBc8Sq1iJE951tx1ngQwODLQA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734676531; c=relaxed/simple; bh=zjkgX7oTkOvnJaYR9WoganUX+QyOqwPABe5PXLp/Kto=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m/l6SupoSmdYvcN9hMljUi+WnM8ytXwnLQ7j5UXInEhwR02t2EM/bUWH+THWpFnKvz3C6n2gzhA2l0i3kaSgGXuuu9fQygVSNFYPEoJ7i+7lD7ProAlDuxfgGGhJ3W+ZGA6iXGdGMwJ0bFSGfXmQyUaxPkeXPu1l3bgbpT1G1ng= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=E6f4ZyRB; arc=fail smtp.client-ip=40.107.92.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="E6f4ZyRB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ht/Ot2f/APjb8xpD0Cuc/iiK7IU2uO/WyefqZbCgO2jDG7ZqX/WafJcwPxHag51iuGcDtxJJz1++ydoSgdoMhtiayTERaWXVsoZYmfw+WJ/FM2Kb7W6rW/i+fP5SBWRCLtC7/6eh5cfqZiMLVoose6cGZ1O0UEbygC8B1vGMQHjgk2qWimvrpC2Ds0BYbGa0cux+x6aZ0p7gUmtKhUQQbwXlHoJ6vm25KMxwlUo64xx3JHf9CCEIthR/oIX8/n2lJohM9kYGgQIxcD1T5n9ksVDz0+9LUlQa+r3K+CMdQXEdhSvdhGHGjTJUMVooKA8/vWPTiIVHDxCqX3CaHbWNvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=49zHcmM+ujdQPqYTRPu5KLUIVTw9o0pIOBx8sUfcZ4U=; b=yEjP8CbIF0wL5IWf2pui3tBr5xWrQvgAshrC8J2Ahd41eCv4T0O/TeJhedUAyvchGb8c2nmGTCLCFSZeuZ4J0jRnBUAEHC7tykPx9eKXB6kiXzMkqBiaolqd2s5ABdOquMtLvK0xXJZpxLDMn0X4kBL46Z5ToxtiTSAMIg1ybI59fQE+DcJDpvdC23euGOvptNG20RiZMsS6n2yBGZvTkgM1YsrAHzDjleaAXODvYaxfvFiNJgRPq0Vqkuh/9/DLC8o2B9vngejtDO9lqyiNY3ntJBGTL5xi/KXsHQVb1F71Ch1qfGgM5/GuQN9UG38rukloH+gPgJn4xq/+bD0c0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=49zHcmM+ujdQPqYTRPu5KLUIVTw9o0pIOBx8sUfcZ4U=; b=E6f4ZyRBh/M+JFVFXsLC1w00EYhM/QPiJVyqGhoLRROusz63HEU4P0azZueEmgAOXKhY2LiqAKI0ogw07rJE/ZmdWv3Qox4NKHKY9qt6ZluS0fVt7yd9HA+F4fKgBoFCTaHZBmaIhhxSBNsXEMfIoemw/rNzpwpyj3Zbh6jNgFA= Received: from MW4P222CA0025.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::30) by LV3PR12MB9235.namprd12.prod.outlook.com (2603:10b6:408:1a4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 06:35:25 +0000 Received: from SJ5PEPF000001EB.namprd05.prod.outlook.com (2603:10b6:303:114:cafe::11) by MW4P222CA0025.outlook.office365.com (2603:10b6:303:114::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.21 via Frontend Transport; Fri, 20 Dec 2024 06:35:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001EB.mail.protection.outlook.com (10.167.242.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 06:35:24 +0000 Received: from tapi.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Dec 2024 00:35:18 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 6/6] docs: Update Schedstat version to 17 Date: Fri, 20 Dec 2024 06:32:24 +0000 Message-ID: <20241220063224.17767-7-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220063224.17767-1-swapnil.sapkal@amd.com> References: <20241220063224.17767-1-swapnil.sapkal@amd.com> 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 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EB:EE_|LV3PR12MB9235:EE_ X-MS-Office365-Filtering-Correlation-Id: 6960102b-ae32-4d88-7305-08dd20c07c60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?n2JtF1ybjWKNtr7cZ4ZVSGqJc7cK6d2juSKPeXZipazM7NTVcGHirSN6dHrq?= =?us-ascii?Q?lhsb8+MDm79UjxqmBBj4zgL8DsMerQHpz3Tr1ZGIRJlDDP5IHiUrhNeCZFJ0?= =?us-ascii?Q?I+MigMT4fNAlacSSty/NRib+uz7uV/dKa8z6b3XvoKzgkYVRozE/jgNx1yII?= =?us-ascii?Q?tmvdp3rmUWIeWg2VOfqzpl56uxEX5f0skZPB04Be1TPLj4BHOaaGntPIpgJL?= =?us-ascii?Q?NyzdetJYKvvtK8xRoupXupe3oCqffAlDcOjsIT9pxzygCK9GfO3h51z/GfDA?= =?us-ascii?Q?srNENyivRjziyClifQXCHAj6mznZ9uCxK+ufWXslSViPrNJsqANXYJHfnmEb?= =?us-ascii?Q?0XSJ2taSPy2b6ZBqDTulX03vFVXpJkF+aafQSRNqANoEn0u9hB2hLEYqyred?= =?us-ascii?Q?ZTT0IYbrGH6Dz1159r5RPuKQ9YwH1CRpdjaepKszdDsTUFtlR7S7WvcQXLi0?= =?us-ascii?Q?VSjOwdcTHEiOQ+BsFOYjYueinAYmEnOdHlTgi0sKFdxay9DkCanhm6uUdYXA?= =?us-ascii?Q?Sohmlq8Lwr4SKTodSDgGWqjH2DupFS749QOk4ej9EdvhzRt7aT+N2HGRWOrY?= =?us-ascii?Q?/pv2+PcSlA9EtzhUOeEtYDwyDEyZzxSxzl97BFLQYIy5ehf3dhYy4mo9zvZc?= =?us-ascii?Q?ceS+/Jm0nZYQVuhokgkUW8ESDcvIeKP9lbeUE0vuoTsj71i87iKzLJ7YjwBb?= =?us-ascii?Q?eOvrEnGX4yf4hX8AueLOCzjARMXZyHVPfmLEaM9qTpnGHq9mJ6Cmhksuuw3L?= =?us-ascii?Q?5xg/0yzKXsB07wF84APm44cUxGrPIlKAiHOn0lzT5KGMXfhwudYhSXS60Kp/?= =?us-ascii?Q?UD4lUNk37m31x/D67LZxiucb53zqsyuf35eC2hrESmocquMd76aG9e5L97L6?= =?us-ascii?Q?hGWBwx3pQhiinhdqshfk+bKdI52LVzuXSxQYjHjXHIjqjgNCFWctqVZrTCE9?= =?us-ascii?Q?/MDpuqH/3tUPztUlRq9nY4iF+Q5EN90z6t9afhWllOUP7rb3Fz7ymxlEP9WJ?= =?us-ascii?Q?cEqP+1moJuRodOmh4NiMtAFYxQeI3uJmw1AMu+fkyDpdI3GF7Dv6D74PxLND?= =?us-ascii?Q?hYnLCf/RbO+t0IY2Mh9fTAJiXTjncHvLfJyZyqOvhBoWuljblLD/ZCeRM0SS?= =?us-ascii?Q?7v6kMg3tEKgA4FXDVwWR7JP87nan/B/WtVDfqi17kYC4Tu4UMl7HNiZvb4V0?= =?us-ascii?Q?e2amAXmSvn1gRXvg2TviscUIpxfolZ5vZNUfxUIJrNAh9DIYeRZLMVyINM0H?= =?us-ascii?Q?LGmkVO+1X4ZSYU2kuXjdqHRFyZx89ywl+ZUPD+sY/GVFCWpz4Nz1dzZ6EgEV?= =?us-ascii?Q?KTwV3JGiS5wIur47Ab0eS715RMO12SRCq5m4uH5hhVDFSz8yRHwD+zjNSnLP?= =?us-ascii?Q?VfafA/Znuz01mhX0F39oPmOE32i0v9DW67gIUAOWmSOxAe4rqJecgTAhvhRt?= =?us-ascii?Q?oaIJOcNcCmZ2ST38V9YxXI0xoqZQwcxn+LXhvyPdLGYlbQ6rylFzpA0eNu/+?= =?us-ascii?Q?FTN9qWp2IGn4t2k=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 06:35:24.7421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6960102b-ae32-4d88-7305-08dd20c07c60 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9235 Content-Type: text/plain; charset="utf-8" Update the Schedstat version to 17 as more fields are added to report different kinds of imbalances in the sched domain. Also domain field started printing corresponding domain name. Signed-off-by: Swapnil Sapkal --- Documentation/scheduler/sched-stats.rst | 126 ++++++++++++++---------- kernel/sched/stats.c | 2 +- 2 files changed, 76 insertions(+), 52 deletions(-) diff --git a/Documentation/scheduler/sched-stats.rst b/Documentation/schedu= ler/sched-stats.rst index 7c2b16c4729d..caea83d91c67 100644 --- a/Documentation/scheduler/sched-stats.rst +++ b/Documentation/scheduler/sched-stats.rst @@ -2,6 +2,12 @@ Scheduler Statistics =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 +Version 17 of schedstats removed 'lb_imbalance' field as it has no +significance anymore and instead added more relevant fields namely +'lb_imbalance_load', 'lb_imbalance_util', 'lb_imbalance_task' and +'lb_imbalance_misfit'. The domain field prints the name of the +corresponding sched domain from this version onwards. + Version 16 of schedstats changed the order of definitions within 'enum cpu_idle_type', which changed the order of [CPU_MAX_IDLE_TYPES] columns in show_schedstat(). In particular the position of CPU_IDLE @@ -9,7 +15,9 @@ and __CPU_NOT_IDLE changed places. The size of the array i= s unchanged. =20 Version 15 of schedstats dropped counters for some sched_yield: yld_exp_empty, yld_act_empty and yld_both_empty. Otherwise, it is -identical to version 14. +identical to version 14. Details are available at + + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/D= ocumentation/scheduler/sched-stats.txt?id=3D1e1dbb259c79b =20 Version 14 of schedstats includes support for sched_domains, which hit the mainline kernel in 2.6.20 although it is identical to the stats from versi= on @@ -26,7 +34,14 @@ cpus on the machine, while domain0 is the most tightly f= ocused domain, sometimes balancing only between pairs of cpus. At this time, there are no architectures which need more than three domain levels. The first field in the domain stats is a bit map indicating which cpus are affected -by that domain. +by that domain. Details are available at + + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/D= ocumentation/sched-stats.txt?id=3Db762f3ffb797c + +The schedstat documentation is maintained version 10 onwards and is not +updated for version 11 and 12. The details for version 10 are available at + + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/D= ocumentation/sched-stats.txt?id=3D1da177e4c3f4 =20 These fields are counters, and only increment. Programs which make use of these will need to start with a baseline observation and then calculate @@ -71,88 +86,97 @@ Domain statistics ----------------- One of these is produced per domain for each cpu described. (Note that if CONFIG_SMP is not defined, *no* domains are utilized and these lines -will not appear in the output.) +will not appear in the output. is an extension to the domain field +that prints the name of the corresponding sched domain. It can appear in +schedstat version 17 and above, and requires CONFIG_SCHED_DEBUG.) =20 -domain 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 = 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 +domain 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19= 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44= 45 =20 The first field is a bit mask indicating what cpus this domain operates ov= er. =20 -The next 24 are a variety of sched_balance_rq() statistics in grouped into= types -of idleness (idle, busy, and newly idle): +The next 33 are a variety of sched_balance_rq() statistics in grouped into= types +of idleness (busy, idle and newly idle): =20 1) # of times in this domain sched_balance_rq() was called when the + cpu was busy + 2) # of times in this domain sched_balance_rq() checked but found the + load did not require balancing when busy + 3) # of times in this domain sched_balance_rq() tried to move one or + more tasks and failed, when the cpu was busy + 4) Total imbalance in load when the cpu was busy + 5) Total imbalance in utilization when the cpu was busy + 6) Total imbalance in number of tasks when the cpu was busy + 7) Total imbalance due to misfit tasks when the cpu was busy + 8) # of times in this domain pull_task() was called when busy + 9) # of times in this domain pull_task() was called even though the + target task was cache-hot when busy + 10) # of times in this domain sched_balance_rq() was called but did not + find a busier queue while the cpu was busy + 11) # of times in this domain a busier queue was found while the cpu + was busy but no busier group was found + + 12) # of times in this domain sched_balance_rq() was called when the cpu was idle - 2) # of times in this domain sched_balance_rq() checked but found + 13) # of times in this domain sched_balance_rq() checked but found the load did not require balancing when the cpu was idle - 3) # of times in this domain sched_balance_rq() tried to move one or + 14) # of times in this domain sched_balance_rq() tried to move one or more tasks and failed, when the cpu was idle - 4) sum of imbalances discovered (if any) with each call to - sched_balance_rq() in this domain when the cpu was idle - 5) # of times in this domain pull_task() was called when the cpu + 15) Total imbalance in load when the cpu was idle + 16) Total imbalance in utilization when the cpu was idle + 17) Total imbalance in number of tasks when the cpu was idle + 18) Total imbalance due to misfit tasks when the cpu was idle + 19) # of times in this domain pull_task() was called when the cpu was idle - 6) # of times in this domain pull_task() was called even though + 20) # of times in this domain pull_task() was called even though the target task was cache-hot when idle - 7) # of times in this domain sched_balance_rq() was called but did + 21) # of times in this domain sched_balance_rq() was called but did not find a busier queue while the cpu was idle - 8) # of times in this domain a busier queue was found while the + 22) # of times in this domain a busier queue was found while the cpu was idle but no busier group was found - 9) # of times in this domain sched_balance_rq() was called when the - cpu was busy - 10) # of times in this domain sched_balance_rq() checked but found the - load did not require balancing when busy - 11) # of times in this domain sched_balance_rq() tried to move one or - more tasks and failed, when the cpu was busy - 12) sum of imbalances discovered (if any) with each call to - sched_balance_rq() in this domain when the cpu was busy - 13) # of times in this domain pull_task() was called when busy - 14) # of times in this domain pull_task() was called even though the - target task was cache-hot when busy - 15) # of times in this domain sched_balance_rq() was called but did not - find a busier queue while the cpu was busy - 16) # of times in this domain a busier queue was found while the cpu - was busy but no busier group was found =20 - 17) # of times in this domain sched_balance_rq() was called when the - cpu was just becoming idle - 18) # of times in this domain sched_balance_rq() checked but found the + 23) # of times in this domain sched_balance_rq() was called when the + was just becoming idle + 24) # of times in this domain sched_balance_rq() checked but found the load did not require balancing when the cpu was just becoming idle - 19) # of times in this domain sched_balance_rq() tried to move one or = more + 25) # of times in this domain sched_balance_rq() tried to move one or = more tasks and failed, when the cpu was just becoming idle - 20) sum of imbalances discovered (if any) with each call to - sched_balance_rq() in this domain when the cpu was just becoming i= dle - 21) # of times in this domain pull_task() was called when newly idle - 22) # of times in this domain pull_task() was called even though the + 26) Total imbalance in load when the cpu was just becoming idle + 27) Total imbalance in utilization when the cpu was just becoming idle + 28) Total imbalance in number of tasks when the cpu was just becoming = idle + 29) Total imbalance due to misfit tasks when the cpu was just becoming= idle + 30) # of times in this domain pull_task() was called when newly idle + 31) # of times in this domain pull_task() was called even though the target task was cache-hot when just becoming idle - 23) # of times in this domain sched_balance_rq() was called but did not + 32) # of times in this domain sched_balance_rq() was called but did not find a busier queue while the cpu was just becoming idle - 24) # of times in this domain a busier queue was found while the cpu + 33) # of times in this domain a busier queue was found while the cpu was just becoming idle but no busier group was found =20 Next three are active_load_balance() statistics: =20 - 25) # of times active_load_balance() was called - 26) # of times active_load_balance() tried to move a task and failed - 27) # of times active_load_balance() successfully moved a task + 34) # of times active_load_balance() was called + 35) # of times active_load_balance() tried to move a task and failed + 36) # of times active_load_balance() successfully moved a task =20 Next three are sched_balance_exec() statistics: =20 - 28) sbe_cnt is not used - 29) sbe_balanced is not used - 30) sbe_pushed is not used + 37) sbe_cnt is not used + 38) sbe_balanced is not used + 39) sbe_pushed is not used =20 Next three are sched_balance_fork() statistics: =20 - 31) sbf_cnt is not used - 32) sbf_balanced is not used - 33) sbf_pushed is not used + 40) sbf_cnt is not used + 41) sbf_balanced is not used + 42) sbf_pushed is not used =20 Next three are try_to_wake_up() statistics: =20 - 34) # of times in this domain try_to_wake_up() awoke a task that + 43) # of times in this domain try_to_wake_up() awoke a task that last ran on a different cpu in this domain - 35) # of times in this domain try_to_wake_up() moved a task to the + 44) # of times in this domain try_to_wake_up() moved a task to the waking cpu because it was cache-cold on its own cpu anyway - 36) # of times in this domain try_to_wake_up() started passive balanci= ng + 45) # of times in this domain try_to_wake_up() started passive balanci= ng =20 /proc//schedstat --------------------- diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c index 5f563965976c..4346fd81c31f 100644 --- a/kernel/sched/stats.c +++ b/kernel/sched/stats.c @@ -103,7 +103,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 16 +#define SCHEDSTAT_VERSION 17 =20 static int show_schedstat(struct seq_file *seq, void *v) { --=20 2.43.0