From patchwork Thu Jun 13 18:16:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804739 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) (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 8A9E34C6B; Thu, 13 Jun 2024 18:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302659; cv=fail; b=o/O6+cWaKkhhqLRCg/6N9LIEEfXao7R2QNokBQ7HZLTJ0C6HAz+Va8YawNhMd38fkwSJEpRKUqsxdGyY6wk3G8EshHjw4xiV1FkvR3wlwRI4Z/bc0hPPUXG7a/gbeCwEQRdQPuMFnv0fmKacMzfy1TLmHwhGEMz6TCWcshmXD9k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302659; c=relaxed/simple; bh=2H8EhQ1NnvWapO/5VC3C5pjfSaOa7xdHEoj1B80D+S4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O3+NCXxdUTqZIJ3uaFWR79fi8CgoJQd/GkVj/fs9iMelqiSPm2kbx1ULCZMWcwpaJI033mzi89inOftnNYt7x0ViW1d2C7mxh/CTIS6ZcuPvNkLVRAtGAEpwRmoxB9TgOKRKV2lsVPxJHIuP0mnQArYcg2uh30K/wowvc3JvfvI= 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=sX8+K4ry; arc=fail smtp.client-ip=40.107.223.73 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="sX8+K4ry" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4vnLIHNqf6EMaus+lVKV5QnYMXB1uDfXGYo/TPGsT1sRrc10nj9Ma8Xfowm8Ety9SoGywT7fVWvtQkSbRHvMy6rzb3fs9iwWmmZ/OBEBQPST7BX3+oMHWK4a4R/HE+ohygGxlU13T+GfzdgcJ+YREv8G9qPKF888WS3CSQYdBNT5su2aK1miHvnhpLpfGcwLCLQ+sfCFedaJ8+MgFB8reOGoh31Lj3yQzu8vR+wuh+p+EpBZHQrpWZ6fLRZTCU3E5zT9AYMfBfWbcs8QOV1tJTQpmiWqvnFLFp8XtoCOPjck6/QnP1ZdesMOb6SfjSob7kddqpVV7o3Nv5lFHXocQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=NBDm/3LMK0oErkDvBoPiWdU5abmUSz18MIXn67uiZ4Q=; b=ZojCpX3Czq6YaKtbZm7hKkH9y5OG9QBj2MEuUykqB+fTD/mVPoy1pNusEMsSLEa29nkYecPaeS02lBJbz7EXY0gxAh5ewVzgNvTRg4uJfWa/5USSOp6xIVX4iVd7medU7sua2WQopFQeV7LH+CxkbdyCsUJnMLb/jr1XxX972JH/jrGEuyq6W+rFAwFgpgFkA/B51s2y5VOhsmJCApoiC2x738iPdWpwC+I304aYR0dnJQShkxar3Q1nCMzkHUUDdBYotu+Tppsfq0AAfsmcO2TgTCFDMxR7PoK2riWP+PKHeA3kxS6g7fPX72uDePKV+BynfCIUOKumI3wop23V6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=NBDm/3LMK0oErkDvBoPiWdU5abmUSz18MIXn67uiZ4Q=; b=sX8+K4ryqOG1Ochl8dUeXR94hVUTyMv8zjvOLiS2mSka8XpVuOMAxtWaWdpHG9iPsl3YHnfC2QUmBhcQBdNCQOlCGDBDA1zyt6d86myl/RU/iwz4oAPnkz2Dcv5BeCXIZDTm95iqL+SAKblQPQM+db8wdKR8Z9qbTZBu1gY7WO0= Received: from BN0PR04CA0087.namprd04.prod.outlook.com (2603:10b6:408:ea::32) by MW3PR12MB4364.namprd12.prod.outlook.com (2603:10b6:303:5c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Thu, 13 Jun 2024 18:17:33 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:408:ea:cafe::59) by BN0PR04CA0087.outlook.office365.com (2603:10b6:408:ea::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 18:17: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 BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:17:32 +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; Thu, 13 Jun 2024 13:17:12 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Guo Ren , "Michal Simek" , Dinh Nguyen , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Yoshinori Sato , Rich Felker , "John Paul Adrian Glaubitz" , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Rafael J. Wysocki" , Daniel Lezcano , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Andrew Donnellan , Benjamin Gray , Frederic Weisbecker , Xin Li , Kees Cook , Rick Edgecombe , "Tony Battersby" , Bjorn Helgaas , "Brian Gerst" , Leonardo Bras , Imran Khan , "Paul E. McKenney" , "Rik van Riel" , Tim Chen , David Vernet , Julia Lawall , , , , , , , , , , Subject: [PATCH v2 01/14] thread_info: Add helpers to test and clear TIF_NOTIFY_IPI Date: Thu, 13 Jun 2024 18:16:00 +0000 Message-ID: <20240613181613.4329-2-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022573:EE_|MW3PR12MB4364:EE_ X-MS-Office365-Filtering-Correlation-Id: a2fff5df-6d2e-479b-b436-08dc8bd5180e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: eKPfG6UdmTVhoqRYP2D7Uk4xzVOFM6kU7mCeOZqhjLz14QCOFiwSRifwdQpdvPTnOmqeiWxhdYTj5ec4SB6LJssA2Ms2GSmRXUA88G8QjAgN6BR14fsOub/DHpwvdRz+8VSNLVfWD2YgvX/WUWNRbn8+p2VtKwTAGcI/VZgP0h0KW5qHGvddMdc1KedchdnzbjUFc3WVYOpP90+11yDQ9vIJv/wN6h2CJ/Gs+4Wb5C/YyS7Wu9cshuYyNN6jQFoEcrfGyWqhj6GOlAUhQZOWsX5NWGmeK/9iYgo036g0tOX2lSACDtTrTz+iSO6cmIcIkg+Ep6WLUMfUxrlFCN1M805eMVmNy9mm1g56RS+0YVjUKshyMqE/mPsQVkpH8GlTfcaCGtLz0XXtDmqH6hXzAJAziwwkHD0rftPnBYgI3UeY/qHIo4dnHu0r6qwW5XW2eKjLE3cH3pO1uDoNXycdqGSTntnuDhUyIcBWHTvV9ETrYIivowe5B4ntiYzphmr01UHfuUXLzKWMsAsJuGE5EVIAC4XiLaOUuuj7l17Ry0bjYvN5D+UGLoXMjmK7s6uhYMeJlmcVxo+eepxfpko7q4Dop1z33lEdOHT6uBDobzHxrTDOgTzqDAYy5fovvd/Xro3opHeb3ne1vUxmLaws/3bMmPULfbwxCLdzLJqwYmOf5hJ/EXcEy9+3zfTgLcgGFVTRkrWIlH7ZKrok2Mzix4J7A/SF37luja2PsM6VQyQS5fPGE5lq6PKA8lfBRDVjgAI+FM0h7/Z81dgQYX9vf+1LMKk51ZdSsoL/eGfED8iBdO1yRkPnhYNR0ahiiHqgbTNDwRp133OpCr1epjhMrIiYgUr/2RTLxDk2NrBAkH/GhKAiEYD/kV4nOjjpPQZ0EyJXcghE/FoGiLoVY2ATb41/1/ZodOXzUde3Tmuolh8Hxe9yEc7XtgaO4vDZ2w4xAJy+XI5BnMkCPje8ohHDpIyahVx4Ptm8LzlIyp+2saAfVBHi/JidmHQOs0YtY3GgfszFmW0WfJpGwM38wNyMgsrbtkCHBuOiSc3amf/7aBsZSS8GuJtFhByCFx2aBhTSy0eIzD8yXQrCy3enj3vSK1lZlruFOrBtPZkVEQlVn4cOkQX0bIN5Wx8vf+oxV+AqX3ZYtqrAPhiKhs0fzXygITlzQw14XPjT3gsPFMPIaBQs5dCDX2kCM9yVQfyWIFulSf6DuCrDDRk76cP3LuvuRvbpz1c7/OMhR/qsnqVkcbVcnCFaybzzLkt7ZZunQiYID2c2brqL1mVpK4aqxRzsburSK9LPl/CaGJ9UexftXCVJCRAsJpzN0zg7/jxLPUJbK/ssAXN69xdsDwHQRbrkZh7yJxmUEBvZNpS1xEj9+w7vqJetJyU+cR5jpu+g19C3e8L9pkfMSSUX1hbaP3E3jQ== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:17:32.5335 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2fff5df-6d2e-479b-b436-08dc8bd5180e 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4364 From: "Gautham R. Shenoy" Introduce the notion of TIF_NOTIFY_IPI flag. When a processor in TIF_POLLING mode needs to process an IPI, the sender sets NEED_RESCHED bit in idle task's thread_info to pull the target out of idle and avoids sending an interrupt to the idle CPU. When NEED_RESCHED is set, the scheduler assumes that a new task has been queued on the idle CPU and calls schedule_idle(), however, it is not necessary that an IPI on an idle CPU will necessarily end up waking a task on the said CPU. To avoid spurious calls to schedule_idle() assuming an IPI on an idle CPU will always wake a task on the said CPU, TIF_NOTIFY_IPI will be used to pull a TIF_POLLING CPU out of idle. Since the IPI handlers are processed before the call to schedule_idle(), schedule_idle() will be called only if one of the handlers have woken up a new task on the CPU and has set NEED_RESCHED. Add tif_notify_ipi() and current_clr_notify_ipi() helpers to test if TIF_NOTIFY_IPI is set in the current task's thread_info, and to clear it respectively. These interfaces will be used in subsequent patches as TIF_NOTIFY_IPI notion is integrated in the scheduler and in the idle path. [ prateek: Split the changes into a separate patch, add commit log ] Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Russell King Cc: Guo Ren Cc: Michal Simek Cc: Dinh Nguyen Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Cc: "David S. Miller" Cc: Andreas Larsson Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Andrew Donnellan Cc: Benjamin Gray Cc: Frederic Weisbecker Cc: Xin Li Cc: Kees Cook Cc: Rick Edgecombe Cc: Tony Battersby Cc: Bjorn Helgaas Cc: Brian Gerst Cc: Leonardo Bras Cc: Imran Khan Cc: "Paul E. McKenney" Cc: Rik van Riel Cc: Tim Chen Cc: David Vernet Cc: Julia Lawall Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-csky@vger.kernel.org Cc: linux-openrisc@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Gautham R. Shenoy Co-developed-by: K Prateek Nayak Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- include/linux/thread_info.h | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index 9ea0b28068f4..1e10dd8c0227 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -195,6 +195,49 @@ static __always_inline bool tif_need_resched(void) #endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H */ +#ifdef TIF_NOTIFY_IPI + +#ifdef _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H + +static __always_inline bool tif_notify_ipi(void) +{ + return arch_test_bit(TIF_NOTIFY_IPI, + (unsigned long *)(¤t_thread_info()->flags)); +} + +static __always_inline void current_clr_notify_ipi(void) +{ + arch_clear_bit(TIF_NOTIFY_IPI, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#else + +static __always_inline bool tif_notify_ipi(void) +{ + return test_bit(TIF_NOTIFY_IPI, + (unsigned long *)(¤t_thread_info()->flags)); +} + +static __always_inline void current_clr_notify_ipi(void) +{ + clear_bit(TIF_NOTIFY_IPI, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H */ + +#else /* !TIF_NOTIFY_IPI */ + +static __always_inline bool tif_notify_ipi(void) +{ + return false; +} + +static __always_inline void current_clr_notify_ipi(void) { } + +#endif /* TIF_NOTIFY_IPI */ + #ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES static inline int arch_within_stack_frames(const void * const stack, const void * const stackend, From patchwork Thu Jun 13 18:16:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804041 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) (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 C2EED14A0B9; Thu, 13 Jun 2024 18:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302696; cv=fail; b=bGZYh4Dq1ZYrPWrcFyaHcgkiKbkVLJ6XRe2s5dow98Ty1o0MinK+Uzq+lMzSGqcyoBs65wH3oKSbvKo43b1tavHlfbNWcOHVEa8ZYkeY1v2bwQ9+K5C3nRM+zUMvf+LcofCPbqesstS/FeNyq0iUvuCC74CV92mSn8eCTxYSLNk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302696; c=relaxed/simple; bh=KpfdWXnHeZxsIgJZ9+KAoccZ5YC3f2WkIT2+neeu/UI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SMcfRjxkjkluEaylgg0yhb1nTkH1o4KZQ/IVv+bvnU/C1lgGVw7yqqjoqI1U5nIJq2J/nIpbdK9BhOidK+AbfZuX8gYMXb9azXcaGnl8rUjUvxlVUNb46pOn55KK2CE7wdGRJTUMkXXnMYFqjm5rghnbNreSqr7g591ukDwoopY= 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=jd7I/ugl; arc=fail smtp.client-ip=40.107.237.47 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="jd7I/ugl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YPH+Sjp+xmOfApZ5ve/AMxPD0/W5Nn+itQ8SLqEjSyZZcQW53rTb+C/etkxqICquCpeD3W/sHt8SAnJuS13Pa6As9FQaaLX0Rx8Td9/elGJhV+zlnZoHHPi0oHU3AjAQAUq+ugJSSu1LWgMb90Cx0aJkAfCkSL+ImTzMoBHNoFpQGv9fwTfPWvOwb12j7egVfqoFjUfBRUstaNQnyjVEuVAdskmA7CE24oIjDYheoU9inUWWs8TrDoSIOZSdDkcMFC+aWSDarcwyj3IwORjbbfuJKt9m1IQHspQqoyPdb8RdMl78oc10Av36E+Y46okcOTorR24O/mgl0ec0nzEEcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=YuUkCb+5GRVurK0poTyH+PXtw8jDpAelqX9rR/ev7Uc=; b=gk7Y/dhLDyb8ZFceebxvG/geg3RWRMNjnkkFJNp+487siZJrDK0YHl9FFBD/aJattdcLTl7H42QyAu0wAAriIKCQ2tqk+tntWWfPPBhncsFEzEKbumsEt3mbh7FVKR3f7968vbmBxqmnSxuafn7N/8/iJdATNurmaKz4FF8VQTwGwFMVTG/nAdWrxe5JWmYGFEicAJE3kRoMhvs45bx1w+Bh/VGzETtd0+kyNhRNgLdRgpxyeBfshWEY84pOLdFZXkZiKU1YYt8k/2z4kXDnItaEqxMUn3+NFrRVvCAScyRHp9UGAs6sxzoo88/XodEy5V5I7BL2IiOrFQO0FNFziQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=YuUkCb+5GRVurK0poTyH+PXtw8jDpAelqX9rR/ev7Uc=; b=jd7I/uglRW1iAA9f8a0MO9wm/DqnQUWkbIhcxQHUqvm40K+FOWZKlIqJxyjkxZfm6I7tIX+RYFbeDbDnjbKXKR8YSOQckpicWWgBDWDSMW8dhfmTkb8r11uIYVh6RCnUjfkuJjEEVvyYjK6qopn4vpVH3EMWD9WNFff3XuhqK8s= Received: from BN0PR04CA0069.namprd04.prod.outlook.com (2603:10b6:408:ea::14) by PH7PR12MB7138.namprd12.prod.outlook.com (2603:10b6:510:1ee::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 18:18:09 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:408:ea:cafe::7f) by BN0PR04CA0069.outlook.office365.com (2603:10b6:408:ea::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:18:08 +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 BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:18:08 +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; Thu, 13 Jun 2024 13:17:46 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Guo Ren , "Michal Simek" , Dinh Nguyen , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Yoshinori Sato , Rich Felker , "John Paul Adrian Glaubitz" , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Rafael J. Wysocki" , Daniel Lezcano , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Andrew Donnellan , Benjamin Gray , Frederic Weisbecker , Xin Li , Kees Cook , Rick Edgecombe , "Tony Battersby" , Bjorn Helgaas , "Brian Gerst" , Leonardo Bras , Imran Khan , "Paul E. McKenney" , "Rik van Riel" , Tim Chen , David Vernet , Julia Lawall , , , , , , , , , , Subject: [PATCH v2 02/14] sched: Define a need_resched_or_ipi() helper and use it treewide Date: Thu, 13 Jun 2024 18:16:01 +0000 Message-ID: <20240613181613.4329-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022573:EE_|PH7PR12MB7138:EE_ X-MS-Office365-Filtering-Correlation-Id: 5640cdb2-1321-49a4-a03e-08dc8bd52d37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: ANnbjwEP9CPzsmHtVJeYQc0b/tt2IoGpFyXZK8e55+ceLrV0W62PAX8w3K820BIWZ7dNjubp8K/zQVrG5nYZx7ML5n8coeyl31bs4slka5+21EWAINEJ3anSx6QoJhEOHug31+GbImsp3kQZQzC0QvovXqdb/oiG4cL3+JYkv/2UjK7U/MZkobjWWASpzzD9uJRs0hW3Wemk7jUeGsupM3bCF2WIK81n+wuf5MJpKrF0OiSmdssb6pavAlNXoOppzZ68emKa3ueeYJ7VDJk+onqoD/7MJoFF48rlekBCCD7iGugXyk0tL3X2lvq6c0MS6T7MB/FhpsHtIGRx1DH/sL6VcIrpsZbaeE84HAGiHtFYl89foJgXWeZRolDIkjUtH52qhBGhRESd2Dhd5zMQx2FVSVk1Y3yau7fK8gj0sNQv9PtEELd0+EaJAPT/8V0PrN1retXo2zgUQ0blOBnV6iOBmrYkenzN9188vvO0ig61wN7TU84ONP6rR7XIfP8XpzdflKlNKAZjMVceDlueUcY30y+grHzWPSYaTZI6zyFaoEvnyfNrM+E3AksixSHYBDIKN3XW+fDKIhYhm/lDmB9RSOj2eGjlc7Voda7IWlFp/YA1NELTQz0MHtKlS8G7gWP/iSJ68i5k56iKv2xsJBz25ZLqXkE7LhoCPK7EIQh9NOkSz10OqxXzgFjW63GX0xeClw178FSf+/mAGe4SNN7rnLEQ3OVGhRer4eEe2bN7ELkhmlsOn7bg8XWdJmNfDVMlonGy+Q0KsDHS67Q3f7xFnvwwWuIaVwf3aANZ4hTl0l4k7xiVNtEc55pN82wQegXVvBQsrtbLh9rUUC5eJKNsWqoCchVQYlJoNe3NxJ6RSAL+Uv+jZ2UTyBzVGKmqwUc3ocAnMD9oLADk10RdsrsROJ3ccjEp3PBG7Ip7dpF8nIy+orRHGzSUgf/LnBTGOX2Mrq1/wcG9ENmcEYYt/opxiKY5gmAgfBPTImgaane3mdG2X+KZJsuZeRjVbewEl/MzaOAc5xRRxOj9Fwdv3Di4ktDdRmho8Heq518ee0OlWYOZclAoMsRT9RCktZfED3Had1Fcj1tRJzE7WrXAX1/M6QOCCT8LFlg5Ql43I45H5+jxH/8D+SWjQPqiMPqgIO+4OzJpPbmW5i8P+LduNovpuyK80RlCRA6LMr0Xpzg//MykU1x4MMH1wCWK/IgobttBox2h95yS9zbuSWV1ntjwiLdV1ylNISAv4hlHphBfstolr7hXptatHd01+q0JaAVJ6ppJLy+dT3iKQmKYn5eTlDdv6s8x29hSP/ogRXBe2s8xIi1BbeC/X1gVI/ki2+UhK08ok4koogLu0E8gRexF7jk8Oeu2ojEvTM7e334LhI7CzhJd6RBsiNlVOUisX9sYIqdFz6fLeMPETPj5kw== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:18:08.0182 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5640cdb2-1321-49a4-a03e-08dc8bd52d37 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7138 From: "Gautham R. Shenoy" Currently TIF_NEED_RESCHED is being overloaded, to wakeup an idle CPU in TIF_POLLING mode to service an IPI even if there are no new tasks being woken up on the said CPU. In preparation of a proper fix, introduce a new helper "need_resched_or_ipi()" which is intended to return true if either the TIF_NEED_RESCHED flag or if TIF_NOTIFY_IPI flag is set. Use this helper function in place of need_resched() in idle loops where TIF_POLLING_NRFLAG is set. To preserve bisectibility and avoid unbreakable idle loops, all the need_resched() checks within TIF_POLLING_NRFLAGS sections, have been replaced tree-wide with the need_resched_or_ipi() check. [ prateek: Replaced some of the missed out occurrences of need_resched() within a TIF_POLLING sections with need_resched_or_ipi() ] Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Russell King Cc: Guo Ren Cc: Michal Simek Cc: Dinh Nguyen Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Cc: "David S. Miller" Cc: Andreas Larsson Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Andrew Donnellan Cc: Benjamin Gray Cc: Frederic Weisbecker Cc: Xin Li Cc: Kees Cook Cc: Rick Edgecombe Cc: Tony Battersby Cc: Bjorn Helgaas Cc: Brian Gerst Cc: Leonardo Bras Cc: Imran Khan Cc: "Paul E. McKenney" Cc: Rik van Riel Cc: Tim Chen Cc: David Vernet Cc: Julia Lawall Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-csky@vger.kernel.org Cc: linux-openrisc@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Gautham R. Shenoy Co-developed-by: K Prateek Nayak Signed-off-by: K Prateek Nayak --- v1..v2: o Fixed a conflict with commit edc8fc01f608 ("x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram") that touched mwait_idle_with_hints() in arch/x86/include/asm/mwait.h --- arch/x86/include/asm/mwait.h | 2 +- arch/x86/kernel/process.c | 2 +- drivers/cpuidle/cpuidle-powernv.c | 2 +- drivers/cpuidle/cpuidle-pseries.c | 2 +- drivers/cpuidle/poll_state.c | 2 +- include/linux/sched.h | 5 +++++ include/linux/sched/idle.h | 4 ++-- kernel/sched/idle.c | 7 ++++--- 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h index 920426d691ce..3fa6f0bbd74f 100644 --- a/arch/x86/include/asm/mwait.h +++ b/arch/x86/include/asm/mwait.h @@ -125,7 +125,7 @@ static __always_inline void mwait_idle_with_hints(unsigned long eax, unsigned lo __monitor((void *)¤t_thread_info()->flags, 0, 0); - if (!need_resched()) { + if (!need_resched_or_ipi()) { if (ecx & 1) { __mwait(eax, ecx); } else { diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index b8441147eb5e..dd73cd6f735c 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -901,7 +901,7 @@ static __cpuidle void mwait_idle(void) } __monitor((void *)¤t_thread_info()->flags, 0, 0); - if (!need_resched()) { + if (!need_resched_or_ipi()) { __sti_mwait(0, 0); raw_local_irq_disable(); } diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 9ebedd972df0..77c3bb371f56 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -79,7 +79,7 @@ static int snooze_loop(struct cpuidle_device *dev, dev->poll_time_limit = false; ppc64_runlatch_off(); HMT_very_low(); - while (!need_resched()) { + while (!need_resched_or_ipi()) { if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { /* * Task has not woken up but we are exiting the polling diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 14db9b7d985d..4f2b490f8b73 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -46,7 +46,7 @@ int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, snooze_exit_time = get_tb() + snooze_timeout; dev->poll_time_limit = false; - while (!need_resched()) { + while (!need_resched_or_ipi()) { HMT_low(); HMT_very_low(); if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c index 9b6d90a72601..225f37897e45 100644 --- a/drivers/cpuidle/poll_state.c +++ b/drivers/cpuidle/poll_state.c @@ -26,7 +26,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev, limit = cpuidle_poll_time(drv, dev); - while (!need_resched()) { + while (!need_resched_or_ipi()) { cpu_relax(); if (loop_count++ < POLL_IDLE_RELAX_COUNT) continue; diff --git a/include/linux/sched.h b/include/linux/sched.h index 90691d99027e..e52cdd1298bf 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2069,6 +2069,11 @@ static __always_inline bool need_resched(void) return unlikely(tif_need_resched()); } +static __always_inline bool need_resched_or_ipi(void) +{ + return unlikely(tif_need_resched() || tif_notify_ipi()); +} + /* * Wrappers for p->thread_info->cpu access. No-op on UP. */ diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h index e670ac282333..497518b84e8d 100644 --- a/include/linux/sched/idle.h +++ b/include/linux/sched/idle.h @@ -63,7 +63,7 @@ static __always_inline bool __must_check current_set_polling_and_test(void) */ smp_mb__after_atomic(); - return unlikely(tif_need_resched()); + return unlikely(need_resched_or_ipi()); } static __always_inline bool __must_check current_clr_polling_and_test(void) @@ -76,7 +76,7 @@ static __always_inline bool __must_check current_clr_polling_and_test(void) */ smp_mb__after_atomic(); - return unlikely(tif_need_resched()); + return unlikely(need_resched_or_ipi()); } #else diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 6e78d071beb5..7de94df5d477 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -57,7 +57,7 @@ static noinline int __cpuidle cpu_idle_poll(void) ct_cpuidle_enter(); raw_local_irq_enable(); - while (!tif_need_resched() && + while (!need_resched_or_ipi() && (cpu_idle_force_poll || tick_check_broadcast_expired())) cpu_relax(); raw_local_irq_disable(); @@ -174,7 +174,7 @@ static void cpuidle_idle_call(void) * Check if the idle task must be rescheduled. If it is the * case, exit the function after re-enabling the local IRQ. */ - if (need_resched()) { + if (need_resched_or_ipi()) { local_irq_enable(); return; } @@ -270,7 +270,7 @@ static void do_idle(void) __current_set_polling(); tick_nohz_idle_enter(); - while (!need_resched()) { + while (!need_resched_or_ipi()) { rmb(); /* @@ -350,6 +350,7 @@ static void do_idle(void) * RCU relies on this call to be done outside of an RCU read-side * critical section. */ + current_clr_notify_ipi(); flush_smp_call_function_queue(); schedule_idle(); From patchwork Thu Jun 13 18:16:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804738 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) (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 A08A11304AB; Thu, 13 Jun 2024 18:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302745; cv=fail; b=gj3yG4pwg7sGyvUkWTch8qU8LUKF/cag2j0hXrhnTK8NHgzHQWAzuff6itEiAojLdyWy2pnK/NoOs7mhkYrHinMxL2PnM/DxPvlb05V4nBeBlCTlyncmXIzlbtyT9vd2rGkLT2T9poyZmSgcXFo5AmKWOKmn5HuijVIBfxT14q8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302745; c=relaxed/simple; bh=H9Tm8Ru5cVQ8HmYAbwTasMIaRU/ufvjeJ7Pj70Gtalo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IMMsSWkHeVHeOM4LFZ+liupAM/hkLgDGEXpPhq7mU9zfyzTalGFXhseCrI3G80/lFvI3l/vCM5eGNxtpMdRhGgt2Vc2iG5QH4qPWqYrl4loUGaWSJg6a8l0GjQ3SNwq6nHOj4F0W1qwvNs41TA2Xs2Ad3vY9/SRwcE42zuIrK0Y= 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=AwLJe6nu; arc=fail smtp.client-ip=40.107.237.78 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="AwLJe6nu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=agjnf37f6yLy6ixU0EshA0EWtK6ui+Ft/4b7dpmENErM9MZr87otaAnPIauFVZIWa9cxPYWJZWhtqTgfE2+HAxJ5s72aCAR5fDROcvyyEz1tYZn959zB78APzqpt3/n7pI0Qw/eu9RQ1U/tib0QB5kiGL0vs6pnSryeaDyNlBCDTAnhr2j1BYj4AprFvHYSi7T6rVf4ZkmEbRUJjWjHYEX8Dg2K5kpGOB/r3eNR9kjQbFmrI+8b/Cu2In2LopQjJT+xKOaWTCJhtRjyRFDzRfrFcI9Le7wURl1sp9z9fD6xNWRK8tievTRzcIvRtz7HHk/ThF5F6gbNKSkbIuMkToA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HZlXvAdiHIqvQBEOLBXVueVNOHTmqlWFZbJ4L3Si/eo=; b=EmhM3ZVZCKL72zudHblM++NBvyLeaDD6b2hadxt9GzABuvY7/qtsPC63uwtoCEaf+8mc0gbYCAD9mi19NEGJtoAD1yBSdLl9VjvV4SoDSR+PfzRZ1xUM/ZrGqP5evGtBXNjd2tlCayPXsw7NvJ4m0GcDkOuRwvAqkF0Ofli7m5Ow4rOZC5O3XkeTyqUSESMHilY9Yt2ixE44Be00DzILkFF9vluG/l0TnXdCVSOF+XyGt2kIYoPTh0FTXz6Qd99Q6LQG7tfmoBoEUfvN9099L8r/NXE7IVv8/iPXn2VQAcaTN4WPvYsrTF2ZcemoZHcjbmtrOSMSUNTJJsrYEJ7SaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=HZlXvAdiHIqvQBEOLBXVueVNOHTmqlWFZbJ4L3Si/eo=; b=AwLJe6nuYVSLuYOXZQNdX2jdu4PY7Du7Cw8sDf0y3ELc/4yRPMwSpRKymPIHHVsIhOKsDqOcgs/Ttx6s15P7RMz+r+3xvaHalJ+QpW/2Bu2nMBT9O59Vj/cKVwfbAz7NZ3jUbkVR9RJjH333Zi7pVcJAXSwpzOKK47dAz5XYWQ0= Received: from MN2PR02CA0034.namprd02.prod.outlook.com (2603:10b6:208:fc::47) by IA1PR12MB8553.namprd12.prod.outlook.com (2603:10b6:208:44e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Thu, 13 Jun 2024 18:18:43 +0000 Received: from BL6PEPF0002256E.namprd02.prod.outlook.com (2603:10b6:208:fc:cafe::43) by MN2PR02CA0034.outlook.office365.com (2603:10b6:208:fc::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Thu, 13 Jun 2024 18:18: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 BL6PEPF0002256E.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:18:43 +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; Thu, 13 Jun 2024 13:18:22 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Guo Ren , "Michal Simek" , Dinh Nguyen , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Yoshinori Sato , Rich Felker , "John Paul Adrian Glaubitz" , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Rafael J. Wysocki" , Daniel Lezcano , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Andrew Donnellan , Benjamin Gray , Frederic Weisbecker , Xin Li , Kees Cook , Rick Edgecombe , "Tony Battersby" , Bjorn Helgaas , "Brian Gerst" , Leonardo Bras , Imran Khan , "Paul E. McKenney" , "Rik van Riel" , Tim Chen , David Vernet , Julia Lawall , , , , , , , , , , Subject: [PATCH v2 03/14] sched/core: Use TIF_NOTIFY_IPI to notify an idle CPU in TIF_POLLING mode of pending IPI Date: Thu, 13 Jun 2024 18:16:02 +0000 Message-ID: <20240613181613.4329-4-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF0002256E:EE_|IA1PR12MB8553:EE_ X-MS-Office365-Filtering-Correlation-Id: 026c0d2c-c4b2-409f-3970-08dc8bd54216 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: wpAcRtoaRu0FHZJuI5thsVcnXSdxajGxAyilAKnR2Qmjg815kf/WDm2lZLzs98GXq5SU4AtXyp0lsTORmNBZ4djbAazEL+5FTBXctcIWKOMqX+ldoYx7jRLKtJ/MmxXS//ztMIdhMCYvdrsVHkHjQXrOZ7GC1L4LB3chiLAlkp3ZWKuA7XIwFKvd45cEokn7LGbl4enmsUPER3WDCeVSiTSc2R9n6IlvUu07KR3ndWdWht/WRfJLH0FQl5aJK/+cKo3vPwsQZUbuQNIoWWtGQJyknbc1HZPiF3MKSFS4OjxCjiqAEWBR/wrEzUvt8BkjabF0bg1sDxbRjTKpjDQ3EyPNpHKTLRZrgnAyW3Tohlqo9UJug/d8+173xQTq9FEJ506qar8TuX8oNtudSTc1XPWYjhKObVBTCIOxHMbfcjHkldtvazrV3O/RievKgERqJD2ODDkwLftkgAidNqEIFQ89U8dd2WfH27aIzZJBsEi4Y54eJFRpoV0Sgr7dT4Qy65+R9eJKYcNMh9ut9qTR+YtLIn4rzx0S3jLZqW8YFsUaQtXWQQ+LHUQP5ee5jy9tu85ORNoaga1PrV5mVSCRoFW18DOShfRYM+GGq6fmob0Jv4HutTexEPFOfWS2MTWD68hYOT2HlSlQzDUyYy3G2rG29Ij7xJM8Hoki0ec2wr7D8Aon+10PLrHuOJpQzZfzi+f4B6ML2ByVVbl3E42DTqmmC9F044M+jmciBn59VolIOv1TwARUi5iN8UImT2q8Zk1qw1mn1MZXfRz+c6ULmOFjaVGAiatVezVFMyO8ynNJ1lh42LH7IBV3jfWuJzYqOt65bCjrAm83IcYVWXU7m+KTPoz70ZaVwBUwd/l+4wabt6wgnjyk94HLXsubh2OZZNZI3o4sxjpQEbJWG4mzb6YkqJ2oZgmtDEA8gftV9u526wrxQj0WfNgIC2yoWLBzhB0PCn5P+0GwzF8S49EUZCgtB766VvKaFeV156GTf/GCwTAMQXpXScJRPs4XOWiseDgJCNDqZzYxbr9UF839Aqa7LEs++2Zf7T70/rDcrcykqSwjhlpelEPpYep2XbgViJ6WdAblbqQH6p1Zi57SfSDAAITj6MIKYw3/sdEHP785vOz+6p73lQD19qyjACXxglZDgjKb+ngoNLo8iDajFFI1Hh7Qaf58orwWX/DISBU/aSfnny+eLkv1XIIKWuTA5Y0IfhwGS5uPRBrBdox9W9hXsFcDiIp1oTw2CO10kKa0/zUJkJYbMLyouzguyK+6VmQ5rX/UM5f+d2gON9lUp+RXg5bcU/0u3AMkqVu+WeEt9FdP7urAeCVK5XnNVxr/NrDPgXm5R18iqlik3x/wSBxarrNPaftu2feJEkkGkydv6igRfAcZndRpxaZIO8EHuq/X0Oy9Z0lY6L8M518eNe3jjb07dKjEHt8EQiOhN3Q= 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:(13230035)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:18:43.0159 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 026c0d2c-c4b2-409f-3970-08dc8bd54216 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: BL6PEPF0002256E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8553 From: "Gautham R. Shenoy" Problem statement ================= When measuring IPI throughput using a modified version of Anton Blanchard's ipistorm benchmark [1], configured to measure time taken to perform a fixed number of smp_call_function_single() (with wait set to 1), an increase in benchmark time was observed between v5.7 and the upstream kernel (v6.7-rc6). Bisection pointed to commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") as the reason behind this increase in runtime. Reverting the optimization introduced by the above commit fixed the regression in ipistorm, however benchmarks like tbench and netperf regressed with the revert, supporting the validity of the optimization. Following are the benchmark results on top of tip:sched/core with the optimization reverted on a dual socket 3rd Generation aMD EPYC system (2 x 64C/128T) running with boost enabled and C2 disabled: tip:sched/core was at commit c793a62823d1 ("sched/core: Drop spinlocks on contention iff kernel is preemptible") at the time of testing. ================================================================== Test : ipistorm (modified) Units : Normalized runtime Interpretation: Lower is better Statistic : AMean ================================================================== kernel: time [pct imp] tip:sched/core 1.00 [baseline] tip:sched/core + revert 0.41 [60.00] ================================================================== Test : tbench Units : Normalized throughput Interpretation: Higher is better Statistic : AMean ================================================================== Clients: tip (CV) revert (CV) [pct imp] 1 1.00 (0.60) 0.90 (0.08) [-10%] 2 1.00 (0.27) 0.90 (0.76) [-10%] 4 1.00 (0.42) 0.90 (0.52) [-10%] 8 1.00 (0.78) 0.91 (0.54) [ -9%] 16 1.00 (1.70) 0.92 (0.39) [ -8%] 32 1.00 (1.73) 0.91 (1.39) [ -9%] 64 1.00 (1.09) 0.92 (1.60) [ -8%] 128 1.00 (1.45) 0.95 (0.52) [ -5%] 256 1.00 (0.96) 1.01 (0.28) [ 1%] 512 1.00 (0.32) 1.01 (0.20) [ 1%] 1024 1.00 (0.06) 1.01 (0.03) [ 1%] Since a simple revert is not a viable solution, the changes in the code path of call_function_single_prep_ipi(), with and without the optimization were audited to better understand the effect of the commit. Effects of call_function_single_prep_ipi() ========================================== To pull a TIF_POLLING thread out of idle to process an IPI, the sender sets the TIF_NEED_RESCHED bit in the idle task's thread info in call_function_single_prep_ipi() and avoids sending an actual IPI to the target. As a result, the scheduler expects a task to be enqueued when exiting the idle path. This is not the case with non-polling idle states where the idle CPU exits the non-polling idle state to process the interrupt, and since need_resched() returns false, soon goes back to idle again. When TIF_NEED_RESCHED flag is set, do_idle() will call schedule_idle(), a large part of which runs with local IRQ disabled. In case of ipistorm, when measuring IPI throughput, this large IRQ disabled section delays processing of IPIs. Further auditing revealed that in absence of any runnable tasks, pick_next_task_fair(), which is called from the pick_next_task() fast path, will always call newidle_balance() in this scenario, further increasing the time spent in the IRQ disabled section. Following is the crude visualization of the problem with relevant functions expanded: --- CPU0 CPU1 ==== ==== do_idle() { __current_set_polling(); ... monitor(addr); if (!need_resched()) { mwait() { /* Waiting */ smp_call_function_single(CPU1, func, wait = 1) { ... ... ... set_nr_if_polling(CPU1) { ... /* Realizes CPU1 is polling */ ... try_cmpxchg(addr, ... &val, ... val | _TIF_NEED_RESCHED); ... } /* Does not send an IPI */ ... ... } /* mwait exit due to write at addr */ csd_lock_wait() { } /* Waiting */ preempt_set_need_resched(); ... __current_clr_polling(); ... flush_smp_call_function_queue() { ... func(); } /* End of wait */ } } schedule_idle() { ... local_irq_disable(); smp_call_function_single(CPU1, func, wait = 1) { ... ... ... arch_send_call_function_single_ipi(CPU1); ... \ ... \ newidle_balance() { \ ... /* Delay */ ... \ } \ ... \--------------> local_irq_enable(); /* Processes the IPI */ -- Skipping newidle_balance() ========================== In an earlier attempt to solve the challenge of the long IRQ disabled section, newidle_balance() was skipped when a CPU waking up from idle was found to have no runnable tasks, and was transitioning back to idle [2]. Tim [3] and David [4] had pointed out that newidle_balance() may be viable for CPUs that are idling with tick enabled, where the newidle_balance() has the opportunity to pull tasks onto the idle CPU. Vincent [5] pointed out a case where the idle load kick will fail to run on an idle CPU since the IPI handler launching the ILB will check for need_resched(). In such cases, the idle CPU relies on newidle_balance() to pull tasks towards itself. Using an alternate flag instead of NEED_RESCHED to indicate a pending IPI was suggested as the correct approach to solve this problem on the same thread. Proposed solution: TIF_NOTIFY_IPI ================================= Instead of reusing TIF_NEED_RESCHED bit to pull an TIF_POLLING CPU out of idle, TIF_NOTIFY_IPI is a newly introduced flag that call_function_single_prep_ipi() sets on a target TIF_POLLING CPU to indicate a pending IPI, which the idle CPU promises to process soon. On architectures that do not support the TIF_NOTIFY_IPI flag, call_function_single_prep_ipi() will fallback to setting TIF_NEED_RESCHED bit to pull the TIF_POLLING CPU out of idle. Since the pending IPI handlers are processed before the call to schedule_idle() in do_idle(), schedule_idle() will only be called if the IPI handler have woken / migrated a new task on the idle CPU and has set TIF_NEED_RESCHED bit to indicate the same. This avoids running into the long IRQ disabled section in schedule_idle() unnecessarily, and any need_resched() check within a call function will accurately notify if a task is waiting for CPU time on the CPU handling the IPI. Following is the crude visualization of how the situation changes with the newly introduced TIF_NOTIFY_IPI flag: -- CPU0 CPU1 ==== ==== do_idle() { __current_set_polling(); ... monitor(addr); if (!need_resched_or_ipi()) { mwait() { /* Waiting */ smp_call_function_single(CPU1, func, wait = 1) { ... ... ... set_nr_if_polling(CPU1) { ... /* Realizes CPU1 is polling */ ... try_cmpxchg(addr, ... &val, ... val | _TIF_NOTIFY_IPI); ... } /* Does not send an IPI */ ... ... } /* mwait exit due to write at addr */ csd_lock_wait() { } /* Waiting */ preempt_fold_need_resched(); /* fold if NEED_RESCHED */ ... __current_clr_polling(); ... flush_smp_call_function_queue() { ... func(); /* Will set NEED_RESCHED if sched_ttwu_pending() */ } /* End of wait */ } } if (need_resched()) { schedule_idle(); smp_call_function_single(CPU1, func, wait = 1) { } ... ... /* IRQs remain enabled */ arch_send_call_function_single_ipi(CPU1); -----------> /* Processes the IPI */ -- Results ======= With the TIF_NOTIFY_IPI, the time taken to complete a fixed set of IPIs using ipistorm improves drastically. Following are the numbers from the same dual socket 3rd Generation EPYC system (2 x 64C/128T) (boost on, C2 disabled) running ipistorm between CPU8 and CPU16: cmdline: insmod ipistorm.ko numipi=100000 single=1 offset=8 cpulist=8 wait=1 ================================================================== Test : ipistorm (modified) Units : Normalized runtime Interpretation: Lower is better Statistic : AMean ================================================================== kernel: time [pct imp] tip:sched/core 1.00 [baseline] tip:sched/core + revert 0.40 [60.26] tip:sched/core + TIF_NOTIFY_IPI 0.46 [54.88] netperf and tbench results with the patch match the results on tip on the dual socket 3rd Generation AMD system (2 x 64C/128T). Additionally, hackbench, stream, and schbench too were tested, with results from the patched kernel matching that of the tip. Additional benefits =================== In nohz_csd_func(), the need_resched() check returns true when an idle CPU in TIF_POLLING mode is woken up to do an idle load balance which leads to the idle load balance bailing out early today since send_call_function_single_ipi() ends up setting the TIF_NEED_RESCHED flag to put the CPU out of idle and the flag is not cleared until __schedule() is called much later in the call path. With TIF_NOTIFY_IPI, this is no longer the case since TIF_NEED_RESCHED is only set if there is a genuine need to call schedule() and not used in an overloaded manner to notify a pending IPI. [ prateek: Split the changes into a separate patch, added the TIF_NEED_RESCHED optimization in notify_ipi_if_polling(). TIF_WAKE_FLAG macro, commit log ] Link: https://github.com/antonblanchard/ipistorm [1] Link: https://lore.kernel.org/lkml/20240119084548.2788-1-kprateek.nayak@amd.com/ [2] Link: https://lore.kernel.org/lkml/b4f5ac150685456cf45a342e3bb1f28cdd557a53.camel@linux.intel.com/ [3] Link: https://lore.kernel.org/lkml/20240123211756.GA221793@maniforge/ [4] Link: https://lore.kernel.org/lkml/CAKfTPtC446Lo9CATPp7PExdkLhHQFoBuY-JMGC7agOHY4hs-Pw@mail.gmail.com/ [5] Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Russell King Cc: Guo Ren Cc: Michal Simek Cc: Dinh Nguyen Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Cc: "David S. Miller" Cc: Andreas Larsson Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Andrew Donnellan Cc: Benjamin Gray Cc: Frederic Weisbecker Cc: Xin Li Cc: Kees Cook Cc: Rick Edgecombe Cc: Tony Battersby Cc: Bjorn Helgaas Cc: Brian Gerst Cc: Leonardo Bras Cc: Imran Khan Cc: "Paul E. McKenney" Cc: Rik van Riel Cc: Tim Chen Cc: David Vernet Cc: Julia Lawall Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-csky@vger.kernel.org Cc: linux-openrisc@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Gautham R. Shenoy Co-developed-by: K Prateek Nayak Signed-off-by: K Prateek Nayak --- v1..v2: o Updated benchmark numbers. --- include/linux/sched/idle.h | 8 ++++---- kernel/sched/core.c | 41 ++++++++++++++++++++++++++++++-------- kernel/sched/idle.c | 16 +++++++++++---- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h index 497518b84e8d..4757a6ab5c2c 100644 --- a/include/linux/sched/idle.h +++ b/include/linux/sched/idle.h @@ -58,8 +58,8 @@ static __always_inline bool __must_check current_set_polling_and_test(void) __current_set_polling(); /* - * Polling state must be visible before we test NEED_RESCHED, - * paired by resched_curr() + * Polling state must be visible before we test NEED_RESCHED or + * NOTIFY_IPI paired by resched_curr() or notify_ipi_if_polling() */ smp_mb__after_atomic(); @@ -71,8 +71,8 @@ static __always_inline bool __must_check current_clr_polling_and_test(void) __current_clr_polling(); /* - * Polling state must be visible before we test NEED_RESCHED, - * paired by resched_curr() + * Polling state must be visible before we test NEED_RESCHED or + * NOTIFY_IPI paired by resched_curr() or notify_ipi_if_polling() */ smp_mb__after_atomic(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0935f9d4bb7b..bb01b063320b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -911,12 +911,30 @@ static inline bool set_nr_and_not_polling(struct task_struct *p) } /* - * Atomically set TIF_NEED_RESCHED if TIF_POLLING_NRFLAG is set. + * Certain architectures that support TIF_POLLING_NRFLAG may not support + * TIF_NOTIFY_IPI to notify an idle CPU in TIF_POLLING mode of a pending + * IPI. On such architectures, set TIF_NEED_RESCHED instead to wake the + * idle CPU and process the pending IPI. + */ +#ifdef _TIF_NOTIFY_IPI +#define _TIF_WAKE_FLAG _TIF_NOTIFY_IPI +#else +#define _TIF_WAKE_FLAG _TIF_NEED_RESCHED +#endif + +/* + * Atomically set TIF_WAKE_FLAG when TIF_POLLING_NRFLAG is set. + * + * On architectures that define TIF_NOTIFY_IPI, the same is set in the + * idle task's thread_info to pull the CPU out of idle and process + * the pending interrupt. On architectures that don't support + * TIF_NOTIFY_IPI, TIF_NEED_RESCHED is set instead to notify the + * pending IPI. * - * If this returns true, then the idle task promises to call - * sched_ttwu_pending() and reschedule soon. + * If this returns true, then the idle task promises to process the + * call function soon. */ -static bool set_nr_if_polling(struct task_struct *p) +static bool notify_ipi_if_polling(struct task_struct *p) { struct thread_info *ti = task_thread_info(p); typeof(ti->flags) val = READ_ONCE(ti->flags); @@ -924,9 +942,16 @@ static bool set_nr_if_polling(struct task_struct *p) do { if (!(val & _TIF_POLLING_NRFLAG)) return false; - if (val & _TIF_NEED_RESCHED) + /* + * If TIF_NEED_RESCHED flag is set in addition to + * TIF_POLLING_NRFLAG, the CPU will soon fall out of + * idle. Since flush_smp_call_function_queue() is called + * soon after the idle exit, setting TIF_WAKE_FLAG is + * not necessary. + */ + if (val & (_TIF_NEED_RESCHED | _TIF_WAKE_FLAG)) return true; - } while (!try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED)); + } while (!try_cmpxchg(&ti->flags, &val, val | _TIF_WAKE_FLAG)); return true; } @@ -939,7 +964,7 @@ static inline bool set_nr_and_not_polling(struct task_struct *p) } #ifdef CONFIG_SMP -static inline bool set_nr_if_polling(struct task_struct *p) +static inline bool notify_ipi_if_polling(struct task_struct *p) { return false; } @@ -3710,7 +3735,7 @@ void sched_ttwu_pending(void *arg) */ bool call_function_single_prep_ipi(int cpu) { - if (set_nr_if_polling(cpu_rq(cpu)->idle)) { + if (notify_ipi_if_polling(cpu_rq(cpu)->idle)) { trace_sched_wake_idle_without_ipi(cpu); return false; } diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 7de94df5d477..6748735156a7 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -329,13 +329,13 @@ static void do_idle(void) } /* - * Since we fell out of the loop above, we know TIF_NEED_RESCHED must - * be set, propagate it into PREEMPT_NEED_RESCHED. + * Since we fell out of the loop above, TIF_NEED_RESCHED may be set. + * Propagate it into PREEMPT_NEED_RESCHED. * * This is required because for polling idle loops we will not have had * an IPI to fold the state for us. */ - preempt_set_need_resched(); + preempt_fold_need_resched(); tick_nohz_idle_exit(); __current_clr_polling(); @@ -352,7 +352,15 @@ static void do_idle(void) */ current_clr_notify_ipi(); flush_smp_call_function_queue(); - schedule_idle(); + + /* + * When NEED_RESCHED is set, the idle thread promises to call + * schedule_idle(). schedule_idle() can be skipped when an idle CPU + * was woken up to process an IPI that does not queue a task on the + * idle CPU, facilitating faster idle re-entry. + */ + if (need_resched()) + schedule_idle(); if (unlikely(klp_patch_pending(current))) klp_update_patch_state(current); From patchwork Thu Jun 13 18:16:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804040 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) (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 01BCF14B07F; Thu, 13 Jun 2024 18:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302754; cv=fail; b=Ajr1WjaiGENLS6+dNIpAe76Sd3MNM3O3rDs+aVr4dcRfZyvzq6AO8qU4gYNyrDl9v7VRbX6xUOsUas/EDAEqxMDqCR7U1HvezPk8+LpB3/YLqHmb1W+ES356e3PmpqP574YyMMxOGfjE9wcTghB8tq4QJTmtRbAZ88MykCuBPvM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302754; c=relaxed/simple; bh=Sq7T97eYF/tf+lQ0VywpZcSaLF6cYPR0rgHDdOkxMjY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=djuO/M8fhZWdMJktD5JvNI1hSBhsCzxNbORIIgHyuv31xG72bAXWiEldTYC0HI3q/6EwmwYdJZzPughkFfjxde2qg+0FNPMCMp0bZmw/xBwVgugBcGf2sqZSniUuv/At9f+jk1gprQQHZHPF8RKYQpDoeWxXiwRB7yowSmjV3o8= 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=OOj1f0Md; arc=fail smtp.client-ip=40.107.220.75 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="OOj1f0Md" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W1sd9O42AdhbNTzKNuqGmHh2Nn4f40X+OseEjPmlgOytnIJK8mtZ0WqJjyy5rdUEEYzEbMxpe/L4qC/vPGslsiuzGamypl79SfA5Ix5EhUweH3KeecFuGEraRHuQJxB3URN5TphiY2VIAiUtgzU/Wrv7LcE795OaANeiiPnjOKB3JE9mtAHaB+3BkhsYyWFSiaHDRvNvpQvJWolPkJXql6IH0+kI93CqJ0Gao3G1FOXzWynbi9pPh2xeiOMiOSbf6xxcPqjhG2fOBEqohO1ugDXU8kFpYB97A4RVxiR58i/VBcpjUtz06TNa8kub9HVTy276zWel9qMzln+fY9lg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vradeM/yOEXyBdiiMbEOKNXy9nIsAdQb7sPMO3R7RGI=; b=kkQuW2zKN4zGXuXGQJyeJcDjhTEF/FbOXX9DT1OYG/3I5GstYRZ59ixKqFfspyEv929CvHVWzC8Stx2XiW2MjoepLLGBhaRufDvOca0cGWl2NjzeV0HX4twUUk3hXY8Vr85DKBEayM3JrTEZfkAffoC7RiJTwdli9hTYjCadYLgctyUgLDHKsGj+f9J3TyTn20O4sQT9GOIlb26yNTO/po/HMPFQieV2IA7UW6yvPEhqdBcnGbBAWh1yyBqNhdrTkSQtpAg2Wak7DTASrhnuTqwmptNxaW8hEzWXirPcrL6iyapXo24MXp8XqhBiBJz0zXavWynuiUmGKAlDR3nZ6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=vradeM/yOEXyBdiiMbEOKNXy9nIsAdQb7sPMO3R7RGI=; b=OOj1f0MdGvEG+6ROifgPjHgVV8nTn21fXRk/NDU6KiXSm/Q0lcgiPw3GOLSDh/LBtqsv7uSLZ2j6y90QXQxvhQftiUBUvVeHLOtSRm61rQzZwjn+W5rT9p1S5E4tCFCMIG40AMeY4KzVf/xc0HV1SqzniKjmmngIw4YKg5Vf9hY= Received: from BN6PR17CA0058.namprd17.prod.outlook.com (2603:10b6:405:75::47) by PH7PR12MB6933.namprd12.prod.outlook.com (2603:10b6:510:1b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21; Thu, 13 Jun 2024 18:19:08 +0000 Received: from BL6PEPF00022570.namprd02.prod.outlook.com (2603:10b6:405:75:cafe::36) by BN6PR17CA0058.outlook.office365.com (2603:10b6:405:75::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:19:08 +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 BL6PEPF00022570.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:19:07 +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; Thu, 13 Jun 2024 13:18:57 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Xin Li , "Rafael J. Wysocki" , Daniel Lezcano , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Tim Chen , "David Vernet" , Julia Lawall , , Subject: [PATCH v2 04/14] x86/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:03 +0000 Message-ID: <20240613181613.4329-5-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022570:EE_|PH7PR12MB6933:EE_ X-MS-Office365-Filtering-Correlation-Id: 34e246c6-4498-4d4e-3bf1-08dc8bd550d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: vJQtjhVjK+OjBdbS4kdrzEwygbFSa+0tn56caq0YHEFyowed3oYFyaWUFAvV37k4VeAX+ky9D/PdFg2juDdHIH6T3uav2N9qfN7mNCCnYtcLC+PcLA8ib/sSx5fIOGc6+EvTrp+LSXwIHXRu7109Sl0FJjGPLffMdhsqOcMY8N+8Lumb7cWEYIi5ovQ6qW7vuxQypHjLfq2WrQqCeFqKJZW2+b+GYbXNH4zXrcwKMGJq46zunln6e1XG9P4f6x75Gqwq2BeraMZS+QKzWSgtGdteQauM4vXF0VXyT/hUB5U32DTE48L4+NDfJu8hZy/uAXmMkLjHU4xcWTDBpPkjhcUmIWujjGtde9ynjzv//CxzIUyKWJFriRcRg+hbEAk+gk5QTAZ7pU1z+W1X1SrfSUSNWt5WtWJ2GZmt8kIdcynrATSK7658tr6MVF8LCDeH6vQE23zYvcD1I2Spm550HuIeUcbMF4idwdDHt+xzWFnvlUPmGQt0bHRzJPykxWWJ6uf6L3PULZYUwmkZKleqXQwYl32ijHRVTWfqc/j3VI5H4abJY4wJw++okiJiejui3mJ5jeoaLGTaxB/N852E/OZ24QR3che7Y5J433g9qU5mR5l/2HlOSojeAobyXEARfhxi5bgqNbnTEBOxU1FwCjMRcKslP5VJAacgso1wrLhzEPvSeYH4nVjoAc2AqiQGox3x43J6SHZ38MZd990QN/1Mwqc2wKfcV5ZkPxeo+gIZjN2+PU5QkmsVL+6t8Jcri8uCplBnu9o7HbtJVpbo3OfSJ4+ujZ4OW354JEqOjyZoIMCpfx6PC5h8rkZTNVHUdbi4IUVWO7BdDE50FHwAxO96Ljn/rFXXRvWZdqchmljpwHTjfO+xCov7pYbfkmcEoE49j6csjZCAwGZRmtggrW+jTvHq8lw82lqteHD3/b36h4UcNgT6tSLJp+iqvDe0Jbc0NSLgwI3qSr24WhtDpMFwYyYcOxwcI8x6ZmyGZ17gjdu+YlL5ln5/sVYiCVy1eusL3sglQZTyRv38bJkyy2xao9FU/RKQx3RCl8fmbLo8QQxQd5y4mNQBOuwSzU0X4RawGyODwzdITJLI2B8n3oen5AASwAWZ6UyB8L9xzuL6dOKnyNfVdvpOJu+b1IRrn3Px0aT3xDx2MTae3h3+rub9YaVWXuLKk6N2K/qY/3lCDppFKFlDDmShqO9D6Qhbzs3EYKmOjzqZtEvOGVft+C6ESQALyz/2CuQeE+p9OTxcywCwxMZuXNxmZG6m0OIDrFq58a2RKjEPRZPWVz2+nlrAwemiLjFHmwCzLkJdy69b0z8sjwRrHR0YkHWi3SW69ZmOxGOE3VcU9uS92YtW8/NFdWLmYf5Rzqz3kWXt9/gI3OspFfdXqbOr7CTSkA4x9VFOkUrfkA2wUwPu5ZZVTg== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:19:07.7689 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34e246c6-4498-4d4e-3bf1-08dc8bd550d7 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: BL6PEPF00022570.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6933 From: "Gautham R. Shenoy" Add support for TIF_NOTIFY_IPI on x86. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. IPI throughput measured using a modified version of Anton Blanchard's ipistorm benchmark [1], configured to measure time taken to perform a fixed number of smp_call_function_single() (with wait set to 1), improves significantly with TIF_NOTIFY_IPI on a dual socket Ampere Server (2 x 64C) with the benchmark time reducing to less than half for 100000 IPIs between two CPUs. (Note: Only WFI idle mode was left enabled during testing to reduce variance) cmdline: insmod ipistorm.ko numipi=100000 single=1 offset=8 cpulist=8 wait=1 ================================================================== Test : ipistorm (modified) Units : Normalized runtime Interpretation: Lower is better Statistic : AMean ================================================================== kernel: time [pct imp] tip:sched/core 1.00 [baseline] tip:sched/core + TIF_NOTIFY_IPI 0.46 [54.88] tip:sched/core was at commit c793a62823d1 ("sched/core: Drop spinlocks on contention iff kernel is preemptible") at the time of testing. [ prateek: Split the changes into a separate patch, commit log ] Link: https://github.com/antonblanchard/ipistorm [1] Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Xin Li Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Tim Chen Cc: David Vernet Cc: Julia Lawall Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: Gautham R. Shenoy Co-developed-by: K Prateek Nayak Signed-off-by: K Prateek Nayak --- v1..v2: o Updated benchmark numbers. --- arch/x86/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 12da7dfd5ef1..640ee41b8c82 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -89,6 +89,7 @@ struct thread_info { #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/ #define TIF_SSBD 5 /* Speculative store bypass disable */ +#define TIF_NOTIFY_IPI 6 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_SPEC_IB 9 /* Indirect branch speculation mitigation */ #define TIF_SPEC_L1D_FLUSH 10 /* Flush L1D on mm switches (processes) */ #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */ @@ -112,6 +113,7 @@ struct thread_info { #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) #define _TIF_SSBD (1 << TIF_SSBD) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_SPEC_IB (1 << TIF_SPEC_IB) #define _TIF_SPEC_L1D_FLUSH (1 << TIF_SPEC_L1D_FLUSH) #define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY) From patchwork Thu Jun 13 18:16:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804737 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) (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 4FCAB14A617; Thu, 13 Jun 2024 18:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302774; cv=fail; b=GAgwLFT5h79ftywInYsB0mIQ5qinZMU+kyBX0PmwfsRaIjvazdrCIcLaqQdjL4AyjEHGIFjX4ylZCWldM+jnlkMCIDVa0eAOIIxWY4qBrFbVgsWJQSR2MA3Cu8UGRlKiizz2Zo+hy7lMpYSb68UyvXQDjexlwPeZ/ANX5PoT07c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302774; c=relaxed/simple; bh=N5Xs1gHFtmRB7g78aJer3bDzIFfcfTiplMLpviSEwbc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gJanbrmLSvvfNKeuiHze4/joyrRKYTqQP30Apg5kj3ApKwlARjgN7qj1QkPQT8r4S6o+nx+qfjuQ/3zA3gSj0GsNa4ZDsrixJ2QWBLdSHs1lN5rjnIKoKaCEzs1DY2kro5L6jkRE+RyMT4jreuBexmpFn9gAUOrj628CeeRpAg4= 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=JNPeXEKc; arc=fail smtp.client-ip=40.107.223.71 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="JNPeXEKc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HJGYjMM7eq3jcQSvLjD8JwilT4BLJSY73LwPGvOT2sRjPx8AyWl3zHvGGWlQ4/Fl9+8wgsIsx8GzkkGgsQxdsUqeXbb40NfWbS8WdfrfNqVkKryijt127SyoliHrc7UOFLnpOl+eYYp/CAtmz3Nw3lhZAF2A5cpoV6XlJOpGGqiVlf372U6s0JlRjnh+2H30lG+1d6roU4vbaHFbkC45bbvE6llmDcyzshi51lOaRrp48ERwWqVrUcTdDgdI8wHzRPPL0Me2BUffj6GwtvoKUIecrRj+MHoXQVT6hUbPXCxc1qIQvcVOZvsXibXk/JGRL248vJ4AMQF+8gxX9Us2wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=y9SP91OYsN4ihnOgSl0XGZN6I6AzoKAxRQI+tR3d6Hs=; b=c9xwAg3FwSKdaIT9eqQ6NRhwq1Q4LOmU43uPgxyZG7ar6powrXDvWEbQ5UuWsARb0E7gVPvUB6upzpoJKRJD9pYUG6ksZz6Y6HvJJNv0IMKplWAet1XSHvZjgPB15GJ1oZ/UoPN8sC701o6jknPs21nlt+dSK1J6Aa37iw92GgZ7HRRl5jE6Xw2aUfH6cEk0jMpt3v0VZEHNZOUnfAbKAptJZGJ47kAD532PA/acMjfm4+ObMZSaEhP3Kw46aNlvN7WuBCQWc8WTFLSY1CR+xGHLuJqnlebIceYR7OPhm2w+GoLp2VJyIBnf4skPg/6/pkYGeaty0vdcuBEowMSIYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=y9SP91OYsN4ihnOgSl0XGZN6I6AzoKAxRQI+tR3d6Hs=; b=JNPeXEKc8NKZzjLLfZoFr+HwwT04qggrDt65S0suHbCGHWKm7Op3xhA4fXldfVXnn91htAQtmWHbdXnAjbb+LIPrmEatVnLJPC+/dh6j+xCJ9fRoFYqt8Xet4VyZFDxm2HFM2rsS0yxjXcaA3zkr8sTZ+baWl0LraZ8w/+VhC2Y= Received: from BN0PR04CA0078.namprd04.prod.outlook.com (2603:10b6:408:ea::23) by LV3PR12MB9329.namprd12.prod.outlook.com (2603:10b6:408:21c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24; Thu, 13 Jun 2024 18:19:28 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:408:ea:cafe::ac) by BN0PR04CA0078.outlook.office365.com (2603:10b6:408:ea::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:19:28 +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 BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:19:28 +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; Thu, 13 Jun 2024 13:19:21 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Russell King , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Linus Walleij , , Subject: [PATCH v2 05/14] arm/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:04 +0000 Message-ID: <20240613181613.4329-6-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022573:EE_|LV3PR12MB9329:EE_ X-MS-Office365-Filtering-Correlation-Id: b58a1efa-cc9c-4400-5bdd-08dc8bd55d41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: QSMgb8ovqqse5ZaPqQTz0yBg13jzsXXirtTTAwCByqjVrdbx8B4DXpyByYui/PENqw9xk+Tmshrct8X2ufQjxA+pKfubOaEpwRybZGdlKoykr1dNLCAmuLP2DCR+60GL/CuIzRfi4ntV1EyOQOrFpbOL2YRVJWs2NgQ+tDxPKIcc5pBxLWxfqhwFU5VsuBF416NMH1NU6hhbmwitwh8fdlhNhXDo8rtCWBAz+scgA6ls2xnROIcpmfvymdxT/l8l5kpTWoay7KqOLMFQzZEhk2BF0b6AHkWLfmFsELzxTeYrf3CERm8Ndp9DHepQqtiiV8ptxpN8HOLNWbBkJdtyR6XqZHlgtSgQurCE2/VhyglqH/fOneUL4tZukDKmO9H4MOegldjT9W3csUqXg6D4q5EQXFwwYW/T75keqhOxq5gpRVxNZQMDGmJgvzuTgtsZsrIuwzq2J9OvVd/hS96oDghFgU0lDbenghlIE7RiWADkGy+w31rORyLzfnsxkJ0MeaaRw/EQ75hXK94wle973hhuLrtIovlpvYJfJExsgAp2Q0ONQzds52YFoQoEKV93RsWsd3PhbqCx4hpq4vXq5YYMa+Zg3pH/zBp7fHZZc6vfF0KXZyEGIn7c2CB8f2h1MJCEy1lrZJJ5hUhrr4UiIkKHLuS1c9ioJ/qrKRAjrMkGfmkTBjGAnJU32zh5d3+v4NekF9b4Up17zO2SvW1IQ3dhk37xXJY3ANiUaVi2CveOQwuzqM1v7g0r9nFJBSq820OMuNRGK7HgUFA+4lTf2Z/n/FxUIvlHxm6sj29/op23+oh8vuICBzd+neHvbNe7iD5h5qmjJP8Ha1BIupPsdhcMwhgQ2Lpxur4WUzTIaSw/3z1ZblIUnKR9flt35j3dnWZnHkp/pSjIWrQb12GWQHi+0Q+ktrECda2TQCNrkiCssiyLb7LexLUukwCPft87Ex5EBMyDXoofXBUNs7oXMavfWql6a4CZFobsM0A7T5HvL5L9BrciTGwjV9/w0Z7PRJ0L+UQfJDUJDw+KssTAC5Vox6KiiIujs0kpyQJwgiBvK2LNv9YBCA/Xio2IpD3lwZyI2rgSFr5ri4KuEQ1HQ/vDP1OcI+JcPXdfmEGuNj0JNhtK2kGc9luv3RprBQOsO2M4OMZir1o2+9CJUs/GfipW8vjdehRhvJICPqLSOzoQmXmF/bCilkqdCh+UwgnjonvIFoLd52ZOTr2uAi3pwEzyzJESh5yihqDRDzIF8g7/zQ+6BItpE50kshThI1BpsRt8vVnlz+Fh/BQt9Ag8lT2t8dZrXiTSFcrZm3urfqED7A9M5dx7UuI35MPsxvA7pHNR63qRjbm4bm+WjbbBxTdfYt/4w/R34topmOvOtyv/kIvZ3ZK9+dkySkoyFCwK8S7xOIWk+fJEsUX8rhpNYg== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:19:28.6283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b58a1efa-cc9c-4400-5bdd-08dc8bd55d41 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9329 Add support for TIF_NOTIFY_IPI on ARM. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Russell King Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Link: https://github.com/antonblanchard/ipistorm [1] Signed-off-by: K Prateek Nayak --- v1..v2: o Dropped the ARM benchmark numbers since I could not get my hands on an ARM64 server internally. I tested if the lack of TIF_NOTIFY_IPI triggers any of the modified path or not on x86 by only applying till Patch 3 and I did not see anything unexpected. I'll update the thread with the results from the ARM server [if and] when I get my hands on it again. --- arch/arm/include/asm/thread_info.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 943ffcf069d2..324248d87c9e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -136,6 +136,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, * thread information flags: * TIF_USEDFPU - FPU was used by this task this quantum (SMP) * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED + * or TIF_NOTIFY_IPI * * Any bit in the range of 0..15 will cause do_work_pending() to be invoked. */ @@ -144,6 +145,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_UPROBE 3 /* breakpointed or singlestepping */ #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */ +#define TIF_NOTIFY_IPI 5 /* pending IPI on TIF_POLLLING idle CPU */ #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -164,6 +166,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) /* Checks for any syscall work in entry-common.S */ #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ From patchwork Thu Jun 13 18:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804039 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) (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 18FF31304AB; Thu, 13 Jun 2024 18:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302800; cv=fail; b=ZYrS31Ljdycnv2fCGyi70wt+kJLGd+dgeF51q6+WEFocNaGfX+9IZvFmIzKO5+LxR48ECAxjlFCRgQRg70zN6JTJte1MmTEQriaUQPdns3e7F+KhPXrIW71jyHsTHS5JyN9TqGdp5R0+OUMsKT7x1tWMhgfl7JQBg9e8rTemiVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302800; c=relaxed/simple; bh=eWXUvT6vKe4xd0Za0lJZERTKDaQICxuWyE147cyZAxM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u5knTWqHhV5WjvsaPPuZR7ktz/VwbITClsrjlXuHfdByuFN90SjjyAEiUk5jeXy5uiMz+Y+WbyDWcozIpIj1WRJdRae2rOiE1jR9FqPpFKBEwEXYeD03KIxZFpzqHJSe+0MPMpvCsogr8zAAMinAs9BhzIDjasJmldAlVYuqbkE= 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=w32DuMEQ; arc=fail smtp.client-ip=40.107.236.48 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="w32DuMEQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fyTJQNQQMoGz+Nqmi58OEvVVAHyML6wHWhWhbopx/KkWFjzCA8PUFCt+MDJg5gQ8Rc2GJ8fFlXtRhpRII4ln3VvINLOF+SBAicqc738xRME4uehEVnaQVrt/FYvfAJZQaTu6IljvWgYEy+XynQaO5ulknp9aNpQmXhb3JFlhQDPFeufiLFJFkU7tnb6Kp77C3HAdTQtP9bkzT4JIzV5f7d1zsPx0WeDH+p4J85lwHBvPTKLzH++b2T1E57ZzLbA/ydE6C+6y8DKDqr7zTUo2YemfgTNGn5+2f/2cvQRu8Xjsz7KA2TnIWrzcCPUywf+WEFrlLn0H63WkyF+Kw9aT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=I9I9g5gYsnlhoA/IM+nU/HeTT4PLqMTpaOL8h1gEe90=; b=KHpbLjGZXvzXHdSir0g8PrHGIGISZ+JE2iIMIlpA2l+MyMyOzkWerK9SCvqA6sFrMdcTVUGysXZmqUOmrJFppPuPDqpWfpI+L/Cc4ku187tuEw1IkdKOVw3hRGaDPiMlvzxxZ20oQ4XFpxXoDE3CGUBriiQvb3Bd+amA7s10lT3Mr6HpnW2ZodZy2giQeS6nmcdMTZSDE0blnZu6GtYuqmgYtGi4DcY2iAuODanrqMjDgjETovytqSg1HvdHv1DzFMMCr6X4OkTMIEKQR4dVzuuQU4SgCV5zfmyqk86tbAauINZwbokPPvPpIUMcdKMdIDR1s7tINr3AMXArWWLgwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=I9I9g5gYsnlhoA/IM+nU/HeTT4PLqMTpaOL8h1gEe90=; b=w32DuMEQQ9H+zGP/JPYHmYlSdv4ncOcOlaai7uTB4VoA128zdFPGPPYtQw3wpCcz7t9MAWDAr62ny+jf+A494lYkaWcnw52JFlwwCdIs0UU25ZcAZrmdrscl90vg9NhKRRnR11zc1NHd0XEWx3NDGCVZC7Fjw7bsXhZzNe5MFhg= Received: from BN0PR04CA0088.namprd04.prod.outlook.com (2603:10b6:408:ea::33) by SJ0PR12MB6965.namprd12.prod.outlook.com (2603:10b6:a03:448::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 18:19:52 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:408:ea:cafe::e2) by BN0PR04CA0088.outlook.office365.com (2603:10b6:408:ea::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:19:52 +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 BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:19:52 +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; Thu, 13 Jun 2024 13:19:44 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Richard Henderson , Ivan Kokshaysky , Matt Turner , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider , , Subject: [PATCH v2 06/14] alpha/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:05 +0000 Message-ID: <20240613181613.4329-7-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022573:EE_|SJ0PR12MB6965:EE_ X-MS-Office365-Filtering-Correlation-Id: 619af86d-7f85-4719-0d5f-08dc8bd56b3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: Z7jO8jP9Km2kAlC1/djKj9w4myZY0Ytn6OJ0na6rGWw0QmwkzFY3UrquI7j078+fMrAVhm9c5S/FSB5K+DcdsHeCa71aHfk1ndFDJvjAdD1MjkAozH0IEgXY73e6zSvEHkgYNg0ZZ3iug5JMpe6vATa0cakQ7/kE+HcDRgLms6FUg0jnQECTw1m3bsbP3Sh+KIdnXx/2ANTc/0um41TNHsHTPeFNVhMfCeH7Qhq5RnJ0Q/iKprDxtSqnYwO8FSc2pLDLLxaCtS3lo9/mmfu2MxDk+UeM00vsLKbw4qDwgQaNqgTgrb9IQ2Cvv1ciVPBh/pCogzVzoFIaPwvFNw2GiCS2lNFnnkxkmLu76Ad+nfaG/W/n7WpF9Ef7sfe3tI6j17HiyGbxr++laYkc0FaOeNgJt1bl3QyKk7pSRLtzYZpWbP1wmIRTBsnvJztPNqacy7+Nl+543osgCsiAxpHaFrSFdRXdmezJy58IfcShLopzh6b2XfuWTKmfZv52HXtBJHA930I4wliXNw2m2rCMHCk3AbkRy6jne80miu6mev2QjcmPYPMxoSfn58/7rq3mHKQTsTgD4y6bNtVpLzIS37OipowQsiQRuyDiMChLeaCLDJmcUk+m+YOoGFI7EmRCIJHnsx4rIjB+0XBw/3rsQuREvIRsqExvY169EuPIzZBVgUgkDlIDLc6jY9h0mnZVqlV5aZAbtXsgCbJJVXqljgw8OGq5zVYUnnEsD1tfL02AlMjbCasaUEoSO52Cd5snbSzOMQGrilC8KQJFJXxBz7uQ5B7jroBvPHAYsZQAOds+oGO5TpWoYkl86Wr30dpv4FZT5UQi3LPgYq2msJ7hHK6YlmcxjInZDLwjZVZbI+Cw1yL40PiLSawaYjDUUcHd3R5EkiXEGGwJMt8D7D/Vm8Ic8kXgx/HYRHiD3L3kZQvtlXcQNNgkjL7LBIzZ6gPT+8sgM3K6sIXmCgwuULASEppH9VfrhQ5ovJvZVK97P2oP4AcURjlKV3+1oX94M1JGsmjNa9wyEbD2gZJ1jgxnU1azrym9UEyJjBJoO9xuyZEQQXys4e4c5s0s4IFzfHG3+r6FOoG6xVkeDQ9MvO38vhgRYHCxxT2wslI5DxHlDkgYlojh98NsqA1RF6QYelVUtJuS3RvljlsOLZW/1y6o+0U9muUkmaXwWxhkfuk2asOMFlbiDDMdenqYcbY95drJWdSl4z/8mrfqIdoJlimNdT+4v+EmfNU9C2Hgf5oxthmFe08twHeXVadJnwzNgWBzSW/DihQYlB4sgWht0GGq4ryyksW3t/GGfOF83nWj5hZPLMort01BrjQN9JnpoREJA1dL3ieRRhjP4YRwvdqqQL3xn2MW9tk93TTaFFZF6ybTp+l1cjrQlfm3fE03YZlqqQ+v/WyTaa0O2hAVdMKEGg== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:19:52.0504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 619af86d-7f85-4719-0d5f-08dc8bd56b3c 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6965 Add support for TIF_NOTIFY_IPI on Alpha. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/alpha/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h index 4a4d00b37986..8c17855c85c7 100644 --- a/arch/alpha/include/asm/thread_info.h +++ b/arch/alpha/include/asm/thread_info.h @@ -64,6 +64,7 @@ register unsigned long *current_stack_pointer __asm__ ("$30"); #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_SYSCALL_AUDIT 4 /* syscall audit active */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ +#define TIF_NOTIFY_IPI 6 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ #define TIF_MEMDIE 13 /* is terminating due to OOM killer */ #define TIF_POLLING_NRFLAG 14 /* idle is polling for TIF_NEED_RESCHED */ @@ -74,6 +75,7 @@ register unsigned long *current_stack_pointer __asm__ ("$30"); #define _TIF_NOTIFY_RESUME (1< X-Patchwork-Id: 804736 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) (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 F409C14B08A; Thu, 13 Jun 2024 18:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302823; cv=fail; b=GySBefZVp7SrgtUslK+AWSZmrrPOsrFCnd85AlBSjPEJvtwzFzn3rtnsy0UIartsQ8gHNLs0EM8YzYpHxraodtZlijiu6xA1qy2C11L0EOgNaCST7VAycUsHiGMrDFAgwLZljNxlGwXDmK/pRl8Fvukd17mxAJAd7BA2bHdK7Mc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302823; c=relaxed/simple; bh=UkD26qGUOlcbxW/8s97Eb2Dvahx8fBscroVhbsYpork=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WnnAL3U6onKAR0Ug30OYEezdQiIiYxiZMf+5davBtUaM9E+fAz9lKDW5wrpE9zeHk280hAFAwI++uELVWx3+0K39R2XKht+gwgFwk0BgXN7k5B/xyA23CffNNAxUi2Lk4Gom80N6MoXk1uU82Uj+Qh6tmQLywqENXw7flJkHcYc= 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=y5Z63C0k; arc=fail smtp.client-ip=40.107.94.77 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="y5Z63C0k" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mikHzaZEujTr2nRiCyzGQFI8tjoQyhFH3UbRZpTe7OpbKoR/mKeUPtaMCaYbjfALVWbIY/Qw5yPxn/2JibJ9fJzylyKwSMEOyKy302GBuBTA5kuzdNuXiYGD15fDnpoBGjbshp7JE4lOx6dN+E4u9uhbOqXU6sdqYllNd7CnWUNfYF9xtHMIspIQiMndPXMlBFrl1UNmgSw640j8vrgXgWUZcXRhvtTA2vMqhQd02J1OvfygsiH4rErbFFY5Go4+VlPo6eUP162KMD4SNeKEuVmLW36hQNGZhNVPg2ucyxE044P01PAyzDJpIbbQ6X/Buwi0P1ehLTNbZEusAEk5pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=tdS/HlgV2qB5FXuFxAuMWLTfcJ3kk8B4HY4EB+i9Fdg=; b=HFOdntrp2QHhe9luFIc7NeAcfZ9IvHyBS+oQBacjeP1buEbaP3zPT3RDSN3/E+q8G4s3aRS16Wj0tCV9Q8ssxWlA3fG5kFRMtmk9capJpWYmP9HnXfgx/uBbKp3ILX/s+MioLLs4A9u4aYeoW+BGDPVmv9lekZ/HgQH7G6fHRIr2vBcXDKTLrmOsVUIglfv+n+njl4ZcPyxVn9vtNmhEcCjws5Yo1lN0L2jWnORLoDlSYPqq2GApCjvgI0SFreXMK0gdwMtZb0K0iV98bc9wHHNcYhNtEN6G/tYWLFtP+FfkoUm513GvR4SbfYvmWUYl9nrUdOCZqXgqRctImNzWKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=tdS/HlgV2qB5FXuFxAuMWLTfcJ3kk8B4HY4EB+i9Fdg=; b=y5Z63C0kMwOjNaJ3oi2fdUE5X9zKgEnglH1v0CnXzhF1QYwFnOcWPBANjg7vsoZ5o1YDE6+tTjICQhiSM2/Nx5MyztOZE5uEQddKzU6jHPP/RznTrdtLIjn6SHOsyGS7RTTa6fW+fR81KJyHRU4oL3ZtmnA1WVYHMTHEuw3hOhI= Received: from PH7P220CA0045.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::17) by MW4PR12MB7381.namprd12.prod.outlook.com (2603:10b6:303:223::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21; Thu, 13 Jun 2024 18:20:15 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::5b) by PH7P220CA0045.outlook.office365.com (2603:10b6:510:32b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:20:15 +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 CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:20:14 +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; Thu, 13 Jun 2024 13:20:06 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Jonas Bonn , "Stefan Kristiansson" , Stafford Horne , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider , , Subject: [PATCH v2 07/14] openrisc/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:06 +0000 Message-ID: <20240613181613.4329-8-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CY4PEPF0000FCC1:EE_|MW4PR12MB7381:EE_ X-MS-Office365-Filtering-Correlation-Id: 59e11ef9-d14e-4b17-2da7-08dc8bd578e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: RrxikFt7BOyQQWIew2F9KO19qH6m3C4Hk7nqsmujZYLb5gzSPR4sbHmDK8OA9MA5BDiM7D3D8LJ5lvkYDWcDb8S7L9cmMMFhGD7rO3CjZuhSp7SS+Fy570usyArnOa90z4moVf7URNQkmhnxQNLJ7iPDRc3GpTxGU0U93y7efeuyovkrrsyyxUNapkAFtWdlsLSBE6OJhfcjejqmXnnAGEtPJ0BW5uUEjTGVnerbktsnHc3Uc2bpvL8Q7GAisZsX3NyAv0fBFxnoBBV1fVYZNF7LjF5bBDH3D9Pghxyl3nLcEJ9c1aN3oyBLTDfmiS4dMEIAsJoRynAj6c+Bs4UPAz5NZldMlSRltWeNEy7oxKN6bx9ycmfQ3Efu7VoMGAe6eoYNJNA6PVzm4vr25TfkUVvbfvS3tJgMRgvcV+xQokozDQKSuRm1nr+5k0rIDhNW7aW01Tp+RLXqtwAf1EI15Mmmp5XlTdLp8yepQ90xs2IRzBmMjZj9Lq7YqStOtKEbB4TMbXzL9WC+Q5aaMcxlheJ764NOI03v35OMeELSk17MufHhPd2gTwVEky0p1TqoWH7q2WvfejtrAyR5KeNh4HxbDf7W5JnFEunqP3PQYYTnA+aHO04lDtpCh+oXi1qM3gmAC6ByATE/K4J2sXiXv9eJzUgZ7+nuSCtK6vIfiFzZqeQ41DdSwyTF8oyVV+3E/NxLY//9iDPlA0W+c7fLxsyXUckMmcQBTbes2g495Dc4ieXg75VEfRIZfHYcUR4j+sJ62LvxPFnQqXtCxqXM7NhLGwpUJZBK9jwje9BSTko6bt7/sxNCNevIuXZFBV4KjbV5n/tEsqtXvNBSu1/+Np+9mBrbQj9jIi86qr+nZuX9drcAgm94oOShcGuZZyA1ob4Cqm0qTKwpPm2SDkSq29HeU+v2bbYmQbrfIDgazCE79K5qVI4bkG5OYcIAzh3x+FW+fxJvGzcn5fLau8I8pT9U++5SfaB2dIwXloTuvB27Cnr9piNiJAUQZj2jh595snJ7KsIOuHretMC3smnNAOKWb072Hx7WJcGOk1TgK3HVX7t0gcPgkpOwfBaqfoXKCwC5p9y59Y9WcobNWgfh34YyLmQFK0s17MS8HFtTmHdfYEmnuS6yGh5Sq4QQwvWVHv+KDdayiqY41DL+WqwU9B45jN5poQbfOUuOBEhO+6YSf4Aayv3tdy5wYysH9ODm+0LKBwNmtLEnLLafyoC//heenqUmtTfDx0NoMRfPkX/gh+DKuYPTNjVAkDTxBKsW4vI5W6tC/vWagkanODCxmEdy7m3sI3y0aQbf4zaRQoRcEqBJiqyiuZHWpA/aE+EjG92JDOpkAau9AXd7bv875MZPBP8VgiXGKs+q7QEbbXdNvTbMys5eeFaglRn3f9JhJEdPE2cRKdw2qV2kySWeMw== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:20:14.9404 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59e11ef9-d14e-4b17-2da7-08dc8bd578e3 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7381 Add support for TIF_NOTIFY_IPI on OpenRISC. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-openrisc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/openrisc/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/openrisc/include/asm/thread_info.h b/arch/openrisc/include/asm/thread_info.h index 4af3049c34c2..6a386703bc43 100644 --- a/arch/openrisc/include/asm/thread_info.h +++ b/arch/openrisc/include/asm/thread_info.h @@ -92,6 +92,7 @@ register struct thread_info *current_thread_info_reg asm("r10"); * mode */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ +#define TIF_NOTIFY_IPI 6 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ #define TIF_RESTORE_SIGMASK 9 #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling * TIF_NEED_RESCHED @@ -104,6 +105,7 @@ register struct thread_info *current_thread_info_reg asm("r10"); #define _TIF_NEED_RESCHED (1< X-Patchwork-Id: 804038 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2057.outbound.protection.outlook.com [40.107.101.57]) (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 11CE81304AB; Thu, 13 Jun 2024 18:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302855; cv=fail; b=kQ5Wmj3vLHcfk+rmYKd6o3XBG8Hx/Gi8T9HsEG6USQzYtRtA2w6XDDOQDnrMPUm2XKtrlUZkWTj2ga63jVqvbvQGwlF40SEHV3bYHeGRGnIPyM0kOpxAAh7651MY9eCfJvDWU1n/ODCI2Ln4Pw4XTT6tI0UvxhIND96/DmyR0Us= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302855; c=relaxed/simple; bh=qytKDN3EtkGkahzWIVIvQfYd7kZcs17R55B362wW/rk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ph3nYpSAz0Ca6VB2ytcTu93fSMo9cEu2JTIeAoO9ZMMDiEk8y2degV6eYAEuzTM0D3nVPnel89jrOBuF2+frEmy01dw4qjmBqVED6Zb052/CmeubEVomp+vb8CJiPvRUABVBQLyBqWIvZYVT3qlqd9dBeHxh03VJvWZHZwhng7s= 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=mkgk9vG5; arc=fail smtp.client-ip=40.107.101.57 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="mkgk9vG5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fRXm/bjXqtT0foH0NjdLr/fqwagcIwE6WH5yeUXUXsyoMwEdRfYBvpEuPK0WDZl+FKwQdY/oSczSXh3EQ0DxTSXSJV1jKmATDH9ncxZpDcB0Uh8sVjc66qqmfDef9NDQcd0VbD2Gbbs8PjnxRDIeMnIPUM9Ksp9RQR9yD+r6xeYYema6gWohlGmxDHU/jAgR1rM8zThcuA0qxNRG1vEGzBye+OHJXI1vCT4p+rMjz3RPnJgOQMrUc5HkFx8R3NOLbPQIep/NysSYOAtWOOvHOFiu13/yMXqdibULhkB5RnL5ih0NxP8h588Sfs7UnBK9Ouk8IW2FnPOgYT0baIuFjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=/hs7C6zIKGEaHPiVxfq0Cw2LOk7ro6TzKuQqWBKK9DA=; b=Gmzwkktn7wGL63ofnyog4U38MgaLJKuFNe+73MRm2CNf7PExdJhTNs6RQVRbKRmxEgRHMgOzlck9RGliGmuvn+aDC+r0yWRjyPbqY4abbodBhfMZIQJN08hXctz8bJE2opytcYOCf6h+OpSB3dSBoh3NlsemVVCu77/pTlVsRsV1EkPjJrDPUjSa/Jr3/X3/yT53yw1XbDlKW2SjHkTbiGCqT4NUMhS9DNP/zL4LQcV4MJEsY13TN/QYx1ryK7fQO0k4RPj4imG7+wWK4uWqDYatvwXcK8EOSZkzfTds2cl6gZcgw2e6N5WKY0hh+4FOQl0LEdbumtQHZu/MZ8jVDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=/hs7C6zIKGEaHPiVxfq0Cw2LOk7ro6TzKuQqWBKK9DA=; b=mkgk9vG5AUFrfzSUPBKrYX8ckVOMvRxYdHNZMYfcn4OVDQGybfOiQywUhM4qj3AjexYNsWCbi1tldh8eqoNNpTYiCFP6mWUQntCt0nOo0CHiIeTAU5Vo7OQ2wCwOWsn+Ta4EpygD22TOsUj/b0Ex/Vp74f1HXkBe61Fwz2luaY8= Received: from BL0PR03CA0010.namprd03.prod.outlook.com (2603:10b6:208:2d::23) by CH0PR12MB8486.namprd12.prod.outlook.com (2603:10b6:610:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 18:20:50 +0000 Received: from BL6PEPF00022575.namprd02.prod.outlook.com (2603:10b6:208:2d:cafe::35) by BL0PR03CA0010.outlook.office365.com (2603:10b6:208:2d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 18:20:50 +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 BL6PEPF00022575.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:20:49 +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; Thu, 13 Jun 2024 13:20:30 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Michael Ellerman , "Nicholas Piggin" , Christophe Leroy , "Naveen N. Rao" , Benjamin Gray , Andrew Donnellan , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , , Subject: [PATCH v2 08/14] powerpc/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:07 +0000 Message-ID: <20240613181613.4329-9-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022575:EE_|CH0PR12MB8486:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ff126d4-e81c-4574-f65c-08dc8bd58d9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: sPbGW6F6ZoKIgzR2KqWIPjeRkSjKDDXRUL0DObH8QPYw5L2JcDPcK4Fju5qNTtuxY4gPP/bXLv63ycKdCoqehGe2K5mMROEyYJ9GpU8do+9Sjs1n0f726H3RzW/yjT5cbLTuOkkZnkNVLgu2zAeoldwrwzc13QmpTgdqAiQc2Tb/3HmmoZB5GbBqhzR7To6TWF11TLik8uDsrf+adO+UfBYZnAjGdDStpv+Jk5yuZsqfeZBrwygOF68oVPPZhCa0Uq28tllIvIXaqdfO8TbtdqeiQvlKvbaQJStlMESRxdJfi1t+x+sOJyJsgPz+zDeYdaJAxfjEnK8IqsWW8ZoWlmA8k9AX6rrDON7QGRykqFWN/OvFMXDVstdD4VnPOMppS55C45vSu3xeuo1cDEy4LJm5KgML2WifOs5Z8CE5VBcn57A4DyJMI6wMhFVg/5OAgJf/eJoSvNcRjVDIX+34RTwsgQEinwnAUftyAo1Oa4RZXaN+Jo2l949+tytykrnJv8ABLEdTS8Gui8t5/WdPlCVjNMPWk57JWkANp7+k1v0VSz2wuhKlCVmPrfKXih1HumacujgX5KSkD21e2mhIWMaYC6rriNv/vpTSQcaabPNaA2YaKWdM88utKhZN4kvl+MFDqLhZqvwuvAnmDOcDb3QUPgHzc9MI7ktWGWwWn2aL3unTqMEbmsucl6MtTaRoTzU3ILMi4qYhYkGT/5nUu4QEq6lw1mrtTqoKMqt+Wo4UaZcfsh2rnGs/wxN0P4tFXj0kqq0dAE4XjFDrTwy9u3x4JH5CCo35t+MSukUB9PGn0lTlWW17DCpNFCW9XHdBEEQ+bzVeCwpw+e8GPUWHxHb2LhVxdZrKkPh0Z2/a375adtEwtn+YMjvKRBr53RY8+R34UnCUcjVo34C+rGyxDwSCGli87dNaVweX9H2NEcGi6sqMOac182DC1Lo3onUWOOKVXCZ+cYrH5DYvD4jsuF3OYmR+W9fUF7zmS9PoMrTnpOPPoNaOjXsmf/SZtEHEqR4VvZYlfWnuMDcojnJWilXtiCAb91SA65clWvo0JLQaNQnG+dv/NJ2q9SkbIvsPuCzL1nIsIiTKAeK8hxnQnvOJAPTuC/mc+kut5sCwpTjZ/fKrwnZAQ6/E52JcYSmVP7PeX24xCS3wiaxpKvfcfbLidekSAWSHVY9uMUggzXu49bEdal+C+8Ypa7pe0jihcEPUFJfSl/34oClnoYo9DWocs21Ig5BaA/kwiCnrAgEcX/MlOiCJZlTtlP8XorriNz28Q3Kf4eVQYnmQgVx1oy0BuyYbx4vbTdS7Vr7h4X8txYM0ufL77NNVVGnIBlH7LQnFT86eq2LRFjTr+JI06kEvoRDfz+JSk3Xn0PUIvhvIBeF+qLEEWc94jhGA2qsdP1g7h+7R9xe+N0IXuW7v5A== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:20:49.7527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ff126d4-e81c-4574-f65c-08dc8bd58d9b 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: BL6PEPF00022575.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8486 Add support for TIF_NOTIFY_IPI on PowerPC. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Benjamin Gray Cc: Andrew Donnellan Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/powerpc/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index 15c5691dd218..9545e164463b 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -103,6 +103,7 @@ void arch_setup_new_exec(void); #define TIF_PATCH_PENDING 6 /* pending live patching update */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ #define TIF_SINGLESTEP 8 /* singlestepping active */ +#define TIF_NOTIFY_IPI 9 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_SECCOMP 10 /* secure computing */ #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ #define TIF_NOERROR 12 /* Force successful syscall return */ @@ -129,6 +130,7 @@ void arch_setup_new_exec(void); #define _TIF_PATCH_PENDING (1< X-Patchwork-Id: 804735 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) (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 8C01214AD0C; Thu, 13 Jun 2024 18:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302867; cv=fail; b=BvlXANusw+GZDrpIoTy9fOe80RxoFRwbj7Vmq9fsDeT4Ea6NVKAw/RIGaUYigI869X4fTDpZmpOrFb68cKulsOfnHAj7VDy4EX8wLj6Ork6ZUckRwIKlGnb6S8EhnPibd2JZ9nq+V7mVL1oRjBbJ/T9sRfk8PxWtVP37kPEX8LI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302867; c=relaxed/simple; bh=mLM0JJ5J+DlRoRzgAwtESJl1A7QxGuEycZmwSQx6fy0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rXTRvCnAWkop3+AgYzXGzyS3kfS6y2w++WpQ+fPXYnWehtT2f3zJniXPICyEihlWwnauVJyZCJe5aET22Afw83xgwqvD3GY7zUlFmaYcOFyuJ70JGC9tsIxn7Xwt7JIP3z1PSskGHok7lTUu5pUyFBL6uctwRR3OsOe94FKSKgc= 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=WF5ve2zU; arc=fail smtp.client-ip=40.107.94.59 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="WF5ve2zU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIxW/xYntALr7MEqGTx9U0LV9b1ULXIpD4JYjcR6UFIzOW0yIGPBG4oYWs5b20J6YJkXl6KI4NUWr79aSnxYNGEO9NVN7nqIhVikTz5VycWOgwWIqTRXDVHowOMCapzqwm7xO/MRXNCzl7yHtFKQoJ9cRZVAQiZzhDPGvtHxu+a0+ZqQQfs5pfYkL3TCS2nCOGbEeaECVpEhWK0c7+HJZsPCdLDjW6Ildw07iWJuLze7qf71w3sTECwu2HDjNnFLKke0/g7pK/I9HEV8w01j0653txWgfqH+LQRpoRdIBpHorydrA+EuF2i42aqjdvVHbZ4ZhoVZ4Oar9f5QYqYhhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=f9rvNrb1dw6niVdiyuZ+02P3rAdH4uSssIVn0bFt6ME=; b=Yzte+4wYJG6YqOGUbBTwuE8hGCcekmfhcVX/HKqjwljuOsLq26/DfPsAtAnkXMW0gvvF4waFHMrFi9KC4rQ+bwcaKBfqzBWDjY1wy5jTpDQyhKStKWLDP8gtpCQY7maUuEpcQ9wMWw92gVQEI83ys0E84GwTQceFABkYbwiMXSUpuyhk4VgzEyGw1NeJfSXptkSast4jjQnjNVJ+SF1sApfF/3Wqij9txmVjhk6sIRiGIXle55LGv+0D35IM/jG1KylJSPylk2WUzG/iWC9v9PB2p/2J/VBO7rVvG0m8Z/4I7G+FJcgpx1+Z2rRvRCct/IaaCe62OWIGDoruoKmlgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=f9rvNrb1dw6niVdiyuZ+02P3rAdH4uSssIVn0bFt6ME=; b=WF5ve2zUEDfeg2mUcMbhe9w4UlXOGZYMl0rgHdnHem7a28T0cN9FD2dIzBWUUmprNOVkVMPcKYGaFIeOpvr0BwOQGyosgMCJkHUdPOnNJrvVuhCS+QQB8BYtyjAmVWdUTqgabV4nLWaHYPG2r5njHk80tAZesXnEkHmTeqkdTKA= Received: from BLAP220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::7) by MN2PR12MB4237.namprd12.prod.outlook.com (2603:10b6:208:1d6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21; Thu, 13 Jun 2024 18:21:03 +0000 Received: from BL6PEPF00022571.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::9e) by BLAP220CA0002.outlook.office365.com (2603:10b6:208:32c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 18:21:03 +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 BL6PEPF00022571.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:21:03 +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; Thu, 13 Jun 2024 13:20:54 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Yoshinori Sato , "Rich Felker" , John Paul Adrian Glaubitz , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , "Daniel Bristot de Oliveira" , Valentin Schneider , , Subject: [PATCH v2 09/14] sh/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:08 +0000 Message-ID: <20240613181613.4329-10-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022571:EE_|MN2PR12MB4237:EE_ X-MS-Office365-Filtering-Correlation-Id: 721f758b-4425-48ad-2763-08dc8bd595a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: +L626wHwRik02EUbWohq9XxhqFdstdozYU7zDUTaacGIbS221mhxzkR8JYC24EoTLfBcPSG1Er+Xc0LxME1b9XrxZ7APKMgd9I45o1kl5vSn7uIPPZ6JqX/QbL3iJJZldiOUZb35Qf7gXGZejtFgfYpJb2teaZdmlR8to6WMHA95y9DO6KIF4vJMqY9KDo6xNiXUWS1cNOy6zHcD38KYatPTABrsPEX9wgHx0tk0pES1DazermC4VShoDRgah61IohO0pTZoDOIEbE5VxiSiGe5YmF6qvtTtsiY+IVFb0F1ivORrQYG9LESthFlI0xb5X+cLCPsq+7Va8u6L9Ms2dlHcQZiTHYSehTe8gAcD8LLcHqEru+75icKLAQZKQgXvOrYE+nMZccuBnI6ub9qJsBKONlpTKRQFCQOfvvy0lETNVocOrhAp1/wEFc/p3wTOLzBhL9TEQ6vGFR0mwfEHKbFilvoH0D/U/hIUs+YC0KoLwW8btu4n8HR2QYj7+RONKr5V7w8CTvlZGn2i5J8ZVcLZ8I837z0BNC9v4ypZWyOAG0Q0rMrd+UP5snzpJ6ttCNV9mB8DMM5NcyY4q6rS2+4bNl67jbCNgaI0jmk8sipfFDRs/0IU+s8Cx6gUGpm56DfkoKum+pgz9OCtIvyh+244LLJfKF0cVPMuEIZ/D1wFVF6s+ZUUYr8djM1GV7M1DHjvt0PWYbJPWtT4DjJf2I9dBC8xeLZ5VDyt5xIwe0lZobTkDuL3m5Uy/D7VlE+72voOZbjOi+Oacw4fJsO0XSruu4gHOq491ceSAXKkfxrAPM2CHdB2vSF1+At77MXn54WBUXy+4boCO54p9hMmb8g4eJZ+rLQJqYnvA5SwgRUW7reUIjnZ7G2PtmJSS8WmPBWdk1ezaaBR60at+QNLzuS8GNeaJxLQ1DNqbSamkdUwDu35XJXYmVlre57p3DezacN60vKoG01Gm6e8VnLcuCxlLv1Hdzu5Ruc9+4tCQlEmQNwJWeidh38+56oYGnmKurbyWWGTo6fYYFApKqq4vWCLRr6TCvRo7CazfqkGgzu4cAxzcfodzDNKdwJW6baBUO2Wu5q9gdVZfzj8X70oqJdD7bRzLuxzhGaD0r8j4Otex9LtCkK+CA8DC7Jb47XX08ojc5q9/fElqSFot+Ox4mhlauA1kcw1uy9e2avnte61LHwHuc13c2PswD8nBFrCz7kxJOYsZU6iI+bXiW1l8zaGCC58wu86VYQq4hIR7uRgQj+a1sdvXQUsRCto1PSm8hylTV+Xa/nCdx2pQmjgyLBGL6DByp3+PoXNkObfl30KixZ42pJWeVaSnMA5Qv9nJIi3dxmgBWNxXeNLyiVzV4ZAkpmuSZ529H5mIxOsP2Ygtgwh7pNlVDAqbLYLO3MQvv/FmdrazCk5E0xkWxaqGQ== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:21:03.2231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 721f758b-4425-48ad-2763-08dc8bd595a8 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: BL6PEPF00022571.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4237 Add support for TIF_NOTIFY_IPI on SuperH. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-sh@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/sh/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h index 9f19a682d315..8cd9d2a5361b 100644 --- a/arch/sh/include/asm/thread_info.h +++ b/arch/sh/include/asm/thread_info.h @@ -106,6 +106,7 @@ extern void init_thread_xstate(void); #define TIF_SECCOMP 6 /* secure computing */ #define TIF_NOTIFY_RESUME 7 /* callback before returning to user */ #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ +#define TIF_NOTIFY_IPI 9 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -118,6 +119,7 @@ extern void init_thread_xstate(void); #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) /* work to do in syscall trace */ From patchwork Thu Jun 13 18:16:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804037 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) (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 D32B014A600; Thu, 13 Jun 2024 18:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302890; cv=fail; b=dat/XltuYyY6/yyBUeCBSp6ZI7IgiuF6/sEayoQEopbdTJ12yYQL9EJdhb4tjpSaRF7BCNgxt9UBjZ79Hg5tDoJxAKYgGUyVaPvjn0Zdr2qo//X5Rlb3zQc4Jshv6w6uPmnhjygI/ZEv0G05AbrQqcjSCsS6LLYJDNLhupO7DCI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302890; c=relaxed/simple; bh=p0cKsEkbsM+vF8/wgff97JNOl/JpHboL4oasYrYew2s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lkcn/NQmNb1+EDbjUQ59wzGoFh+OK7hm45TLf1S7/pW3Ka4IJOelddh0bLMmM93S0YCXwgg8/HsZjqfFTL3QiOrm8DpnAETQjR1NMRP/mXIijrsPW3yP7pRq2EUQA14hVqteLJ4DCzACSWrJCbPDnPQ6xmLkk+cqf/3PjF7aD6s= 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=D/KjMiz1; arc=fail smtp.client-ip=40.107.244.79 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="D/KjMiz1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnFIgEyAvLKuyzfjzuDNouN2YpFoP3LYlmYYvSCtLz7luFNmZHUKJXANUrwATyI8K8uvDqyKYOnr86RwbrmzsiIRy5hW2KmyC3ZPVXqNRygL7gLM+HiyYtA5ocILSQj2sydMFHEQUCw+aWhVXzBjSixQXQh5gb+GHk//regn7xsjqJpKj2vMSnkLrcL84IURqijU4ePRyi7fE1T+gIYzdj0k42Bpjdf/aWZDIGH48+gt6a/Y0mNHNTRMinp59VkMO7ptuheg4QeeFFVJD2vCJYzIoaf3ailUC90Xecz69CINWVZScg4foZ+uSCjSgvLQsZ0aZxaVKBNh6V0gnP0cUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=7bZVytII8R+C/v+PKo5wVvTus0SddPbaB1Zkfd2yfPY=; b=FgJh/4jKWf+oenoFYIN3dKoM+gQ/AEQPD/mcE9kZk/yEQOD8f39YlbCVXwKugLBZ9nYJA4fDeHG8BFwFdFOkX4Z283BjGPoZaMYHgH9vtXCLaNewl7NNZW3gCpOMMwW2we6X2XkNR/pP6i8P2EpC35n72cBWAU/nuJovDug0O3JhahNIUiDNEPnmF4JQ0AURKY0DscFPlqtBBuFBWGYjvVIycQe5P87/+wSvgVYGWCL1Ol35OC4WUI5LrO6Eoq7Uc/SREYMkU2LBx9rUJf+b+tHeRbfz8JR/6h8MUOwH9fuq/FQOjfpeydfT636Rj56TBduyKppIGTC92f2z5DotLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=7bZVytII8R+C/v+PKo5wVvTus0SddPbaB1Zkfd2yfPY=; b=D/KjMiz1YfOPD9duGajzB8GVoGiYev5C+/JGnu/oD7XmWTuxOCQfVTWo6B//Fu7NIbIrijhh2Vz/oO+/6MEjed0pK2cwQCdyFxsLd7M6AhlmExQhlSBWr9jKCk5sCs/ONZv2Vd9EfAwXmqf2OrwEMGXYYw3HAZp5ZiiS8sELoUM= Received: from MN2PR06CA0024.namprd06.prod.outlook.com (2603:10b6:208:23d::29) by PH8PR12MB7182.namprd12.prod.outlook.com (2603:10b6:510:229::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 18:21:25 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::41) by MN2PR06CA0024.outlook.office365.com (2603:10b6:208:23d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20 via Frontend Transport; Thu, 13 Jun 2024 18:21: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 BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:21: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; Thu, 13 Jun 2024 13:21:17 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , "David S. Miller" , "Andreas Larsson" , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , "Daniel Bristot de Oliveira" , Valentin Schneider , , Subject: [PATCH v2 10/14] sparc/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:09 +0000 Message-ID: <20240613181613.4329-11-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022573:EE_|PH8PR12MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: af9bb6d8-ab9a-48ae-d809-08dc8bd5a2c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: KjnFamwtsOv0+kkIeS4C2HyEk7bDBEgS1oRMGmIgWPeyWauDQbqcd0fOtn2ylnmEsnjfMGAuK6Hd0bsCrKvMt9iFaY9WrhYpzP5d/DVj45/dNi5xR59LgAc1RMF/F+j7Ifv2v2Mh3zNbDn+0mtyGlZ4Sn4eOGPlbN3RxFzdY+8+PnqX28gJcmi5y9slGNPHdnJUwZIHIKk4rJPMYrl9+u4mOuxKxwfHQkoh5b1x10JON9c+k3lSmIQH5KoIUJAFuArTkAeIf4NGxEjtU7wdXEw+R5qjVAPtzT/JCcGWE9XUsf6HMWmvDqEOyo2R2SfzwMZ+jCX7joIsR90oeTn+e9OALuydnq2J626QINVtAzSbAsN8iZDmh73KW31lDN22TN1aZ7Lhj5CjdEI3gl/oVbXJqLoCL0xsHDtHLK3e+I2SzwbeXdJiIEm/y2yhSRVtbGlYskZ60hH05VlN7ttV5bvMc+faIWcsRaXA88s7rLRSO+06x7pO5Ixma3qXL8aHmuEnCXpXzlc0U3yYr+6BJARtcBqnlVIuGreDaIL6kEVenWv0+lcYYJao/aKJyfOQsBdFMPNmmqF6hg99o/PPgcDT+A78v3jMRzcO+oolUem5O/P7cEbw6AwS1MaIscLNb/WrEQnDv56i9d2zhajIoWvNy0YeYsfufVhTSX2O8z9ZYWr0GBaYWFUY8coPfGm9VQ1uzH7hg5O/4OjF9fAx0uI6c5kpMim8nP4XMDLvrCKit1L996ONDJh+AnZoZpU7VPP3BDb0S3tgAv2mjcYcoUr0Q3vx/ZftlJreflsHphY513o2/tcUrzr80hGlYYhYUKxyIu9P7V0/bjuJWumqw6LwKjeLqZqEnn+HqiprtvQvZzzy7I+cY56wdr4WeFhMG1xmnrVnH5bNwAYwBG87sQD6gjtM/ekfPRUb62/jzkE3oIASzNuliYFqdHB0wamok9i+TIoilLoUBcYBufK/DDiX0gQqdYepTCwSvXowUs2Ejhg1Adt1tMIAL6Wzvog3zrSh13McP5CenIoQjbTH/GQl0SJ2SP64MVzArXlrFpvIHsZXNFFtvCczQnV0Pb7/4MxzZJiuoW69EZwGuq3U6Lw8v/wtpe4rDXJlkpcqaDk/38TQply9cTGAJYIUpvSP2S+gT6EtcS68AaEKFu01yUoRIuBPJoyGMWbclKU+0GP4d0YNCPvj9hm0LFney1V3IEr+irRYYQC+qXGjytCnICxeV0qmu18DMKH/0+Locx8e6h3T7i+gMSbU5cXEx3IDrIesk1p0PE5aKzvQnRcDMAl3rw2zjIeN1HNgD7dIBOctH0LlHwzD56SPk3CB50fHWDdgvyg5bABFZHoinfDXjcjEAZOAyJChNgsJpc3Kcd6M6fUPhZVxZOmPth6JYwcybfQKKlZo8vhOawcrLpUUShA== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:21:25.2856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af9bb6d8-ab9a-48ae-d809-08dc8bd5a2c9 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7182 Add support for TIF_NOTIFY_IPI on SPARC. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: "David S. Miller" Cc: Andreas Larsson Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: sparclinux@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/sparc/include/asm/thread_info_32.h | 2 ++ arch/sparc/include/asm/thread_info_64.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h index 45b4955b253f..f538ede526d1 100644 --- a/arch/sparc/include/asm/thread_info_32.h +++ b/arch/sparc/include/asm/thread_info_32.h @@ -105,6 +105,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ +#define TIF_NOTIFY_IPI 6 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_USEDFPU 8 /* FPU was used by this task * this quantum (SMP) */ #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling @@ -117,6 +118,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define _TIF_SIGPENDING (1< X-Patchwork-Id: 804734 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2054.outbound.protection.outlook.com [40.107.212.54]) (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 C0B801304AB; Thu, 13 Jun 2024 18:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302912; cv=fail; b=bWmtzDKI/Q+SRwlb4o6weU7hV0ONO3JNOa9SfDME115mfM8qqlQHetqF/oSQgJs2f4D+BdfvZGCKIWcWSBBXLpYCKHdF8k2wOkB+QaHx0TFSteqHE5L52DTQ4HCGGoQTRwpPMlyVfwLHOEDEyiGJvDFRfB7fDKogx3s23P56Jc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302912; c=relaxed/simple; bh=INq/ADRZMx7ZFhG4kspI5hg2PitdwiFdBWVwzSPRswE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lnw2BfFRCF3gfE6dsGuxJAjRfkIZ5nC8E23jLUOJPlLFsDyDj4OtcqHuBCZW8VfFxO+iFgNS/+SYhqY03ysIkAlfHu1QQ6CF0nanwK/3NXiy70HIHHCgN5wZMSbI58pScCtHdgAenpzqJ4wnC6n3k5ZZDR3gTT2vGEqXl5GDeTg= 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=dz4WsEKa; arc=fail smtp.client-ip=40.107.212.54 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="dz4WsEKa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NYdq56m4Zq9OWc8v88n//s3mJhovzM+bmuM9e8ZxO8dFnncrJxWL2DCxoFIRY14JRghbT60PiHqN74DB7/8nhXZp7LiaaEwZXVHbNmq5eI/Fvorpn72vX4fjQMn2+i4KZOCI4S+xv0plLcGaJ8Bbkmot5c+92ukS4EXNvhK8qUFKVPrfwlfNGlzuH+HYHmltQUKklzXExL+ax/vJHuuUnHAc1EGW7wOvYSCVqthcJCXZe4YTEFOgGavxQmMEacSXQXRv+gDQ684oWY2Kft9usCHV7VrkGAoUDWbhZng8i3URMJ58Bpw3f3+xL5D8LqH2Dx79w5svYrCZkr6j4Khl8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0/YTwJcAfMt2dMGRNjEcsxe6Vp0c+dVhfzKbaE+0tLg=; b=V1GpwX9DlqcdN5RvTzH0CQ3MJPZvbsfo4Fr9I2u8TGDuQ1bnvEScqjselADrb7X8yi8WGQWpjYP34Eo5J2VEJKkcvI/ZjhFEpoQRhvTU8rDa0caMI+K8atwLDgkEcsmSOvYdyNhmbwol6/zGyeeniJ1bVSj9LKR8t46a21zJB24Pww93cE9cH5NMRvKR+XBM9TXUViNo7bqzunXGLaeE1u942W6SXvdH5I+f2ds/a4tovhErAagSeR2/IyUfZGPpxAlqjDComSBMZJ7DAKRXJZxZ/tW83mvlgOSqN0ijvGuRcM+nRwldR6RJLYOLsRbcoQwrc6+5ucoYl7MFbiPyTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=0/YTwJcAfMt2dMGRNjEcsxe6Vp0c+dVhfzKbaE+0tLg=; b=dz4WsEKakVo2xQZ5YLezKbu75GOmr4Et+H2oT8s5CS/Pbd1y97fXCa4xtmCsUre51/l5Xs2dYz7mnSVm0MQA8NDnjqsEQzWvN2NX3s9MJKQuNwjHVgMH5tj9BXMtSWL2mGHgN4oLoJS6Clp7sa6qIVXlv4d85cidAjmzyMa8bU8= Received: from BL0PR03CA0033.namprd03.prod.outlook.com (2603:10b6:208:2d::46) by DS7PR12MB8370.namprd12.prod.outlook.com (2603:10b6:8:eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Thu, 13 Jun 2024 18:21:47 +0000 Received: from BL6PEPF00022575.namprd02.prod.outlook.com (2603:10b6:208:2d:cafe::f2) by BL0PR03CA0033.outlook.office365.com (2603:10b6:208:2d::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:21:47 +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 BL6PEPF00022575.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:21:47 +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; Thu, 13 Jun 2024 13:21:40 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Guo Ren , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , , Subject: [PATCH v2 11/14] csky/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:10 +0000 Message-ID: <20240613181613.4329-12-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL6PEPF00022575:EE_|DS7PR12MB8370:EE_ X-MS-Office365-Filtering-Correlation-Id: 60141e5f-76bb-47c6-25c5-08dc8bd5b00f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: bVFI124eI4nCFp20hPd7YGMl2hHVtCkWXsECoVI656WmLPAFrU11n9uInoNPuhuPWBYgbKa2NNYj5X08rG7xtvGb45xpdCTNoUXuoMq/hT70hycJkWtpe212kexSnB/Q9Pa+F+p0DDXfahRY6QZASghucD5uNFbiTDyOBFWOyFx1oii/UN5I9pHPbfsNGvMrMbJN6B9+5IQLSDACmxiCKGlN4h5pGU77Uc1o639dXIxi0L1h26SQWB5nhxmGmWewXW0qH8Iods2qxm/48XlccdoKaw5yg9Cu/V9f2ZHRl267yYxtIKGdRkoM9K/6QDO3k/cJioRPCMXAYHVMBfcixTe680adv4CmxHjVtH7mR/qC9cD9TCznPQ3p7Sk101Gcwj8XMAhEJ8GuGaeeraowYTPhHt/0egQ3JOJGFsCsQlKJyW+gFennUdnXJsacqNHIxHB3WmmFTfVyhqZTJabfXDJB9uGoxG0P7Q8P4mJGaTZesSqpAgQRPFClSweOIWA5TiafmiWxQAC0ORW6pfAxESBXkanX/AYPaEF63xlxts2oqhehZ2nnNiMA7g55rhO4eezjxKcYXEBFThST85KcR6Jwlqy/eOaanwxyAE79CG+1S5lb5+O+H3YjXYACUXeib3s/jQUxAZ4w2pXb6Qq/+kshV3BGpqvqlCydjyUWhtIb4/UCqcQSseutRP0zfNWfi6ahiX/+vKaWlLyYF1SkgdC6cFRVopI2bDUkwGgurHWAddcepZNeqt/Npe7nr9qNsORjeZmxE67T8Rkp2TUNOA44tTOwDnI3KwYtNni3ykMc1HNKi/BT3HywX6tkpNEg6lmLGDl9J14+7wSaEey1WpZ/wi4bCm2uWYen6ou883fPeuHLdul2k/kQMilCF28PuVcgSop/06KxIjWLWhYAqxx87Y5EcU2MWz/o8wvI4o90I4bXI698L/5cGu+vz6QZYxmDvXiOZJZ6vSpfCKvv1vZR29NrvCUHiG56TqfGCsKcvFkYkRHjFDPdQsTeJCtPz5LZesj1v2Te8W6eF61j1cFN8VitadiHjs+Tk3AH06oOIzjygJ3rjnjSj1zzJ5qeBDQHK2EpHmOvq0XlCfQHnoazXDcVUqCG3NmfPFv+LESt3PbuGuUURmHWLx4y3zS1Eedmr2WZrh3KMeksfm4HoreNtdwHJuSAqpi5fbA7BxBV8EDKJXqZsvNVGGJPIWddP2wQgYJKRwOFs6mmTG0mz3hJFq1QbO8+tRfz8UXAc2WFN2XV0pLzRn+YgzHGJAm+/7mExeq7jzY1TsO2C8fu52AsAk3vrFphHS7usjCcIuGCxeW8fUOpCuaRjRsJS7ZYw23jZHlgRcaKicxHR6Hvkn6Xsjd0Wo+xAXV0fIBHYK/T8D/lhYp/vy0Rcm5nnyAUBpp+WfY6dkzSfzRjBcob5Q== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:21:47.6126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60141e5f-76bb-47c6-25c5-08dc8bd5b00f 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: BL6PEPF00022575.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8370 Add support for TIF_NOTIFY_IPI on C-SKY. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Guo Ren Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-csky@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Acked-by: Guo Ren Signed-off-by: K Prateek Nayak --- v1..v2: o Collected the ack. Thank you :) --- arch/csky/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/csky/include/asm/thread_info.h b/arch/csky/include/asm/thread_info.h index b5ed788f0c68..9bc7a037c476 100644 --- a/arch/csky/include/asm/thread_info.h +++ b/arch/csky/include/asm/thread_info.h @@ -61,6 +61,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_TRACEPOINT 5 /* syscall tracepoint instrumentation */ #define TIF_SYSCALL_AUDIT 6 /* syscall auditing */ #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ +#define TIF_NOTIFY_IPI 8 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_POLLING_NRFLAG 16 /* poll_idle() is TIF_NEED_RESCHED */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */ @@ -73,6 +74,7 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_UPROBE (1 << TIF_UPROBE) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_MEMDIE (1 << TIF_MEMDIE) From patchwork Thu Jun 13 18:16:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804036 Received: from outbound.mail.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) (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 AD851144D0C; Thu, 13 Jun 2024 18:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302940; cv=fail; b=uiPPlu3imgZynGfJouCARkDC4K+yLL/I1DONKoHnxetzN76pruFh7ISRY0mg60Th0/DvwKjo7+41Yhk0r/90vITi3I3/R7gDSkyydS/mgyfosvJsm1XIYCnweKJ00J7OFPjwiPU8pO40c0rpULtlPzoJdCNjrYHSqXf+pH9nBzU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302940; c=relaxed/simple; bh=fQIllobKnQj4N1TQcML1X/+0mkfNnGh92sGbcw/mz1g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rvQdMNuYnp/89r8XSBKSuIcPISEmTlAWNKIuzV5IWasmh/8fdem+UeH6KZtSCNRMVACwblSSgctTpbn38OtkHFrr3fjknkthU6x/b3+nWPOoSktdKM8nIjw0+7MKwo4mrYeep0ijHMFjDZrgv/kB0ypzvJ8Bwd/HQNYInklUpYU= 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=4wci7Sol; arc=fail smtp.client-ip=40.107.93.54 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="4wci7Sol" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g0BJdGADgnYEz8LzM05F1eyJGT1MEHucXevu8kFdp+ynE08HJhMM9XzskioC49ZeoseL+e6Z6/pv6BMfjk9Cgh69RaN1xDjd+SLqX51xbjqP6AOtZpLLskoNA3O/pol0nBcViGUfhI1CYF6qw2X4tI3OL3UBz16/bDPpKyGJhA4vYUg6nesDDHs9LhVPFxyyoFGL5c+7ocFhGg9NVSAdunsqBC9qrmSSkmRofc3+npBIILyzAWuaRkMNfOrkWylTpMrM66LkmBzXteaTIRYIWW6iEgE8lNWk51CL0FnaCTC1XvFpb2z/s7VqmTaSqeG37JlQxFMJQ2nPzGbHnjLu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=bMSZcPJusC+1ZmpvinkMeGGnKivkW5zqNmssukThVJY=; b=FXfqBDU1119jwNOP81268Dm/R0q4DXWHx1QfDbOh9VJkK43hcPVVviEqhqXx3lwmX/dN3+BtLu8lENaRYXx9PsHZ+qc9e2v/N2imnwsIUd2LYWhdI6cxG8y69LYH2y08E8cTTBWt9J9FPST91D7nRGxnd5QRCFnzMUonA32S/numEBaAHo6zG2+iB4mK3G9CJhmdR63n5z2l4UvJ862VBXS9iR5talbXVeBwNUs4wuxem8Q1KnpharVsDY121gDwruSc2Hs+6zXDqAmRpA59qoKnohPsOtJ/Zn3P5bSf3hWCO1zUVG1ZiGXUFmbciuQAFgyXJ4daqVkwdXwb3ImRhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=bMSZcPJusC+1ZmpvinkMeGGnKivkW5zqNmssukThVJY=; b=4wci7Sol2F5/Et5YZOexRzXRZ+W3KrSa/zKB3EPIcvPF7i4uE5qVn30PQnwTdzWqt8zHP87dBH/3qN3F5Zeaw4sFddqLRgDiM+yta86DSM0TxRFpuvBBzB55Py+DzrpoBNbvqf4+DbA4SbObU5f5wrOAtxaql1SEsiYcQBGX51w= Received: from CH2PR02CA0022.namprd02.prod.outlook.com (2603:10b6:610:4e::32) by MN2PR12MB4080.namprd12.prod.outlook.com (2603:10b6:208:1d9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24; Thu, 13 Jun 2024 18:22:12 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:4e:cafe::1d) by CH2PR02CA0022.outlook.office365.com (2603:10b6:610:4e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 18:22:11 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:22:11 +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; Thu, 13 Jun 2024 13:22:02 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , "James E.J. Bottomley" , Helge Deller , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider , , Subject: [PATCH v2 12/14] parisc/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:11 +0000 Message-ID: <20240613181613.4329-13-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CH2PEPF00000145:EE_|MN2PR12MB4080:EE_ X-MS-Office365-Filtering-Correlation-Id: 3180faa6-2a7d-48eb-eda0-08dc8bd5be32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: KwBfury/PvMptdd8knaSeTtWAEtsiMjLmzl2M0MB9UVxT+JkxY6nnm7XGrEJxUe0hPZCNXabY8V2IoqFhkt2qJ1Y7GtyPG9jQBGY00CerhhnR3Y4By3dlTyrYIefbpoWh6DCzVuP0LtAENO5+HGmErZw/LJDCBl9JtJoxbg8LsNa5CRHt0XxUdaB8yPc/qIwD8dPYUoUtUT5aQSzgm3UWojWQW1i6lKewB+d/PPmVi3LzlCANvjeirMBPtfovq2g4OOAfkeVNe2YBGun2wNzunmu7bqA3U/tJVJHzSUsH6HHbV6qgygh78lj1WIv8ksPBxjAZOvbpHUWVAcgXzqGSjD+KyeYvRKC+oHDDHPtmn2CMbmHZ0ZKGfH2T4XUukH8ff0DJwa+ncs5dLTe3yARClr8YEVP8UtC46EKguld+fd3mULXJkuYWJL3BdwsS41yeh2F3/kNjM/brHgFhkURtf6m3G7bPN/Wjnp6tAtkWGrifPREsWUg8mx/6xVFl17bYAHkfeLw2pedVe65r1jEgeDRvUXhi49/DHCz2iN9GGUDU508a+GAv024PgpSKQ1XPAa9rIqmba1o6HWpn5BVcMPF+xhOKHJPH11bbtETlzF9PjMGP8jiH8cz54CrqlWJw1FoNz1l6uy9qH4DIVSsSjt6Rf51DiZuCw3RiE7+nmjPKPqhBm/8hWrV0BwTHAYnIuWFERX3dEVc6u3MJKLXpdyoe+z2qgdb0MBfy52NFO4ruSW1YcVA2HCSq0c7q5LQH5rpcNODLctC9zQ//vAdTIqa2iwYab028Ci+BorXNBSUH/TFo7IZShClGPmP6uSzZqs5akDno3V8FU6wyYwLlwpaOS/eXj1X8xPj0B3DKf7T5TbzxLN1bx5yV4XjF7Zmsv30S3XnpYmjoR0EuAC+OSOEPgM9Ip5SQZd6fvT+xfOD2mszO0w8Vt3Zl7PRrGlAaEgmvmCTmzRiprDXs8E0xD4FXDDZyHgUD/4HkJSwn890eAcd6RnnlFm8pYDVOrl6ZO/qEfX83ZSLZDH7k6PAtalSYtXsUYsLhoxtnhm6l8vKpgQqkRr4ZnrrZVFhGVNK103g352mH1IBYuyjnt/Qk+RAQCLGtFkOfyLLBLOQ+wBFf7N2uE2zktxDH3cu6FqtWnr6uMBNsb64hEubYG+17AfY6ktVKkROWmW7B1NGZDKcaqZ13qWsdkxPAeiJb/1WgVGMD+gii2HwUKD7Bts31SvaIAg5Trq4GKuI2NgYSK52ncTB6MEVE5LlNKkwlu4GfcVROoBIaOvIxnkjkqjL+uDxK1m9OFy8zgakMszxgX+upkf0VPC0xLgxGeBYw81lsm9yfcgkNYPW3I2zdX94je9VGcJy4t86+9GQcsxZlcKa/dxyAqL4zkwIJmsd9a148RkHjzJNjYcob2PHGkeadA== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:22:11.1321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3180faa6-2a7d-48eb-eda0-08dc8bd5be32 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4080 Add support for TIF_NOTIFY_IPI on PA-RISC. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-parisc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/parisc/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h index 1a58795f785c..35f1deeb8f36 100644 --- a/arch/parisc/include/asm/thread_info.h +++ b/arch/parisc/include/asm/thread_info.h @@ -52,6 +52,7 @@ struct thread_info { #define TIF_SECCOMP 11 /* secure computing */ #define TIF_SYSCALL_TRACEPOINT 12 /* syscall tracepoint instrumentation */ #define TIF_NONBLOCK_WARNING 13 /* warned about wrong O_NONBLOCK usage */ +#define TIF_NOTIFY_IPI 14 /* Pending IPI on TIF_POLLLING idle CPU */ #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) @@ -65,6 +66,7 @@ struct thread_info { #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP) #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \ _TIF_NEED_RESCHED | _TIF_NOTIFY_SIGNAL) From patchwork Thu Jun 13 18:16:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804733 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) (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 656A014AD19; Thu, 13 Jun 2024 18:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302956; cv=fail; b=n5j3x7jpknxMPugdRR3kP6+4+00IXjfB63XBDMtEEOSEjR6ounxaG8Hl9q3HwEdMJanoAmItVjyocRAUtPfzGJE8HKFuTVpJprsNdAzD30NtjYPNW7HewQeG+Y50w2UBBEpZbm9wt23djdYOyNXNiUOjej4BMVdhi40EWWHGQQY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302956; c=relaxed/simple; bh=XXWdspiKC/0UlHHLqD7udf95/J0hP8yCGKcEGv6lnwE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rgcUDGS4wYL67jfxyjG8zcXvp5lQIqqjk52tZ1+IlCwoYWOXL0nzV1UpovpF+F3/Nt3vOKvPP4LJ6n4fHvRk7CBVEaYq1uMbdSQnEaYP/8pkUvdX0WhDhNSfkOYf/N6Z3ulkAkgLizXYAeqSx0u/jR0p4jswrWUOYJuDp0yZB20= 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=pUmc6Qwv; arc=fail smtp.client-ip=40.107.94.52 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="pUmc6Qwv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mb+COovBOKqxrRm12kbdi7e19XhOlwEswjjUf9I0KVQXx00QhDPt7svCt73F3gF4JgIzBt8BG8CupYPx0n+Ljg2qvHTQbSVbDGotoWI9g8a6mcLyWfg5vIxnIvoTrkwkiKUH1SDjSp1jFM4bANA6MsOZOy1AtHsMQsPEyguBS9WtD2jgq5lfRCpvMBMo2h6k254ZHEGVSF3EM0doaH1Rzs6a1jAXMsTN88Z+tVwxqI5rnDPwX0tC2tF2rnQjr85ht2PqDwi/xza0lNz5yVwSu8r+S3TFqtSNhPzWyeKaDl4bn5Sp+gxNR0Fr7fPW8Q9z5GkWgHRxPhIJTRDqeoKQbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FqRo+oqUsFAbzVJ+rqjyOKw0pKvf3GHUxqpByx6Fh0g=; b=f4hicJqkIH9EgiaxOZD64cIACZT9tiDOCpqd9TikfxM3oLe1tn6RaMukmkk1h53AS7ZjXn0bOBkROiQGd2HDzu1zDkuBhiL+UzvNP/mp2cNS4mf7a6lrq5MH7Ar2MhncwkHhHD/ya8dSYSzIDG3/kR44Rp7umfw40Iu0497KraZSPefBbgBIyVmpYPexoKzav1W2wZ6hrwffoVQuRgam8v2ytULbUzo5viM5DC7T5OaBVeV9EQdOMKn9K5MY4vP24lWK1T19Yrb749Ts5fqgn/Qqvkr1mFK1KaqHSsITW0Sf/DUyUX1Ht9EKVjdwM/J6wcZD4zUf19sveT2lVNHykw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=FqRo+oqUsFAbzVJ+rqjyOKw0pKvf3GHUxqpByx6Fh0g=; b=pUmc6QwvVg6bRL2vaHmjLpZxwZVNGBCzfsCujunkFUKMppY6L5ENoDP2RrjZgqOLaMvkIvVDx8vHoqYVmuy6LXbYj+ueYhgYmFPOYW7SOlugG7Chohjx0pCYpPyvcCDupMOmYzhPRt9yJhnP/99BpTTMxPFFGPPmoRDB0G87NSk= Received: from CH2PR02CA0023.namprd02.prod.outlook.com (2603:10b6:610:4e::33) by DS0PR12MB7582.namprd12.prod.outlook.com (2603:10b6:8:13c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21; Thu, 13 Jun 2024 18:22:33 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:4e:cafe::3c) by CH2PR02CA0023.outlook.office365.com (2603:10b6:610:4e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 18:22:33 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:22:33 +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; Thu, 13 Jun 2024 13:22:25 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Dinh Nguyen , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Subject: [PATCH v2 13/14] nios2/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:12 +0000 Message-ID: <20240613181613.4329-14-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CH2PEPF00000145:EE_|DS0PR12MB7582:EE_ X-MS-Office365-Filtering-Correlation-Id: 295db9ce-fe45-4cc8-8629-08dc8bd5cb2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: 7tlOd3jfqjL9pTJtCy4YKNHQZyiuh61Z/ahz1SGJ3Xh3A5Hga5o77PSIh4a/T5ilil04bA6PpXjtO7usxbsbYRCmRvUZ/3W1EnFGoYpaRsX5pNzwxUjB3UqxyWWaTujaIq2MusIN+xXnN4pkpsDrQD3MzYMjSL7gfcQ1vKxBL8KF+BLdaujNEgiWUGB0hvatlzoEkC7agIk5lNfispu7sCGeES+okZoP6uoR+9Iw1gFowgmEyRlqMVxpySsukMun3V3Vz2iqO1ZlwP2GMmid9PE8gdO9Z74kYGy2+bW1AoVgY7qrdzwV7w17zpANYYCuqQqEcrCFYDz97J8FhJe5b9YqXaVrpo73NWF2O1MeM2fTo9XtOs+W1T7TZdZKr3HT19RlY1T1IM2NWZSn4xpu6QOXnRkDoVgnBvYY6aYXKsDVPIb9YkYJBgVqUh2nW2oMAcDBz5QhfIrKhRkHKKBE1clJppdM6xgBcKIcQlYFjMpZJpD7DNDlLmJWuwW+MueqxWSgvQ445Fw15AkM4wnS60yVQnoJlYbsjmu8FqERDg1gI6o1WdVX0FpKibrC5RLYN+WV4DY3l+hyC1cybFAAyzWlMnluIN67TGWyi4LEfWsSVPgw0i43ytqdGtUrboWFDCLbQjRSkjnkeMup345ry7gwlCCLxVJPq9VbzljzFx1OouVKICDgNGbWZeOtfbMNK3k7p5+wLbp8Hl8QvBz8/yOw4jgNd8lwakQMV8wfo5O+u+7TsprV362puBc532MltzgZ1D7ODiayOwjKhqFoMR00Loow+aLJaPZIC+x0U5eeWq/Sc3XhCvLfIOEf19x5FvPad/TUb9WOnuEvow3ixG2Xtmoxt3gPGBme1/guYTIR9Sp3gHk7MSbCHDLF5oI9AJQoXWunw1Vj5p223447if1dTBgG54Xd8hcVosVC7tYobQucppBMIeXGI5trjMRNT9Mny7AqtG9MYFfQgePASWwYUSViHv4tba5DjPS5Wff88S821sMvYXqAoOrQnqJmlnBges2bGKqBf1XWBRw7wcoPxPU9jGfouNvHoz1E4MeyhEYFPklL45W55thXLQNyuj8Mh4oyfHQDlt+oUjAphbWtS4Ew93GzrAWL12e+AkFXzgB5KDruxNKDHLTTAfJj50AMeNZn1Dhi0M4hCLFzrGsDHpo74v7Mk5GnXYC3YZfYrYccVp7ZTUPuDgFYzeBjgChKxarrqrUiDohVknDBUoiWisB4IJBnAILmMwcDKLyKPfrw3UR5YUcynUVmYdeqloEhM5OwSCm5+X73hjGwJGJorLDDHan11/lCRpaAX9DdOZ2AhuipUawYu7npHCb+Oo1x5IjO0Gb5tl4vQHO9756g4ECl7q4svVgiartpzklE9a5K8EdrZse4laCCn+m3/WBGFRwJX32DkrISyeIc9g== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:22:33.0230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 295db9ce-fe45-4cc8-8629-08dc8bd5cb2e 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7582 Add support for TIF_NOTIFY_IPI on Nios II. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Dinh Nguyen Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/nios2/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/nios2/include/asm/thread_info.h b/arch/nios2/include/asm/thread_info.h index 5abac9893b32..24882fd5ad11 100644 --- a/arch/nios2/include/asm/thread_info.h +++ b/arch/nios2/include/asm/thread_info.h @@ -79,6 +79,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ +#define TIF_NOTIFY_IPI 10 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ @@ -91,6 +92,7 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) /* work to do on interrupt/exception return */ From patchwork Thu Jun 13 18:16:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: K Prateek Nayak X-Patchwork-Id: 804035 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) (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 DB71014AD20; Thu, 13 Jun 2024 18:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302981; cv=fail; b=umt4PiG940jQAt2+y9vb9MnN4yDPEJXeKGddDtsBpgtA8MNmVKl8FR4u1mm1YjhpCD2bSPHLxkGI2mxfjqPoGcmDP3U9zGw+H8HnnAO57G0Q0VW2A3oZPKWdeOVmE8LbZGT0EJIjx0baHhE24jPOuj/r8/Lf3yHvhA5w/OHwADg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302981; c=relaxed/simple; bh=EwqSEJGQzhfTSysTU8zyNcy0wEjpWJpLS+8Gv4T14bk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bLMWkGuTd9C5LJGXvbRNx19HqrjMsT+qtq6LV6cD5B6DpteIG/om5OrtWT0UxPzEga5eJkEfy2HZgEab+c5EA806JX9q0A6LbVOvoniXKihROfDaLTyDCRYZFSF0str5nx4jCezmAVjfZpluvRxpOibI/WWFCCMyeNSeF3g9Ykk= 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=GtrHipjY; arc=fail smtp.client-ip=40.107.243.69 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="GtrHipjY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M373mYZW4L8C/I7f8iOFkCeCSISBbPB2c6anIMd0VB9QGFR/rz+03+6muv+L7R0uz12byDiLHgw+I67RyzmL07V1oqPlG9Mwg7+w4eelyN2XGbiw0JKeKVtgXYl2mq+vUjm7KviIckGRVPjTECr+pxnrnIuh0O87Gv2pLnnSOkhLVdOChiIKyE+95dC1e/xcrhJxSJDoL1OJcjPUsgSaVAZSe/RZhb/nAKeoC6XFUoV18raGUJZljF0KIsZ1SlCtD7x9gZfJ0yw9gqLp1dgze+m+UcX4ZxP6TLIQF1X3C96zWq4pJSFH9FrAPoAxTi36+h+RZ9J/FrCvJbMYNOMD7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lgacvd3u+50mG7IuO3XlM7C/fryoshVvDV11ftVHmIY=; b=ftWz5uxLf4sylTxMMNYdrlP6GfNOt2PdmmobB+oty2hK5AyvRv29LI/IMWMRT3mK1Ul3zt4qRMeC5GA297EGPuqRyS1mLVBqiHHOAVh/QljRE+9SrfmhCTogg+Wd+9znXa+w52pUrDJ0xJ8ySAHrwRedrKXF+X5BoS5ffUZvoQEkdmEVjml73yjY2qOvM/VBVzM0JOcWXut448XV4IrA9tHN21kHjjbaKQ6gUjCjNBqhO38R+z06KD6doxCgWG/V/vwiNCvJ89u+RS206mlknbJ+pGILDoGCQYBxteI6v8799EAu0ZmQz9xqEnMHuMqd0cmdAnrL4un/xgPgdcXBhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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=lgacvd3u+50mG7IuO3XlM7C/fryoshVvDV11ftVHmIY=; b=GtrHipjY32mGdugCpwW8gP3rUnbj9tnN82QqSZJ2DXVzJf6G6e7ThnMvxD423iOk++7AgUIgQWVS6u8OzLKmBRyIUmRThu4l+8vptnrI52QUt89ZB3I/kapLgzNmkgaaGgf5FHMYdksF84+47O6IRJjbmhHcOFKeX+A7QNtvwRw= Received: from CH2PR02CA0016.namprd02.prod.outlook.com (2603:10b6:610:4e::26) by DS0PR12MB8199.namprd12.prod.outlook.com (2603:10b6:8:de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.23; Thu, 13 Jun 2024 18:22:57 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:4e:cafe::cf) by CH2PR02CA0016.outlook.office365.com (2603:10b6:610:4e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 18:22:57 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 18:22:57 +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; Thu, 13 Jun 2024 13:22:48 -0500 From: K Prateek Nayak To: CC: "Gautham R. Shenoy" , K Prateek Nayak , Michal Simek , "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "Valentin Schneider" , Subject: [PATCH v2 14/14] microblaze/thread_info: Introduce TIF_NOTIFY_IPI flag Date: Thu, 13 Jun 2024 18:16:13 +0000 Message-ID: <20240613181613.4329-15-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613181613.4329-1-kprateek.nayak@amd.com> References: <20240613181613.4329-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CH2PEPF00000145:EE_|DS0PR12MB8199:EE_ X-MS-Office365-Filtering-Correlation-Id: ef6dfaba-d5c2-4715-349a-08dc8bd5d9c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|7416009|1800799019|36860700008|82310400021; X-Microsoft-Antispam-Message-Info: B7qx4qbAwR4ebL9d6362WPNN+A5sFbmK3PrB8C1tLXA9221ZI7HJrr4+t5hj03c7T+FICa+ZO58MHDlSe16ugEZDSmWXiR0b6wdcNVCPfFkycTMBqH3g/KA+VyvoEyJpJsA1XM2r8t3EJEkXDKDW7E62UOIpai19cWLy2PHbcaQgmKHzSHH1ucbp9ZBwWrRhBeIt2miysah950/lMb1ss6a1YvieAV5pUCrkkxfxOcfbXarwtUZf+ryzjchvYwcHdUms7cxXbqDBiuCl4FF+kMy3xJ+jpFhjGzFWmvZrYMhuz2EaMfVoTWPknjK7HTmYSmFBVeu2XXOCEUECribmUltMCtkaSV1wBbw1cy0nw3L7AR1zGaVpownZ6EpqeFrjm9lZamO0h81ypzZQfNihESqYHtEOalWB1QYIaCUUwPgy6h4FTc/La/El+n/DJ1XFN1tSFN8qFXeOTN0OODSPQOtK2OmqPenNn6okVESpzLTBda8RV+SymNkFc15pAo6svdK+260I09l8TaZrXcm2PPMx8TosEAUhJKWUPEu/HNCGeUpvptk9Ro5wSkPFKI8k5iG8I1mIYOTNTp/TQpESvIJKd4RYJD64PIDLaRnktXz7f3vZ+Hbdo8o1m/FDJNld7zCFAT3oazRrT+l/FKnR4Vo3zSuB2xTBtUcTVS4OAROXo1tEQr1mCjnqnlapWsfJrk2dBLQ1dBTtXypMnH3beIIMsY9MMvZ+JC/KBdgeye/esmIKH+R9o87d9fhDbi+GmnnatblHOtvWXDB15mN6rekwsGoAsEvGYzzFTEcz6WJFEe4mrCUvkwBoaT/FHazu7qoaFOoPLKD2LHZQPh59TN68DDpbtPKHFHTWeWLkIFmP6qoVM5dRJvSykk1tKTHEhHC3Wn4bX+b9HtWVzudJ5n9Azho4Dybr1AXBEYNTA9Iqh20XHlnPXPmclJJ90HOHUR/Vrt0P2hAoIyubL8d6Ok0qPSf1gLDVNBsM5UuQzdNzHCjO9kfe2jGo0pT+AEmHqHI3PJO/Jr8Hx9jvW7YoW27A8ahDzCwPxvCw0+EIdLEXsF9r7qZquAvYdFd5kGhV6cfDspv/OlyVdv/dcTr1TJx+i5yZ8ty1ZvSH4rfDg2Q/Wcq5oQ4S5BHN1T/Zm5yNUyJe43DqyyzHBBLn6ajbZUXwfE5D29iE8d8J0AcPVHwVSfBzUHOZYDnGAtRAS73cgouiVbpEIqIOtm2iZijX7HP9aO5w/hYcYUUioLZGxwbBnOXonjfL29yOmue/6zzEeP8ltFOjlAlYGiNGMjGCMq5771RZPUcmxCpOZOCmPmD9pkqd88/xNRzwMH3cuMpW7O8eMkwUEPPAwE3vzRpJGVuCzms3zEdQxy6V4X6mnQP48xJ1K8ZbaEfleM+fkBms6ZMvMyyzCWLiHfXRyFtgRw== 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:(13230035)(376009)(7416009)(1800799019)(36860700008)(82310400021); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:22:57.5077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef6dfaba-d5c2-4715-349a-08dc8bd5d9c4 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8199 Add support for TIF_NOTIFY_IPI on MicroBlaze. With TIF_NOTIFY_IPI, a sender sending an IPI to an idle CPU in TIF_POLLING mode will set the TIF_NOTIFY_IPI flag in the target's idle tasks's thread_info to pull the CPU out of idle, as opposed to setting TIF_NEED_RESCHED previously. This avoids spurious calls to schedule_idle() in cases where an IPI does not necessarily wake up a task on the idle CPU. Cc: Michal Simek Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: K Prateek Nayak Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: K Prateek Nayak --- v1..v2: o No changes. --- arch/microblaze/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/microblaze/include/asm/thread_info.h b/arch/microblaze/include/asm/thread_info.h index a0ddd2a36fb9..953a334bb4fe 100644 --- a/arch/microblaze/include/asm/thread_info.h +++ b/arch/microblaze/include/asm/thread_info.h @@ -103,6 +103,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SINGLESTEP 4 #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ #define TIF_MEMDIE 6 /* is terminating due to OOM killer */ +#define TIF_NOTIFY_IPI 7 /* Pending IPI on TIF_POLLLING idle CPU */ #define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */ #define TIF_SECCOMP 10 /* secure computing */ @@ -115,6 +116,7 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) +#define _TIF_NOTIFY_IPI (1 << TIF_NOTIFY_IPI) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_SECCOMP (1 << TIF_SECCOMP)