From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 3D55730DECC for ; Wed, 25 Mar 2026 05:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774417029; cv=none; b=nW1iufjho3OMC0LcM2vWoIMg41GAuB/Q7MkobKOYjpmE1/QPCNot4v1o25KPQU8OSoLYsYmrML7+n4liLl87NtTXP9RR9M2YSGo3hXDXOhe2ngUwEs9Hh4kmojSJUOF5CwwQ7b34+JdoUa2AEsCNrDuX7qa/BGUYR6n/z9pZVhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774417029; c=relaxed/simple; bh=VfbE5p6XxWDtrZKL4z25W3T7EhTAqU1R09iqQNmKxnc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DVxEVDhoXGskifATyhfOL+nrYoghtNVYZPTS+SRq/bo92QnewTYfDPZutndNyNggolaz4zdPEle8mSffUYu5WTd57fGUvblGqlbCRLXcLxiwjIoBiIJNQwFwTpK+nSJZZelD/aHKAsut0EQ9tkrVgKcOg01NSup343ZKOp4sJ2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Nv/hLECV; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=O4mMw/xS; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Nv/hLECV"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="O4mMw/xS" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62P2JDfm3057430 for ; Wed, 25 Mar 2026 05:37:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= T4OZ7+DhzAq7S4Ng68Au4YsE5QtH605huiFIU9p+rIo=; b=Nv/hLECVJIDE5rWb FZ+2J1HimcyyiTy96vTZ5lDjZCOPJrIzcX5BCBtdhvlDzEJSCPwLcEFws9+vFfD3 EHQKUHzy/zWLe4vcjjPsL3qFXAhzx3DrPG3WXW9jLiJrnbV/ywQyVg0/Sv/bWLO8 QF/DWtdvZgCD0urnhK8QuUhAHcJF+8RoqOVHgEE0FiiJDJRfHmmMY0Olk9VwOeYJ HoBwcwisTT977Bl0TwNg96HZ8VRTHGCx3ULcmIn1grRVZC2Jzyep8q6bSXM2uDZv JX4HfKjGcXI8UWO/jNarE8kEyTvHoY9vKUG9bBU7bOxjVr3eYJH4r4qB+Gd45UHc ARdINA== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d46tp0j17-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 25 Mar 2026 05:37:06 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c741f044883so1460319a12.0 for ; Tue, 24 Mar 2026 22:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774417026; x=1775021826; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=T4OZ7+DhzAq7S4Ng68Au4YsE5QtH605huiFIU9p+rIo=; b=O4mMw/xSKzBB5fsbdg136ZIbExNbVSio+gfzpW/Gsvnt9KBrW6s5CIPKzbf7TuMaId yGnXo0Eq9xPQh7zWrYH6cfV7M/yQLbAAmaNAz733IRYR65gNeu4zUrNT/s6P4LkjGOC2 OVI9jZ42HoYs/hVR+soLkoyCeK76ryVqZc4FSGlh0aZcBzVM/hTJ9jod2758LAPcQVrT WTkmUepKWDmbDi/D5QE0oa6SiLll558G5BN2zINgVTZExbn6fNNJw7xRWpEM6YBEgLtr HftO8u4jeQxmrI4g9kgRZOZ5mu7Cr2J0kgUo/MhowV25U3GDzZnf+iY83/pRxY5hnGlg Obhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774417026; x=1775021826; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T4OZ7+DhzAq7S4Ng68Au4YsE5QtH605huiFIU9p+rIo=; b=LcU7B91p+xQdVZBBV6Ap3x+2ueDLYvXshUXdAI8OL08Uzoa3mz6NpxHoe2C9Jf3o+s 2IQQOzCMeFevKXX6QNIJoTDrDS4NUAgpYNEkr6MugHm1D/rMX6oNm1nlNmsvvJVGtE+W ayE2jk2YUkUDAT20zXMOZlx/3OZbuhugaedhLhZgTN5MfDuL08X5l5zubRHrJxY2MEm1 a22oObjIr03ItPk6Dmelh/HFUMXdRJCCCIPO7CJ54Q9ferBpbC9YQNM24izQscKG1+Ch HcDkCKnm7vyZHhkqZQcag1sLv7M+U7hTDSoEd8KiB2xwAsUaBKXQyakKkMQwnEXAVGNe JT3g== X-Forwarded-Encrypted: i=1; AJvYcCUbIDISVEtz1OJRacUc7WAYjxcyFFjzYGzX3N7ZUdpL3DJxVXm15SbisbeOLrmUrxujtp1VyhjwoVy3TAY=@vger.kernel.org X-Gm-Message-State: AOJu0Yzy5uvHtUpBhknu5lYgU1331p/Wx4L8E9AvhpzwcC7kQTZYU8JU 7Bb1syJI3vCGD69csyYZF0P2ujC1Vgfsh/zA0bjApkAIb0dNjz2vBLy/E6s272SyPP4DAacmcpb ZpwVFh9Peyn2IG9QiTs+1DGVQ4RJgxwfjDd2NxI61kosHftFBs+tWtBYVOsxiSNScuN0= X-Gm-Gg: ATEYQzxAPI3oqP8zoCsZmqwwKcJhf3MyW4szbql8VMGXVsrFfDJgqYJWFwVXU8/wnhk CwZHAP11Gc0pwpL5hPBHkh/AVnCeexfD8XwhpdVBV8TZAJFn+vefrDIh3lccl+h763QiDBNlWIM tvPV6l8eqms5E7F/3pmRKGwq8Ro+80+3ZlBQGOH1CLymJw7EpHwUUQftjrkyvugxxrnZjT9XjSv 4Yd4glwwGJnzTPS2l/VJUIhohpWSuxjpaQwWmL2AqpuycK93d8onrhzBvajotC64lS533ANQT3z Ehr3/dS7MZrqtfPJvkIxQfYJMfSSVK/MZYM4DmwOlVcdvNWef5PoYLfzXLZz5QAAoMsdCvj4/dM f8VcWZRbhkupAsvTQBOgEXSnSNPXQR3HY25OmtY5d4/rLXiq/wMA= X-Received: by 2002:a05:6a00:420b:b0:827:3710:2c3e with SMTP id d2e1a72fcca58-82c6decbba0mr2114526b3a.14.1774417025589; Tue, 24 Mar 2026 22:37:05 -0700 (PDT) X-Received: by 2002:a05:6a00:420b:b0:827:3710:2c3e with SMTP id d2e1a72fcca58-82c6decbba0mr2114506b3a.14.1774417025030; Tue, 24 Mar 2026 22:37:05 -0700 (PDT) Received: from [10.217.198.242] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b03be3396sm15360546b3a.27.2026.03.24.22.37.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Mar 2026 22:37:04 -0700 (PDT) Message-ID: <6d1cc767-05b2-428e-9328-599bf7721d72@oss.qualcomm.com> Date: Wed, 25 Mar 2026 11:07:00 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cpuidle: Deny idle entry when CPU already have IPI interrupt pending To: "Rafael J. Wysocki" Cc: Daniel Lezcano , Christian Loehle , Ulf Hansson , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20260316-cpuidle_ipi-v1-1-d0ff6350f4e2@oss.qualcomm.com> Content-Language: en-US From: "Maulik Shah (mkshah)" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: vrzlK06kkoRa7y3kgraG0bPXbXlklD9f X-Authority-Analysis: v=2.4 cv=F4lat6hN c=1 sm=1 tr=0 ts=69c37482 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=NEAV23lmAAAA:8 a=EUspDBNiAAAA:8 a=6lJ8GlR-gWZHLfuqW2AA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: vrzlK06kkoRa7y3kgraG0bPXbXlklD9f X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDAzNyBTYWx0ZWRfX/j6N82WaddVJ 9orcxYUMLpcZqRxgpT7e275aaubNaQsFrbI4ArgaP5oCRnRiZr1b3+7xEta1z2vTYL+RjVJWBAF K6sfKM+J135tJOxiVAveeLXUoaY1BMp62GaGHCmIvcCNDG/xZPKNsZfvbbcMS9XTdgAWE7HaQK8 z3jr2mjiTK5nN6Zzk+kSePE79BnpwI/7ml84eRxOVTLt/xovPkahXe6NV0CbD5IzrmHgJW0CD7x dL2Sf0VtnxiQZWc3xspDENOU8G81/+B8VyuYO/Tp0vAcRLKH1iUb/HCC82HzJbzHlLxpni/+VYl sNOzjyEkW1+xbiggJNAA2nvm24N2qudGYhmGSz6Rje7eTttydTo/TOGBbGlrhBsHnStVS3RkcBA LhmUnuK4RfCndsdpc7+fzEE6t5UQuARsYLEtTYuWp6McSWvpFLJi5WvVfmTCQzoEFhmvY0Pxp+v 43mYhkm1V7sSTxLKSrw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_02,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 malwarescore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250037 On 3/24/2026 9:37 PM, Rafael J. Wysocki wrote: > On Mon, Mar 23, 2026 at 1:13 PM Maulik Shah (mkshah) > wrote: >> >> >> >> On 3/20/2026 11:59 PM, Rafael J. Wysocki wrote: >>> On Mon, Mar 16, 2026 at 8:38 AM Maulik Shah >>> wrote: >>>> >>>> CPU can get IPI interrupt from another CPU while it is executing >>>> cpuidle_select() or about to execute same. The selection do not account >>>> for pending interrupts and may continue to enter selected idle state only >>>> to exit immediately. >>>> >>>> Example trace collected when there is cross CPU IPI. >>>> >>>> [000] 154.892148: sched_waking: comm=sugov:4 pid=491 prio=-1 target_cpu=007 >>>> [000] 154.892148: ipi_raise: target_mask=00000000,00000080 (Function call interrupts) >>>> [007] 154.892162: cpu_idle: state=2 cpu_id=7 >>>> [007] 154.892208: cpu_idle: state=4294967295 cpu_id=7 >>>> [007] 154.892211: irq_handler_entry: irq=2 name=IPI >>>> [007] 154.892211: ipi_entry: (Function call interrupts) >>>> [007] 154.892213: sched_wakeup: comm=sugov:4 pid=491 prio=-1 target_cpu=007 >>>> [007] 154.892214: ipi_exit: (Function call interrupts) >>>> >>>> This impacts performance and the above count increments. >>>> >>>> commit ccde6525183c ("smp: Introduce a helper function to check for pending >>>> IPIs") already introduced a helper function to check the pending IPIs and >>>> it is used in pmdomain governor to deny the cluster level idle state when >>>> there is a pending IPI on any of cluster CPUs. >>> >>> You seem to be overlooking the fact that resched wakeups need not be >>> signaled via IPIs, but they may be updates of a monitored cache line. >>> >>>> This however does not stop CPU to enter CPU level idle state. Make use of >>>> same at CPUidle to deny the idle entry when there is already IPI pending. >>>> >>>> With change observing glmark2 [1] off screen scores improving in the range >>>> of 25% to 30% on Qualcomm lemans-evk board which is arm64 based having two >>>> clusters each with 4 CPUs. >>>> >>>> [1] https://github.com/glmark2/glmark2 >>>> >>>> Signed-off-by: Maulik Shah >>>> --- >>>> drivers/cpuidle/cpuidle.c | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c >>>> index c7876e9e024f9076663063ad21cfc69343fdbbe7..c88c0cbf910d6c2c09697e6a3ac78c081868c2ad 100644 >>>> --- a/drivers/cpuidle/cpuidle.c >>>> +++ b/drivers/cpuidle/cpuidle.c >>>> @@ -224,6 +224,9 @@ noinstr int cpuidle_enter_state(struct cpuidle_device *dev, >>>> bool broadcast = !!(target_state->flags & CPUIDLE_FLAG_TIMER_STOP); >>>> ktime_t time_start, time_end; >>>> >>>> + if (cpus_peek_for_pending_ipi(drv->cpumask)) >>>> + return -EBUSY; >>>> + >>> >>> So what if the driver handles all CPUs in the system and there are >>> many of them (say ~500) and if IPIs occur rarely (because resched >>> events are not IPIs)? >> >> Missed the case of driver handling multiple CPUs, >> In v2 would fix this as below, which checks pending IPI on single >> CPU trying to enter idle. >> >> if (cpus_peek_for_pending_ipi(cpumask_of(dev->cpu))) > > And the for_each_cpu() loop in cpus_peek_for_pending_ipi() would then > become useless overhead, wouldn't ir? Given that mask in loop for_each_cpu(cpu, mask) will have a single cpu, overhead should be minor. or May be we can have new API for a single CPU case. > >> I see IPIs do occur often, in the glmark2 offscreen case >> mentioned in commit text, out of total ~12.2k IPIs across all 8 CPUs, >> ~9.6k are function call IPIs, ~2k are IRQ work IPIs, ~560 Timer broadcast >> IPIs while rescheduling IPIs are only 82. > > So how many of those IPIs actually wake up CPUs from idle prematurely? 282 times out of total 12.2k IPIs (~2.3%) hitting the newly added condition. Thanks, Maulik