From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 825D3E9A02C for ; Wed, 18 Feb 2026 18:23:06 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fGPyJ5sT4z2xMQ; Thu, 19 Feb 2026 05:23:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771438984; cv=none; b=FSI14WQkUZcJauQKOclaTKYvKbJNme5CmeUm3PZgwVSV+cvItHLypPN1c8Drq/kGUp+GTuaw2P40l6EWuXCbedeA/UoSm6FTYLiTH6vyEg3gmbAz2yWIiir+QcRVkCrLm6MriHt4cUfXlA5yJVmSShJ4Gvqxf7egUZ3oK4BxE1GIukEYBuw/QAhHTq8d1fOOqq+ESlS42KiR1+fki7bwoFInPbbQOrfoCOTkH/hl65wf9G5Kwqu2PF+VJjpBQojGr5NojdPwiGsU6hJLlOaLpL3BD655Mc5r9D60salEhBRZdUkhJk/Y5wFTWkbyFzBGyKHPr+b3+8/Ji+m/4x2Tlw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771438984; c=relaxed/relaxed; bh=0NPWXcFnDOyF2XkV+Rxo1cDo2IfbAk+Luw7jV18Rj/U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JRojBzlgFnL9H8dOKADXiCOdB9CQaWE9TtzKmZLG2zOCmOUtLQOfW0ineF531O82hOPk+rpeQ3qeMUrD5MePGc2Dfd0gBTAqUIUcQmn75VBxHOhD6lxB45DO8CNZX0g2AlyTPO/BRDAx6wEWZz0+w+o4yZKo0pvn7y90Hj8cRkb8T21nUHLEqUHdn5ZzITRYHVRxeJviWrpT+X8tltC6m4iPIxWsxEuz3Mjmr1pqmqqTr+Tu6vXokLasppFpBV7v1HxNabcOQJxM/tRjGY1iQKN06ENlQWPJWZ0PbmtKK3DoxCwj8savvj+czNFdWbOsfUDjcjKJFLTaA9XF74yFpg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=dZSttBme; dkim-atps=neutral; spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=sshegde@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=dZSttBme; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=sshegde@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fGPyH5Nxhz2xLv for ; Thu, 19 Feb 2026 05:23:03 +1100 (AEDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61I69h8C3354314; Wed, 18 Feb 2026 18:22:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=0NPWXc FnDOyF2XkV+Rxo1cDo2IfbAk+Luw7jV18Rj/U=; b=dZSttBmeyn0rgoRLmT9MW5 RfxeQ20a7Z1JlJpekhxW/KrES0KvhHUozMNOLpaY+b1YE81cIq/elsLZQKqaB7RL 5B5lM40oC5OBu/IlXsDHmZIqT1euMdrEdWeaDv4b4jqKFFOErauw0o9O+vZbfySA WSOiefu3ETCipTeyuP48ZSUW269UimsV0B6W1Nxv2YPhx/PITemnt59g3sho95WV GGzzbBSoL/Eq5T2xHwGGtxmEt09gKc4pDY18VdrW/Hu/DA9EoY0CNzOYPApH3Rpo ywv9h7owfgC3zbLC5DuMosIt7tot+uGGteXO1vGOe07uRfQpcxRdksGpLgB0Fxrg == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4caj4khh2s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Feb 2026 18:22:42 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61IHSK5w023899; Wed, 18 Feb 2026 18:22:41 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ccb45916w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Feb 2026 18:22:41 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61IIMbOx24707830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Feb 2026 18:22:38 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA9832004B; Wed, 18 Feb 2026 18:22:37 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1B9420043; Wed, 18 Feb 2026 18:22:27 +0000 (GMT) Received: from [9.111.93.209] (unknown [9.111.93.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 18 Feb 2026 18:22:27 +0000 (GMT) Message-ID: <8fee8933-1b27-41f2-b198-45a2d1390e70@linux.ibm.com> Date: Wed, 18 Feb 2026 23:52:26 +0530 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/15] sched/idle: Handle offlining first in idle loop To: Frederic Weisbecker Cc: LKML , "Christophe Leroy (CS GROUP)" , "Rafael J. Wysocki" , Alexander Gordeev , Anna-Maria Behnsen , Ben Segall , Boqun Feng , Christian Borntraeger , Dietmar Eggemann , Heiko Carstens , Ingo Molnar , Jan Kiszka , Joel Fernandes , Juri Lelli , Kieran Bingham , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Neeraj Upadhyay , Nicholas Piggin , "Paul E . McKenney" , Peter Zijlstra , Steven Rostedt , Sven Schnelle , Thomas Gleixner , Uladzislau Rezki , Valentin Schneider , Vasily Gorbik , Vincent Guittot , Viresh Kumar , Xin Zhao , linux-pm@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <20260206142245.58987-1-frederic@kernel.org> <20260206142245.58987-2-frederic@kernel.org> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260206142245.58987-2-frederic@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjE4MDE1NSBTYWx0ZWRfX4BHUtWXNKtVg 3KkYKoHQGksJGb5a85dTZyKSuB1eQjs2W65mF88ZJ/Lga6//SaoNXf00GorPbK5iYBjIBVAO8Uc Nl7ohDKnr0l4koacb0Yaqfz94dm3JPRCJ7st9LyQ/IiPpfI/gf9hmdAC13VRJSoEgg0FsIpd/qg /6tWZa1uQbzyQZb3UiXy5ei1dXy0MX1eAhdf39ufbGcoYyIE7IXuoRemV9vcpaFY/i9WiWNVVhK jVoOnBpQU80AKME8VbYT1e1nn+bpBT8bguJ6wThSzkrQvnWLi+j1cnI9YqBOQ/UMkiNHuR71abf gicMz5PSh0mI19k7Gd785eYJoBFpn7AP6LYPYPfsszV5dY+cBI+DQz+OkZMz1t+9JTfcWbUSEO+ 4cNDo1UpiXuA5njoL84nNBYbWTMA6SO29O/RQo2MGUo5w8WLQ6lFT7FCjBFguPcO5zEMyc6PPt9 Vc1AQLFwyBGdrzDTXrw== X-Proofpoint-ORIG-GUID: B1NrpVy1KPkVC7VW6YlK3OnaFYL4hO7q X-Proofpoint-GUID: IhRE2r75_C8EqT2m1I81Y2_I-sw0Vcda X-Authority-Analysis: v=2.4 cv=M7hA6iws c=1 sm=1 tr=0 ts=69960373 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=M70JiF8069jlCNdMrNkA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-18_03,2026-02-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602180155 On 2/6/26 7:52 PM, Frederic Weisbecker wrote: > Offline handling happens from within the inner idle loop, > after the beginning of dyntick cputime accounting, nohz idle > load balancing and TIF_NEED_RESCHED polling. > > This is not necessary and even buggy because: > > * There is no dyntick handling to do. And calling tick_nohz_idle_enter() > messes up with the struct tick_sched reset that was performed on > tick_sched_timer_dying(). > > * There is no nohz idle balancing to do. > > * Polling on TIF_RESCHED is irrelevant at this stage, there are no more > tasks allowed to run. > > * No need to check if need_resched() before offline handling since > stop_machine is done and all per-cpu kthread should be done with > their job. > > Therefore move the offline handling at the beginning of the idle loop. > This will also ease the idle cputime unification later by not elapsing > idle time while offline through the call to: > > tick_nohz_idle_enter() -> tick_nohz_start_idle() > > Signed-off-by: Frederic Weisbecker Makes sense to call it outside the loop. Once you report idle is dead, there is nothing to do that CPU. Reviewed-by: Shrikanth Hegde > --- > kernel/sched/idle.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > index c174afe1dd17..51764cbec6f3 100644 > --- a/kernel/sched/idle.c > +++ b/kernel/sched/idle.c > @@ -260,6 +260,14 @@ static void do_idle(void) > { > int cpu = smp_processor_id(); > > + if (cpu_is_offline(cpu)) { > + local_irq_disable(); > + /* All per-CPU kernel threads should be done by now. */ > + WARN_ON_ONCE(need_resched()); > + cpuhp_report_idle_dead(); > + arch_cpu_idle_dead(); > + } > + > /* > * Check if we need to update blocked load > */ > @@ -311,11 +319,6 @@ static void do_idle(void) > */ > local_irq_disable(); > > - if (cpu_is_offline(cpu)) { > - cpuhp_report_idle_dead(); > - arch_cpu_idle_dead(); > - } > - > arch_cpu_idle_enter(); > rcu_nocb_flush_deferred_wakeup(); >