From nobody Sat Nov 23 15:20:29 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) (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 BAD2614F9ED for ; Tue, 19 Nov 2024 05:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995114; cv=fail; b=Y2CRDJnGH9CJCmXtqNU93sRcVnzGV1LV1Xzov0hNHH/Qa+12Vg0J7mWX1uyG8CyquiUYcqJEvx+15q+Wua72WPA/JHmU/KU5Yhw/sEZ8WtworfwUz+isF/WRLOnq0iv659QmyVZzwA2E5TBtj8Vs1z0eutBZM2aRPD2rHpbDTFw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995114; c=relaxed/simple; bh=NvfdD13FXBIn9W9vCLjDQooZjd7O+lCkzQ03b/5XHiM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=US6/zzEtnrn3FTstb9Xgg8v+F+EjH26bO1MpuWvV0nXxffim5UBMJ3WKth+ZG/mSOM118VFsyahpq6OzBv5KxU98ilN1ktWbfGhsp7TSITaBkZKQBhU71jAFpgA/jEbxUZrbTN7UPD+uOlblng8X1/raE6UEggGREg+VQQIwlPY= 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=xiBvEiqK; arc=fail smtp.client-ip=40.107.92.42 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="xiBvEiqK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aAGUTmESuRFDbuAUt5dbWowPNFtK3NB9TM9p9jrQ7P8UQYM1Hv714FIZkLlXGNPr4y4Rifc0OKAVJq0vFBzS+wHoH9G2ZfVjxinMyi3kMfKjH2TmJK/JWV20MCU3lTiJd/ZrI4v1TkqK/7culgX0Bll/+VmAh/yZLJ1AjtqG/j8hV5C85Br82pN8az9/yIfWEGk0AzjcAq5GpxTyGbSdoH3j1E2axw5QriaD4QezNf5ua3Uuno8YYiXs2B+vhqNJWSlunZbxHG/I+q/enJRMX3jgHCEGhceSVAX8+G+bG9qDQavsi1BMsnI++8ktDVvxVCObd3VQ8cy1WHmfhAQw2A== 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=mq3KQ0DIfJbjbunTTs1DC/IYbEaojIfXvZ4R4dEbRpk=; b=S4lcoN+YUg4YjjrJVaM2NTZxOqumgcxhquQHIHYxnnT9g5CmzGnu/ImhpaS0Ie9wPoQbxBPhPpGMunA5HNxuccXi2jgHmWBKjWrMmB4d6WBaHHraoxouzT0a1svEdrAFs5JinX2bC03yrELKcRr9NTb8z6z6dM/Mi56w2wlF/j2UJl8HVwSCNcIPGg/odmhhweMU79AV5MTdCGRaMtOFEu3kpkI2sf5yMh1b1x1LPn74HOWVJvMmQzKxbq0vR0/QodaMyNuWbRkARMZrSOi+u2eCqxX/MScoENM3h8bgK2cyXGcFPKaVdhRRKIs44kMwVKfig12/kjbjXKycuxPp5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com 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=mq3KQ0DIfJbjbunTTs1DC/IYbEaojIfXvZ4R4dEbRpk=; b=xiBvEiqKzf6FQhgWTbHvQIby6/fCV4zyhiOjtfhMCqc/p/aiqNlIMf3+Sw9AgOeBRw51QAeU2UECYIQug+JRi6k6gjm0EOJ30n5EwzRIUqZNaAuGGWIdWNYMBjJmPd6uVhboAVCrzUAmmpRabBKPKee27/9ToYWkYrMXQX8MIc4= Received: from SJ0PR03CA0379.namprd03.prod.outlook.com (2603:10b6:a03:3a1::24) by DM4PR12MB6592.namprd12.prod.outlook.com (2603:10b6:8:8a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Tue, 19 Nov 2024 05:45:07 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::ad) by SJ0PR03CA0379.outlook.office365.com (2603:10b6:a03:3a1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 05:45:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 05:45:06 +0000 Received: from BLRKPRNAYAK.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; Mon, 18 Nov 2024 23:44:59 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Sebastian Andrzej Siewior , Clark Williams , "Steven Rostedt" , , CC: Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , Thomas Gleixner , Tejun Heo , NeilBrown , Jens Axboe , Frederic Weisbecker , Zqiang , Caleb Sander Mateos , "Gautham R . Shenoy" , Chen Yu , Julia Lawall , K Prateek Nayak Subject: [PATCH v5 1/4] softirq: Allow raising SCHED_SOFTIRQ from SMP-call-function on RT kernel Date: Tue, 19 Nov 2024 05:44:29 +0000 Message-ID: <20241119054432.6405-2-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241119054432.6405-1-kprateek.nayak@amd.com> References: <20241119054432.6405-1-kprateek.nayak@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: CY4PEPF0000E9D0:EE_|DM4PR12MB6592:EE_ X-MS-Office365-Filtering-Correlation-Id: b3aee976-1433-445f-f939-08dd085d52d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s0U3NAu/yDD85WRFaoedgK/51LDl/ikveC7908qaLsStcR6JM52vx1X8SV3x?= =?us-ascii?Q?kggutFcSE53Nw6j4a7ujBYCu1XYonAjtQCTd6ibqduYmoDAJNg+Sv8bdKRDk?= =?us-ascii?Q?eZ358fpFvl8jMw+LM0yjVMrYahPmpFE8bwnKu92O2YjgfFEo6imU58eLeB/j?= =?us-ascii?Q?a+in8vu4uvve/PI6UTUiqRqZrGEOHiCnJ2AYFSMBfFn/h4FXmIjYiad4JWFA?= =?us-ascii?Q?eBNFIVP9uv5PGfKi0IUfmV6bZXFXK9O28hadaHQ23tmtT4jUkG1uhF6Bvbzg?= =?us-ascii?Q?rZJ74LcEZizR/YpyT2Q9z6nHOpfIZKXgyBvS8RsQPHfwNTsemzpDOPK8rd8K?= =?us-ascii?Q?dot9iNDguapoBmylIyFawQFdV9rczQuzT0K+ziTH8FPrNCMgzDVcN6XR3mhg?= =?us-ascii?Q?6Pf6ShL9OwYC77aawenU0Uto699LdOz0GnS+KHM2LH2n+9J6NoEQFky35yan?= =?us-ascii?Q?jM5phiXDEmLMWNlwTmiXKfi5wvy4lb8cx0XWF+92f2uMeeKijRzCsdXW4v4g?= =?us-ascii?Q?vXZeBV+axaBy+5qJDYHbG63Qm67ngJ+SjZ8RJ3boHY41YiaVHEurphoIjihw?= =?us-ascii?Q?y+VcCYaxKR0Ts6DDtppDFsaXC8oqh81C4Dl7jYnvOYtGk84y5Oepx0LGBMKZ?= =?us-ascii?Q?AW9m2cgjwty9LDMLj+lA4/JvnHvhv/TvYWtOPJzw3X89ckh5bmGq6HNm5UNX?= =?us-ascii?Q?jICyHbp+3VKbKId2WgdBOjlayBk3aRywzLZ5cyJOaxZzpX3sxrcUfTjC9/UN?= =?us-ascii?Q?av90CT/0zM/l4GWC2m1ADbrNLfnPVvN1xRxtdYwX0q4bizSjp6hxFwEQQNyS?= =?us-ascii?Q?9RjLmj2CXUD6/3ykWrzvvqj9ZkjqUVou3wtxBJ/oeEJTnygP8YSdM8nxwY2r?= =?us-ascii?Q?15tFrutYAFhEE6+1JE0SmeV/Z2lUoUZFg/732eh7bgExTbL/WID6StINOenB?= =?us-ascii?Q?h5b4fO/6AplljSo9Y8PN5J4zImzaMMJlwRcZOC2znEsMzikd/u46qHOFbUYo?= =?us-ascii?Q?F6hGiFCsRZ0lEs1n7kB1fHg9kLemahVOLV52TvC5yI/N2Ckqjawej15r1hhG?= =?us-ascii?Q?UZ76C0oOnxrfKgzNZ0+y02LCM1gr2TrqI/eh/87WDZhnk5s5oZij3te9Z2ZF?= =?us-ascii?Q?Q+QGRfugtEB4onu0t2G9ZwNCjinvuG+FCZEPnO4mESGfF68TsTHRZF0br041?= =?us-ascii?Q?ioewMK+pQ5a5eEtv9tlMeLE7GI5n5YuPyqmdEwbikCWU0q6h88KkJN9boAlg?= =?us-ascii?Q?5CHW8XN+KX3ppgPLs06mIQwYW/0Vn2ITwmOQKdfAZh088AQnyvxFhg4Row2U?= =?us-ascii?Q?gm/g7ktFIVlehBZq4v73sefy8alI7EuxdBprjhyCHSOK3ciFXj8Ebksln2pS?= =?us-ascii?Q?9OnFsZUFmSBfPsKc0hOeD+EFNi2R5wp38xsqqWP8Msk/sWkJ9g=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 05:45:06.9535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3aee976-1433-445f-f939-08dd085d52d8 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6592 Content-Type: text/plain; charset="utf-8" do_softirq_post_smp_call_flush() on PREEMPT_RT kernels carries a WARN_ON_ONCE() for any SOFTIRQ being raised from an SMP-call-function. Since do_softirq_post_smp_call_flush() is called with preempt disabled, raising a SOFTIRQ during flush_smp_call_function_queue() can lead to longer preempt disabled sections. Since commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") IPIs to an idle CPU in TIF_POLLING_NRFLAG mode can be optimized out by instead setting TIF_NEED_RESCHED bit in idle task's thread_info and relying on the flush_smp_call_function_queue() in the idle-exit path to run the SMP-call-function. To trigger an idle load balancing, the scheduler queues nohz_csd_function() responsible for triggering an idle load balancing on a target nohz idle CPU and sends an IPI. Only now, this IPI is optimized out and the SMP-call-function is executed from flush_smp_call_function_queue() in do_idle() which can raise a SCHED_SOFTIRQ to trigger the balancing. So far, this went undetected since, the need_resched() check in nohz_csd_function() would make it bail out of idle load balancing early as the idle thread does not clear TIF_POLLING_NRFLAG before calling flush_smp_call_function_queue(). The need_resched() check was added with the intent to catch a new task wakeup, however, it has recently discovered to be unnecessary and will be removed in the subsequent commit after which nohz_csd_function() can raise a SCHED_SOFTIRQ from flush_smp_call_function_queue() to trigger an idle load balance on an idle target in TIF_POLLING_NRFLAG mode. nohz_csd_function() bails out early if "idle_cpu()" check for the target CPU, and does not lock the target CPU's rq until the very end, once it has found tasks to run on the CPU and will not inhibit the wakeup of, or running of a newly woken up higher priority task. Account for this and prevent a WARN_ON_ONCE() when SCHED_SOFTIRQ is raised from flush_smp_call_function_queue(). Signed-off-by: K Prateek Nayak --- v4..v5: - More clarification in the commit log around idle load balancing (last paragraph) --- kernel/softirq.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/softirq.c b/kernel/softirq.c index 7b525c904462..03248ca887b5 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -280,17 +280,24 @@ static inline void invoke_softirq(void) wakeup_softirqd(); } =20 +#define SCHED_SOFTIRQ_MASK BIT(SCHED_SOFTIRQ) + /* * flush_smp_call_function_queue() can raise a soft interrupt in a function - * call. On RT kernels this is undesired and the only known functionality - * in the block layer which does this is disabled on RT. If soft interrupts - * get raised which haven't been raised before the flush, warn so it can be + * call. On RT kernels this is undesired and the only known functionalities + * are in the block layer which is disabled on RT, and in the scheduler for + * idle load balancing. If soft interrupts get raised which haven't been + * raised before the flush, warn if it is not a SCHED_SOFTIRQ so it can be * investigated. */ void do_softirq_post_smp_call_flush(unsigned int was_pending) { - if (WARN_ON_ONCE(was_pending !=3D local_softirq_pending())) + unsigned int is_pending =3D local_softirq_pending(); + + if (unlikely(was_pending !=3D is_pending)) { + WARN_ON_ONCE(was_pending !=3D (is_pending & ~SCHED_SOFTIRQ_MASK)); invoke_softirq(); + } } =20 #else /* CONFIG_PREEMPT_RT */ --=20 2.34.1 From nobody Sat Nov 23 15:20:29 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) (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 6EEB4142E7C for ; Tue, 19 Nov 2024 05:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995131; cv=fail; b=YTZy8Aa9Z1FTv2aKd8CBUws1xU6V+vLjOwN8jFAFINOgv8m9Nk9aq/C8EP0lSJZfOHir7kAEdcrKyhZsNpddfCAJUhyxGOx8dslpIEsQLZjgZDd2loIeTwVfHvw97XP6Vz7l2f/dz58C0L2O0ITwh03U2TCARa+PvTdoiaQWAMQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995131; c=relaxed/simple; bh=mmRXaZNEQFU51tq28QzU/6x5g+wfSEl+GY4wPLtqtBw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SK+ihFucFzobyaAC+jN1GO0KgZBgrZGL/OfSmpDMXFRYY63PosNatrUFEsqI5YfXuO5EwKGSg8CCxrTxQQpSeXlpqGrAIL4px6HhbxlvAVY/oNLaCPvpAtL3cmIKDGJuOmGIoq/HT7ur4ccg7+sQQvHhamUsYtxLbyTvhYER3p0= 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=079TZUtj; arc=fail smtp.client-ip=40.107.243.89 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="079TZUtj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xK5jbM2H1yiowAcgNgPRhPzLnoqslLK+Aks3RW9XgZB3ov7ALAaFWbO1mHyw2fF6dQeaswhxO9hWfSO6Ysk+u+G5FVrnhArnrJPHEJpLcUCmeyN3Gct9zCREdVJmmHDL/mJ9WgQjsc2yqToLlxp9W8RwEA2qUnE8pm5xOeDmgyO3HQPVuX3PsxVhk5OswtSyGpkx+T7NAVFj4y0hTohg5J5401D2qbMibTcNf4s5D0ODuNL4sZWvL0vOLO9EEfP7ArMlloC1PXrIJ+BvPqTBIVjMcaLdO2r2ktXVQjNrzxH64bSgFI5WT0q2oulq34r+ZxjaKLEvjyrQQ6lC6Yw3Hw== 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=VHbaCb8/wLcrTiweWDcgpXY+NJBc0ZRZBrBOxVOrQCA=; b=IV4rW4o23NbN7eywfP4gOQcPc8TrIcZEr4tw8+VYyPXaiO397eACND69GZ42JJ8sjFSDMX3H0DGxb4RCSao/CgmEOtAkQY0lt6klwWAynFaJgFvZ4X1/EDuYCKDRleIgMEa3uSpapwD7ci87SZjPVDLsoWF+SMF0Tm+jCgslqYLfxDU/s0MOHTkSLJa7tbwOQP0ISoZubkSHO+zwqdWX+nIVMfMnZOmNi1J/WDLNlFD9IuaC+pxXspRNDONbxHUhfACTlVzhGX3eI/0/OHSdjyq/bXd/AG88+m0jsdOqU4haMUlWcqVlnEF5530WSShGrlS4KnUcDzIwAnDLmpMcww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com 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=VHbaCb8/wLcrTiweWDcgpXY+NJBc0ZRZBrBOxVOrQCA=; b=079TZUtjsiZxX/ac17VFKqqE9q9CS/kAottQzQpI675aWpZOt1ltR0Nch6dDPrhewrcVJ8re0AaNIR3E8p5oJxlbAnblpq/LFNSN23dGtrd4YzfHi8o0RrsxaIHNz4VLJ2viiVJ+0rgclji46/J/vXBYtLK6DyooNTLcHMfPp5k= Received: from SJ0PR13CA0086.namprd13.prod.outlook.com (2603:10b6:a03:2c4::31) by MW4PR12MB6899.namprd12.prod.outlook.com (2603:10b6:303:208::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 05:45:26 +0000 Received: from CY4PEPF0000E9D4.namprd03.prod.outlook.com (2603:10b6:a03:2c4:cafe::c1) by SJ0PR13CA0086.outlook.office365.com (2603:10b6:a03:2c4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.13 via Frontend Transport; Tue, 19 Nov 2024 05:45:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000E9D4.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 05:45:25 +0000 Received: from BLRKPRNAYAK.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; Mon, 18 Nov 2024 23:45:19 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Sebastian Andrzej Siewior , Clark Williams , "Steven Rostedt" , , CC: Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , Thomas Gleixner , Tejun Heo , NeilBrown , Jens Axboe , Frederic Weisbecker , Zqiang , Caleb Sander Mateos , "Gautham R . Shenoy" , Chen Yu , Julia Lawall , K Prateek Nayak Subject: [PATCH v5 2/4] sched/core: Remove the unnecessary need_resched() check in nohz_csd_func() Date: Tue, 19 Nov 2024 05:44:30 +0000 Message-ID: <20241119054432.6405-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241119054432.6405-1-kprateek.nayak@amd.com> References: <20241119054432.6405-1-kprateek.nayak@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: CY4PEPF0000E9D4:EE_|MW4PR12MB6899:EE_ X-MS-Office365-Filtering-Correlation-Id: 1768d2e3-643b-467b-fd8d-08dd085d5e2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cxX1bSnt33TZzuQZR/P82KQ9iyxS/Y78PyFSqRuQAZ8mA6bSD45v4Hq+PtSn?= =?us-ascii?Q?5truU/MeixMEqTJjYN/LMICX3V7sjd8Nf12vCgL5KeYKdnmRK5EsmMyXmvEP?= =?us-ascii?Q?UlZSXvmt0/xlhnF16xlmGgtaSNwc2vlq/ISK0IcdsdGl0LFvgo7+ehye+4ZG?= =?us-ascii?Q?qShYcn6jRx92YU028bOGv/Z+mlArar6WNnmFKRmmPJPLxeQcOQNcUeLY7C6f?= =?us-ascii?Q?eSA3WeZtl8CWeiYsNH1dO/F0yuRKIAUi7RKofVAzgjis5NlUleECjH8pCx/t?= =?us-ascii?Q?ZAsn7bjN7Bxb/gTTvAIscPkWk0GhPe1Xb8NKDxEed0fJJc6DW8a9sOlpw5yx?= =?us-ascii?Q?tZdCs799oQmtsmPM4PfmRD1fbrsflPNesOoRz/kzEHQCiVV1fXn1MtUsyHgd?= =?us-ascii?Q?wE+D+L3/ReL84UDNN9ZHCzjMvVIPIriOyCzAmH4c+k21LcfIICRb0Sh0vzej?= =?us-ascii?Q?9pW1ASE7P+dJQp0i3sBregmiys2uB9cd0YxUx3ENqzC1iJJQVSe9PJzvzXu7?= =?us-ascii?Q?31/rrnjqpv2unKZAt0jKU4g4QV71srqYfHsGQO5kaQh7zQ0V7aERPAwQNQzf?= =?us-ascii?Q?EgQtxraaU5NW35IdTreTpwEIAEtPlxG2vL3D7KuHCbcyf32v8oLwUvxu4lYX?= =?us-ascii?Q?33sv7ipKP0YTXRIph6Ln9XfuYkHNSLnFBcofuHY8jGYrz0F+6e+sMk+W95i+?= =?us-ascii?Q?LOjUx6UtfSPGms1q/8dUAzlNBoGepUEKrpPk1zVZgvCunlIlbFWyMAmhJlv7?= =?us-ascii?Q?6l4cyiR17VbLqwL3OrQAdBjtUILVpGZW8HVoe7/6riOzxoJNWuzweJgZseXH?= =?us-ascii?Q?TUYbDiyAs0lL9BFW/5ncz34tTtkcXBlDBlCLCd6iy+C/Bnolqkxq03X6+dZq?= =?us-ascii?Q?8EQIJ6846h3Bw8t6hbMUwk05KO7nvh2kiv/QJKYSmrJtOVBjdATQCuSCQS/p?= =?us-ascii?Q?6en6f3z+114voYIXG/YTOCqUAZ2zZao7KPJ5129wxFN4cEV+tAkBW1Wecj6s?= =?us-ascii?Q?fcViFQS8gtNFIw/bWTCg6xyhCAk+rUqm4XFMJa7GrPrmQUlUW5ZUg1J4aLg5?= =?us-ascii?Q?MN5yPdtIi8lM9VpPleZkby8Mb6OHahBfOSDEmx6AF8O1YKY6759W8LCMtba+?= =?us-ascii?Q?EXZGW32ndNAaiysgCGEO5LcmqeqgJ7pNWBUxmdf9QV8P2HVK1HjBMhjm/whu?= =?us-ascii?Q?PwK+BksRJPPbDJ+VRTO7/qq/PwNLPI+A4hLZp1S/rVrlBAs7jcscHHONzLSy?= =?us-ascii?Q?eaHCzdzfiVf7Z6aRgldhhrbKb7Qgk3EGPp6sopKVigYgXTs48K5KfpKydSDl?= =?us-ascii?Q?yZsfvXhRG3HRQ4mPuG1vXLc2RuOnA9FGZC6+25X5w2pLfmoHk8imqn9ml8+e?= =?us-ascii?Q?PzzG+FVD0qjyCgESqBdtpG1KRUqrQF2lpmv038RctFcJYg47RwyA1N9Lw4ma?= =?us-ascii?Q?SzISK41j/6c=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 05:45:25.9656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1768d2e3-643b-467b-fd8d-08dd085d5e2d 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6899 Content-Type: text/plain; charset="utf-8" The need_resched() check currently in nohz_csd_func() can be tracked to have been added in scheduler_ipi() back in 2011 via commit ca38062e57e9 ("sched: Use resched IPI to kick off the nohz idle balance") Since then, it has travelled quite a bit but it seems like an idle_cpu() check currently is sufficient to detect the need to bail out from an idle load balancing. To justify this removal, consider all the following case where an idle load balancing could race with a task wakeup: o Since commit f3dd3f674555b ("sched: Remove the limitation of WF_ON_CPU on wakelist if wakee cpu is idle") a target perceived to be idle (target_rq->nr_running =3D=3D 0) will return true for ttwu_queue_cond(target) which will offload the task wakeup to the idle target via an IPI. In all such cases target_rq->ttwu_pending will be set to 1 before queuing the wake function. If an idle load balance races here, following scenarios are possible: - The CPU is not in TIF_POLLING_NRFLAG mode in which case an actual IPI is sent to the CPU to wake it out of idle. If the nohz_csd_func() queues before sched_ttwu_pending(), the idle load balance will bail out since idle_cpu(target) returns 0 since target_rq->ttwu_pending is 1. If the nohz_csd_func() is queued after sched_ttwu_pending() it should see rq->nr_running to be non-zero and bail out of idle load balancing. - The CPU is in TIF_POLLING_NRFLAG mode and instead of an actual IPI, the sender will simply set TIF_NEED_RESCHED for the target to put it out of idle and flush_smp_call_function_queue() in do_idle() will execute the call function. Depending on the ordering of the queuing of nohz_csd_func() and sched_ttwu_pending(), the idle_cpu() check in nohz_csd_func() should either see target_rq->ttwu_pending =3D 1 or target_rq->nr_running to be non-zero if there is a genuine task wakeup racing with the idle load balance kick. o The waker CPU perceives the target CPU to be busy (targer_rq->nr_running !=3D 0) but the CPU is in fact going idle and due to a series of unfortunate events, the system reaches a case where the waker CPU decides to perform the wakeup by itself in ttwu_queue() on the target CPU but target is concurrently selected for idle load balance (XXX: Can this happen? I'm not sure, but we'll consider the mother of all coincidences to estimate the worst case scenario). ttwu_do_activate() calls enqueue_task() which would increment "rq->nr_running" post which it calls wakeup_preempt() which is responsible for setting TIF_NEED_RESCHED (via a resched IPI or by setting TIF_NEED_RESCHED on a TIF_POLLING_NRFLAG idle CPU) The key thing to note in this case is that rq->nr_running is already non-zero in case of a wakeup before TIF_NEED_RESCHED is set which would lead to idle_cpu() check returning false. In all cases, it seems that need_resched() check is unnecessary when checking for idle_cpu() first since an impending wakeup racing with idle load balancer will either set the "rq->ttwu_pending" or indicate a newly woken task via "rq->nr_running". Chasing the reason why this check might have existed in the first place, I came across Peter's suggestion on the fist iteration of Suresh's patch from 2011 [1] where the condition to raise the SCHED_SOFTIRQ was: sched_ttwu_do_pending(list); if (unlikely((rq->idle =3D=3D current) && rq->nohz_balance_kick && !need_resched())) raise_softirq_irqoff(SCHED_SOFTIRQ); Since the condition to raise the SCHED_SOFIRQ was preceded by sched_ttwu_do_pending() (which is equivalent of sched_ttwu_pending()) in the current upstream kernel, the need_resched() check was necessary to catch a newly queued task. Peter suggested modifying it to: if (idle_cpu() && rq->nohz_balance_kick && !need_resched()) raise_softirq_irqoff(SCHED_SOFTIRQ); where idle_cpu() seems to have replaced "rq->idle =3D=3D current" check. Even back then, the idle_cpu() check would have been sufficient to catch a new task being enqueued. Since commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") overloads the interpretation of TIF_NEED_RESCHED for TIF_POLLING_NRFLAG idling, remove the need_resched() check in nohz_csd_func() to raise SCHED_SOFTIRQ based on Peter's suggestion. Link: https://lore.kernel.org/all/1317670590.20367.38.camel@twins/ [1] Link: https://lore.kernel.org/lkml/20240615014521.GR8774@noisy.programming.= kicks-ass.net/ Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") Suggested-by: Peter Zijlstra Signed-off-by: K Prateek Nayak --- v4..v5: - No changes. --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 43e453ab7e20..424c652a9ddc 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1237,7 +1237,7 @@ static void nohz_csd_func(void *info) WARN_ON(!(flags & NOHZ_KICK_MASK)); =20 rq->idle_balance =3D idle_cpu(cpu); - if (rq->idle_balance && !need_resched()) { + if (rq->idle_balance) { rq->nohz_idle_balance =3D flags; raise_softirq_irqoff(SCHED_SOFTIRQ); } --=20 2.34.1 From nobody Sat Nov 23 15:20:29 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) (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 CF72311CA0 for ; Tue, 19 Nov 2024 05:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995151; cv=fail; b=uyYmhfj5Oba66ddOQU8auOV+NDbaHs6Ln1vgWb0G03TaFIUPKxHw9oc53Q1cJIe+zFzbyIRr4N6xD9982wE2ySx3AQApn4y3cGj2hxW6Z3SemiOyc8/mv9IC9QN3+MCz6QXu6vcNqe3az7J/33S1npTwkolcaZ27zNEkHoPo2DE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995151; c=relaxed/simple; bh=MOSwCEVScRBGxjHxi9jQzzkIWqmKmrg7wW2CnkCTk68=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pi/mfmB1jDSA3GepQ0+2b6/lOg3ob4SghnIVTYmN6aPG29wSvpvUuh57hXq0V42n3bVV1SjSi8hHWdaT41vdww4GcJZSAGzeWDdB6VtTt1ylKPoqGitRfQv8YFL4LHDC2U35UxLfuFV1fVZ3lfayQuzvzLmDMuPHiQc5XLkGZDo= 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=Fm8grh/m; arc=fail smtp.client-ip=40.107.92.83 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="Fm8grh/m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RxWtC2DxiI8ZoSTJHUNMFEa9ly4ZKEliCq08fCgKrYYapmFsB0HwQ6K37QKvpy2ze1/xMhAlKDQbaBYoTh+fMhLybDS5+h/oK35PoZg8otDF1+Pc9bLN/vMJcrj+c+zFf/RfR2i1fXSj20EF5aItoxGBwXsxJtER/nYtTxtpvwHBLb+FU70AdxECWX+Yp1z9Y3PoPItu9fNmyjY2zYJvj142USymNV4BmibrEyT+Dc2TZSMFqDYbU+WvEqa4LEwv4E0leQz+9NHHqa43E4S57yjwNkVIzU+/a0wy4KlUexsqMPYJZruBjEs32y7R+yU6vqNfdT+DKNyArxmPzmQ1Gg== 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=WS9hm/KjUWl+Wpcw5jNpBeKzC1ALZbApj+pKBhsvbYg=; b=u2AkzO8gZUnkYvcKS4HUSExWx6/Fwo6GqVQx0RJFHX9y1ZRuWH549/M42b+e9OtBuOVcGtizNpKwo0Z82j6CZbdjpdpm1fnh1LkdetVEXhC/KqymXcgOssfNoxUXuX45tn6UuEgis9CS4Uaif7tozRg9v5Fviedve0WP+8hr5zz+NB0eRx4yGUPw5OiDVS6HKlmLoMgHtO7qVmk8PuwnSkgSlZv9tS1oJ2nB0vD8QuvRVvC3gRR7MuyCkqLfWBAjniGdeT+24uRe926FhJGuVcIXI7hJFipX0yBgIXCnlL1Mh2Ec3n1HeqoOesOCB9OpcVwXPm5EkoF/oFZU6xH2LA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com 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=WS9hm/KjUWl+Wpcw5jNpBeKzC1ALZbApj+pKBhsvbYg=; b=Fm8grh/mkqCXW2PBR7ZUlvu4WByhVVF/BVKxbqHng1HFdVdLU3yK72TVQ6Z1zCImBfyriS1puMyfeiSK5jdFXgT+/AG6XmAlfKtHGAdo+IZboohVFV7a1MWFTMLK9ZRTf5a1NBsufR93aNeCNwlZuOVdeRXl9evtzWYOmNs1eVM= Received: from SJ0PR03CA0385.namprd03.prod.outlook.com (2603:10b6:a03:3a1::30) by MW5PR12MB5600.namprd12.prod.outlook.com (2603:10b6:303:195::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 05:45:46 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::58) by SJ0PR03CA0385.outlook.office365.com (2603:10b6:a03:3a1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Tue, 19 Nov 2024 05:45:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 05:45:45 +0000 Received: from BLRKPRNAYAK.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; Mon, 18 Nov 2024 23:45:38 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Sebastian Andrzej Siewior , Clark Williams , "Steven Rostedt" , , CC: Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , Thomas Gleixner , Tejun Heo , NeilBrown , Jens Axboe , Frederic Weisbecker , Zqiang , Caleb Sander Mateos , "Gautham R . Shenoy" , Chen Yu , Julia Lawall , K Prateek Nayak Subject: [PATCH v5 3/4] sched/fair: Check idle_cpu() before need_resched() to detect ilb CPU turning busy Date: Tue, 19 Nov 2024 05:44:31 +0000 Message-ID: <20241119054432.6405-4-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241119054432.6405-1-kprateek.nayak@amd.com> References: <20241119054432.6405-1-kprateek.nayak@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: CY4PEPF0000E9D0:EE_|MW5PR12MB5600:EE_ X-MS-Office365-Filtering-Correlation-Id: c4002bed-e9dd-46ce-7c5f-08dd085d69c4 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?QimA3z+FRIE39+T8yUdNnIXcMAHOr3ELbvzNu41fLLuftO5c1stTwzB8aCFm?= =?us-ascii?Q?JVTxUolP9MeN0wwToq+/SC3ygHzlDvE2gh1gcxb8v3K3wYExfvUB+Qj0X6BO?= =?us-ascii?Q?CU8uC0qmR68qYnO7hvacxKUKyWkxgzr4Nk8MDUDbv0JpZZ/FrnCsf98cD9yA?= =?us-ascii?Q?1NJoKrl5z95ylWeurhioidOMBY9EyQ52r9ytKj0DmnvmEj54ceK147e4H1VY?= =?us-ascii?Q?iojssKrEMY7AEj5QIxhu7JmpoRnLFvPaqFa2zcu0RKCefZxTXk7uQ/VZ1zQK?= =?us-ascii?Q?2Kfbkr2mPYDJgn5/4RLCaxe1kmn8KYXJfVQaAoaUSbpSUH9Y2pyB5bo1U/cy?= =?us-ascii?Q?OLzOhhNZ0SWDmSqHXtID5mJDH6a9QVX50PVF7fSsvx0bcagKOdBZyxqvpM9P?= =?us-ascii?Q?ga1f1knfoX938QrJvUzIjrCDcPBu/wvzymEkzOtBzxB0OMLVi41uaf0S136K?= =?us-ascii?Q?xRvnTohtcHcCyDA3HgGEGrK7dmAUE84ww7JSVqdcF8tX2PGZtc5E96uCh4CO?= =?us-ascii?Q?TVMJWnC/GHlYSd/cquiY+JGw3ZHSTsa2Frx1mtveyVxRAZ7V2VQT6qpIbIjk?= =?us-ascii?Q?7VDzpV6E3vj4cFw8ef4xAwOw+17M5liRHq/XbtZPQymCjSehQ64Gy0TR78Uc?= =?us-ascii?Q?0Y+jNLyAtLMfW78DOG3cas3p+7CXYpFvlaWNa0vl9/tYDA7QNfnMEXNDx3Tp?= =?us-ascii?Q?SsThOnVuwBLaRyYTENPoe+aLcpnSDIrJYNdTFVWGHsS88rzpmylSLG7S/5xR?= =?us-ascii?Q?v774SHvqYdTOIy5aRnHY862yVEpjNOl0wqm2lCaZrqIwMbqO6fAMSWBdyBza?= =?us-ascii?Q?S8bSZs2boFs+dmsGcrgoHnBCZSpGMU3ne5n73W7YpZ1gKUFDQkGT0jQ80dFD?= =?us-ascii?Q?BJgBZjYFLoBP80CR+4UTXivvX6JhxxR7pQvMdAA7W+wncyiUFIdhrjCddG7B?= =?us-ascii?Q?stXRHMxV341ikYLY7HZyG2uKv+McWWim73AX2Fhwts7ioBHCamGBmPhtPb30?= =?us-ascii?Q?9wFov9Acv1dXcmvg1cRc2boiVLswSsJXrgqZ73EskNNXD9x6K492NrZR0GPG?= =?us-ascii?Q?h3UuqpCvyMN+gCL9KVmVqsfEiOBWlX3PBwR9W82Ptp/uNz84Rh4uNtSTJbAy?= =?us-ascii?Q?4qVvvPVXwWQ3hbyyA0qDrW58JyhL6v0NT7tXp42IkeGhcP/57Y0CNqd70fjz?= =?us-ascii?Q?Tx8R8RCDJmjeVen2bmb7gyj9zk/GiTSFWlHjkgNZKoarq2JqHg7Gj/OByw7T?= =?us-ascii?Q?vzLJkg+4RWyNV0U2zsO+b8yECJtuuCARSCrW6FnP+9SlKEstffB6yo67g19N?= =?us-ascii?Q?mEE4TDxHb4Ry0zjKdXRrBvEyCVhuFOghU5k+ihqa4XmtnTBMJbno6JbvTReg?= =?us-ascii?Q?u7B1X9p9Yowt587JdORyR/VKe/Lxl9rbiaVOqBEjuehGOPyjlw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 05:45:45.4225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4002bed-e9dd-46ce-7c5f-08dd085d69c4 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5600 Content-Type: text/plain; charset="utf-8" Commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") optimizes IPIs to idle CPUs in TIF_POLLING_NRFLAG mode by setting the TIF_NEED_RESCHED flag in idle task's thread info and relying on flush_smp_call_function_queue() in idle exit path to run the call-function. A softirq raised by the call-function is handled shortly after in do_softirq_post_smp_call_flush() but the TIF_NEED_RESCHED flag remains set and is only cleared later when schedule_idle() calls __schedule(). need_resched() check in _nohz_idle_balance() exists to bail out of load balancing if another task has woken up on the CPU currently in-charge of idle load balancing which is being processed in SCHED_SOFTIRQ context. Since the optimization mentioned above overloads the interpretation of TIF_NEED_RESCHED, check for idle_cpu() before going with the existing need_resched() check which can catch a genuine task wakeup on an idle CPU processing SCHED_SOFTIRQ from do_softirq_post_smp_call_flush(), as well as the case where ksoftirqd needs to be preempted as a result of new task wakeup or slice expiry. In case of PREEMPT_RT or threadirqs, although the idle load balancing may be inhibited in some cases on the ilb CPU, the fact that ksoftirqd is the only fair task going back to sleep will trigger a newidle balance on the CPU which will alleviate some imbalance if it exists if idle balance fails to do so. Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") Signed-off-by: K Prateek Nayak --- v4..v5: - New patch. Add some details on implication of threadirqs on idle load balance and how newidle balance helps those cases. --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 225b31aaee55..fe6db479a855 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12564,7 +12564,7 @@ static void _nohz_idle_balance(struct rq *this_rq, = unsigned int flags) * work being done for other CPUs. Next load * balancing owner will pick it up. */ - if (need_resched()) { + if (!idle_cpu(this_cpu) && need_resched()) { if (flags & NOHZ_STATS_KICK) has_blocked_load =3D true; if (flags & NOHZ_NEXT_KICK) --=20 2.34.1 From nobody Sat Nov 23 15:20:29 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) (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 BB87C142E7C for ; Tue, 19 Nov 2024 05:46:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995169; cv=fail; b=aRZ0woRrAma4BDjlw1c6qLozSmPkMpSF0t5Inh8u4sS19GKQ9wafhKROmLzIzkeu0OOrCbH00ToL0MEo2xzFc2zahSeFTdsPHXmQhWg8qsOiXUhF25t95YUVi7/WEV9Z02RRAdjE4cDzjgz8fRrtdLm+huzGIFofHZlHxtUi+9M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731995169; c=relaxed/simple; bh=+ZoSNuKGOS6XN/mIyhHo6fbq8jMula5qsReok3p7RjI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ey0tDGnqoFXme4Op+0NyCpMP1hDuDEPW8yl5cHvTNDE5GM/LHtFhkIhjHsnOQXFw6tgPAKIOXj7OSvuVnKlN38qjUwnWCoVFxwjY2fKU+Qnh2707NZeI4KQYWOVKEgsuAcVpDcsMphUq/SDp2hpYp6PyXzXXecj9pw3Lc0ecKgI= 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=pV45TzxH; arc=fail smtp.client-ip=40.107.220.87 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="pV45TzxH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gdtXU8J/vrOT1hoBZi0NL/qCy92XUMijVcuLRrtolqfzn3iM/8UJDi3p8YW+w6ulC5L8/mzTK+CXrgQaci5kHVOIl8wepjlgdVBB7sV9ic8BQzLXcPUJifr3tKlRw/UQu7DwBV+rx0jwF1ec2o/K7f6pLLqHkjBgqba2QKYWkVJYjG9qMP7j7Vo4CPUJ3t9ZZ4evlpRZwv511GfGFceTu21HUTs3Em2ZRaoFmzVmuvLgeD6AUfvXCBrEkAndLb83JRh8tcUjK+EVsgMtsE1s24wHU+BxOB/RutE/zF2kjNilqA5eERYkmsdyr/F1uHTDegkp1EKsYY3cxuiTSF7A2g== 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=wX9FQvjzKlDgiiet3apd6ajpe+k9G1eYy7N4Swy2W9Y=; b=gfW4R7Bbb9xl9lDgf3esxlCtFW2Du9j8CTsfhyeoXCqGGDm5DIy5Ah+4/DlnMQCSOKIprcfwHzrOSMHXX7KIPjiuVT/4UGN2AO01z8LA+loWnQlQc9KGg/CgX3i1aSPrEZwTyNcoLP/X9sQMFgKDRC/seHAACEAujnR5asEo+QviVLoQwt6IPmiBLXUrxqedEph8AyZg0vIMHnm2HBDmN7ItPZQyo4GitqRsEypdFR4Sjm5hx3qM9c2oKwjr6sYFELnSgs1tGxLuXdTaxWEJiZX8sc5JBkxRgGz+9j9ilQR5LwfO1VIxjiqn/uzE7Hy2YW/1wwdANk+4ZLeSWEfd+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com 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=wX9FQvjzKlDgiiet3apd6ajpe+k9G1eYy7N4Swy2W9Y=; b=pV45TzxHhV0F2WmmSVKbtG/r53VgZQHJFCxBh6jm9dFdPjabaDbu6Y95QLF2ygAAuZRwVf6jOIwDssaNItbDH0oc3wNZLxV2DUP0jgbRts1RPvJChAt//HEh2Tjlb145s4EbInIPXcwCJA+a51RsFdE8Y5/1iRGi8m8CPNFD0hc= Received: from PH8PR05CA0011.namprd05.prod.outlook.com (2603:10b6:510:2cc::28) by SA1PR12MB5658.namprd12.prod.outlook.com (2603:10b6:806:235::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19; Tue, 19 Nov 2024 05:46:05 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::87) by PH8PR05CA0011.outlook.office365.com (2603:10b6:510:2cc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Tue, 19 Nov 2024 05:46:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 05:46:04 +0000 Received: from BLRKPRNAYAK.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; Mon, 18 Nov 2024 23:45:57 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Sebastian Andrzej Siewior , Clark Williams , "Steven Rostedt" , , CC: Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , Thomas Gleixner , Tejun Heo , NeilBrown , Jens Axboe , Frederic Weisbecker , Zqiang , Caleb Sander Mateos , "Gautham R . Shenoy" , Chen Yu , Julia Lawall , K Prateek Nayak Subject: [PATCH v5 4/4] sched/core: Prevent wakeup of ksoftirqd during idle load balance Date: Tue, 19 Nov 2024 05:44:32 +0000 Message-ID: <20241119054432.6405-5-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241119054432.6405-1-kprateek.nayak@amd.com> References: <20241119054432.6405-1-kprateek.nayak@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: SA2PEPF000015C9:EE_|SA1PR12MB5658:EE_ X-MS-Office365-Filtering-Correlation-Id: aa1417b6-1690-46d4-c8c1-08dd085d7524 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EzcJULrDLWtHj0YpIu1EpP0tyGXPK/Owtnxa5oQrXn1MX5w+I3rEl4tYRw1s?= =?us-ascii?Q?6dU5eu9Ef3TF8Idp3vONWd8HQAV5UmKhehHx1/hcDZCSPGrHlJ0KNvNNStNr?= =?us-ascii?Q?0g7U3B2ygOQZ+INnLFLNlyUxyRHk5AC5d2CGZPCsLQftX/61aczsdhXMAo34?= =?us-ascii?Q?23fUiEg2YQg3bV/JHBi+1SwV4dm3y8h5yKeWEdiQ3+Q/h/te7n9NasXLmiAz?= =?us-ascii?Q?tBhgid7kGfDDYYKB2sSM31obbIJo2zduePyVtYt5EoSYU9QactDq6DipEQ4W?= =?us-ascii?Q?yrClR1aa+nD0NJXk6IDDmb+tZfxK3b+9YItLZ5csdXUPEYLRO3Jk5USiAqB3?= =?us-ascii?Q?PrPIWXgipeC7NYSv8NUlNXi9QbPDpzhi+aPKmM2BnIsjZeiRoWqJUZjas/Tt?= =?us-ascii?Q?b9CcnrinF9gDRneTYmL+9b+zNPMpTouX+xkOFWXXcgIQmNrgWaDluTtRUWK4?= =?us-ascii?Q?24puEMc7XX4HoDnizgOENvzuPvl6EKL6yR9BZl5qcMLIk0rNKRzAX6Y+JT9q?= =?us-ascii?Q?Z1Y4b7XIpqkJXgmMYFWkp5/NMYDijNDIRod2UkgYNWoJdJfI8kLbvUOfInFV?= =?us-ascii?Q?KCk59S4QD8y8IMHNj+j1ixVZQBlESC4zhnlqry9gxlfnz65vU9D1drNbDnER?= =?us-ascii?Q?yMbkxvO7dHd/8DZuAAHuCpZ2lAVkH8eQdM4HP4kRdcEKfB5EKWS/yerMR1KI?= =?us-ascii?Q?BzlWPptPj5rb97Pw1enSrMVO/Ggn9QZClErbE3gKJtBJ94tst3Qtfu1VBHgY?= =?us-ascii?Q?x600JTA65AMViVqhrnopfz0/z2x1wSVMkaKhAvyDwAgIgrIpxYJtJMbhfGE6?= =?us-ascii?Q?fwzFuzn5u8Qjzc019sEGKftzQVJx6PUJvEOCpx3RYYNDwCmMR3j+0QgCayuJ?= =?us-ascii?Q?uPJ2mysLxhNeeM1Nr7RB9l2UycidvpU8nB3EH48qYPE4TxLKPX0KtumCmP89?= =?us-ascii?Q?ClllJsGfvUQnVdfHJsDAWAEM+9Z2Qp53c4xBRQZFb8/oOFrPb/CCak8t1MVY?= =?us-ascii?Q?WlPpW5ypj9E2xlZvxRalXKXklVU5RULWc35bDY1n6dJT6afDPoABRnx7/tjX?= =?us-ascii?Q?ZXwzHtZAzOtYYpxtxCW+eKYdN2azdtos16Va1ZuYUaHqjdjq8D1KyJIF8Yz9?= =?us-ascii?Q?6R7DWRpKAJwTt1bd3xAlK55VsMUkhpmsNB9zEO/pB+CLtHwrE4ZxgGynGr/p?= =?us-ascii?Q?3gjdGqlW+tkIKp+LmQ3vBFRDzGjT6BF6UgnheaR5YFl9JF6rA2/c0V/gOk91?= =?us-ascii?Q?E6GAwCLES3oq4EtfIgRRYomxUsHT/ez363KOKnTXsfO3ZU3E8tTo/UPEz0e3?= =?us-ascii?Q?0R7swCIQrAU4bcWdLet4L9l1UHoZTBb7r6p3DRvCJvuem4yoEyW7oBUUxWBm?= =?us-ascii?Q?P61RN+LG38bxmQE9teVJkYml+tvyMbOjSUing7g0/keJMj9LAg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 05:46:04.5866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa1417b6-1690-46d4-c8c1-08dd085d7524 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5658 Content-Type: text/plain; charset="utf-8" Scheduler raises a SCHED_SOFTIRQ to trigger a load balancing event on from the IPI handler on the idle CPU. If the SMP function is invoked from an idle CPU via flush_smp_call_function_queue() then the HARD-IRQ flag is not set and raise_softirq_irqoff() needlessly wakes ksoftirqd because soft interrupts are handled before ksoftirqd get on the CPU. Adding a trace_printk() in nohz_csd_func() at the spot of raising SCHED_SOFTIRQ and enabling trace events for sched_switch, sched_wakeup, and softirq_entry (for SCHED_SOFTIRQ vector alone) helps observing the current behavior: -0 [000] dN.1.: nohz_csd_func: Raising SCHED_SOFTIRQ from n= ohz_csd_func -0 [000] dN.4.: sched_wakeup: comm=3Dksoftirqd/0 pid=3D16 p= rio=3D120 target_cpu=3D000 -0 [000] .Ns1.: softirq_entry: vec=3D7 [action=3DSCHED] -0 [000] .Ns1.: softirq_exit: vec=3D7 [action=3DSCHED] -0 [000] d..2.: sched_switch: prev_comm=3Dswapper/0 prev_pi= d=3D0 prev_prio=3D120 prev_state=3DR =3D=3D> next_comm=3Dksoftirqd/0 next_p= id=3D16 next_prio=3D120 ksoftirqd/0-16 [000] d..2.: sched_switch: prev_comm=3Dksoftirqd/0 prev_= pid=3D16 prev_prio=3D120 prev_state=3DS =3D=3D> next_comm=3Dswapper/0 next_= pid=3D0 next_prio=3D120 ... Use __raise_softirq_irqoff() to raise the softirq. The SMP function call is always invoked on the requested CPU in an interrupt handler. It is guaranteed that soft interrupts are handled at the end. Following are the observations with the changes when enabling the same set of events: -0 [000] dN.1.: nohz_csd_func: Raising SCHED_SOFTIRQ for= nohz_idle_balance -0 [000] dN.1.: softirq_raise: vec=3D7 [action=3DSCHED] -0 [000] .Ns1.: softirq_entry: vec=3D7 [action=3DSCHED] No unnecessary ksoftirqd wakeups are seen from idle task's context to service the softirq. Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") Reported-by: Julia Lawall Closes: https://lore.kernel.org/lkml/fcf823f-195e-6c9a-eac3-25f870cb35ac@in= ria.fr/ [1] Suggested-by: Sebastian Andrzej Siewior Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: K Prateek Nayak --- v4..v5: - Reworded the commit message as per the sugestion and dropped the comment above __raise_softirq_irqoff() (Sebastian) - Collected the Reviewed-by from Sebastian. --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 424c652a9ddc..e45f922e5829 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1239,7 +1239,7 @@ static void nohz_csd_func(void *info) rq->idle_balance =3D idle_cpu(cpu); if (rq->idle_balance) { rq->nohz_idle_balance =3D flags; - raise_softirq_irqoff(SCHED_SOFTIRQ); + __raise_softirq_irqoff(SCHED_SOFTIRQ); } } =20 --=20 2.34.1