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 669411DF736 for ; Wed, 24 Jun 2026 11:26:00 +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=1782300361; cv=none; b=YCtcNq6Eosh9ldDUhNGKH3XxHj8IRNy+Q3hP4ofOfUnv3Csfp/OB8ZVOrqMj7bpqyqCZk9BcvKQdyTOQ0LEeRrqLxVBuRAQmMXQMSpp9o9w/Lz+h9y0yoxUALYryDuO0ZmLWbcoyuhQku5BgZat1v9EIGrUZZZP2cg4qvK/qDZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782300361; c=relaxed/simple; bh=QyRMrgiQxK+4SZ4C7IkqGeqvE/p929yInSvh801TBuI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=s58EgGMSL3tVw2mYSPb8b/2/id6WYGT6AoV4XP8iUXPH5ZasggD0VhfS749yZc/tqxvBv7UwLpjfTl1YHiRD5/lDBfN2Do1zo3uNxUxGD79DSdIrwRQD7BMLNMU2XGcurBz9AMeqdk7hePBEuRVnd6scU7QgaEieUX6W9gDz4x4= 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=K5Yjp8/L; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eTH36Tfd; 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="K5Yjp8/L"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eTH36Tfd" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65OANgbL1148323 for ; Wed, 24 Jun 2026 11:25:59 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= Yw8koDn99ZeNzw5vCl5OzTNmlRbyRxNk1xWkFyFXfr8=; b=K5Yjp8/L3kZ8wWMR BYaQdj3VqiNDeCZvVFI081ydLbeUVqRIZi/s5d/N8+nw5s90qFDS630JBaMqvyI8 YOL/5hcccIWOhqu1r5MvyNc6Gk56tZUDq9GoHG1rtwfW+194hcfci1WVGbK5tfbY agtiOOAGPmdT72NFDzed6LjN8M+17vANGpNLvvZYQ4agpAlKn4bdnBOKetjjQZAk w3cvDos3RdsCHJOH5qgzM9y1ugt8hwtYkU121yh1Pu4q0jbgvVWJ8JNO3MjGd2J4 OIoMsRDhUCTbC0Wr1NTr+pwoo4RKBg/GQQmMXlbMXLrGhM+VD8A4kJpUarj34SeU bwe1yw== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4f06r31t44-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 24 Jun 2026 11:25:59 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-84534f17866so931658b3a.2 for ; Wed, 24 Jun 2026 04:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782300359; x=1782905159; 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=Yw8koDn99ZeNzw5vCl5OzTNmlRbyRxNk1xWkFyFXfr8=; b=eTH36TfdOfWiRM1+5VftBkMxaMsrvndqymKRKWI1Oq0glm9uP7glN1xHozTjM2ndXX iretqx2TC2INB9a/21DvOHetY4W6RM8mn220fxJvqscx9VwKnUV9maqygCF0UNkSpp/e nMxnTZVoVlqBq6cocqcJPWJf0feU7MUfRbpM3yBcDapBjwnXnuiymsZTigqHeeixFjgn DGRudRw2MOvF0+qRV6dqyEwOWkO8q+GC+oiaNvnrMSMR+1ktyOkkTk1NawcmxjZjPQay KP9usrj5gOm/xf45rpVsCpPe4pBZUlvUv6JNuMiJaxbB4v+JZGIQSpmjMWF8sr7AfXvE rObg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782300359; x=1782905159; 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=Yw8koDn99ZeNzw5vCl5OzTNmlRbyRxNk1xWkFyFXfr8=; b=VGKlBtrrIzGomJyw5LIYlUGt0WbipT/z65u+xL1qPIl8401ovWcDZDj/7naJjuqp19 Joj54Zs8pX5/GGQ+W11TRZl1F91Qa9IGy5GQWzJIJDhr7KWwrxlk0+zgT4HpnQ6hX81i Z+bjop3AxLjimWQnKyXhz053qwICPMetrPHl+sE+wOiSsD9SALJ+Q1oKVxpntJoZd0JC HaSRPqnNOd1MGdkW95he4I7W0v8Msi1qaUSZYz+t6Il0FqwRXZkhkmuk9+5NMOHQUN/R dN+WdlOqFj5stm9ifyjXeB+jKULDFVHLSjt9wjNKnynyPc5yP86IsdAQK0b4/WiAjH20 1j+Q== X-Forwarded-Encrypted: i=1; AFNElJ+xYuaQryoQmRKvSwLw1vQsmQZYYEw2mGScuLJ//n6XcBT/TWctQtragFb5MgC5Fun9pyBFqy9BajwbGV4=@vger.kernel.org X-Gm-Message-State: AOJu0YyIZqFCDVU4bAuzqHjKxiqRxVrbiX5hM3v5sR24Rk9tXgGjyqV6 mV1wU+25q4/okYZYEh0vf0zEHHRoBBxVJHegvDw31n83xsod0mBxHcs+Y4uB1oZN0tcUSI1Yv84 x2qC5/F23H71gQecsLaItC+f8SGB19ER4YGzLf+gsswUtYFxzutOqXoEwt7mHSDKSjnQ= X-Gm-Gg: AfdE7clHe9i2DbRt5mgLqeRFvURUogzuVlJu4Uvw9WGaxp7wt41QztcQ9rqXecuH/Gk A09526Tu6S1p/koNq6c77rROsC3PzgqbZSkIQyGcCkSIsPtsLZLtCc2vwSL3eLqClYHEn9qHaTO 4uZEEOxrq6ydAd89T3zMOPEsQBa0TCTVZqsCjICCbG/rLqRoWH/mhJArbjAgPGftefA5YPh2Ehe 2yNsdc3UkrR95BfEfAKKSNAOShAY6Z0auGYs2seDcgp4mBSTyGuPSAL3QPYcqRnw80e4Igh3WFO 1PMMgkAADAnT7z6r86JbZqtOkXqF2QXHRbWubN/CEq5FPHENCoyp07Rx0COEg4/pZpYsI9yK7OO eS9jZGy8V8Zwn8eGRf8PEWRBVu9F9vz5bUr9H4eJ1PLEc2EPy7lN4HvZivVj4UdlhlAg4rVyUEm dlIK8aZxI= X-Received: by 2002:a05:6a00:2e96:b0:843:468d:7804 with SMTP id d2e1a72fcca58-8456255cc6fmr21221619b3a.34.1782300358955; Wed, 24 Jun 2026 04:25:58 -0700 (PDT) X-Received: by 2002:a05:6a00:2e96:b0:843:468d:7804 with SMTP id d2e1a72fcca58-8456255cc6fmr21221592b3a.34.1782300358493; Wed, 24 Jun 2026 04:25:58 -0700 (PDT) Received: from [10.133.33.204] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-845a4122616sm1972257b3a.52.2026.06.24.04.25.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jun 2026 04:25:58 -0700 (PDT) Message-ID: Date: Wed, 24 Jun 2026 19:25:51 +0800 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 v3 3/4] cpufreq: ACPI: Use IPI to update boost MSR in cpufreq_boost_down_prep() To: "Rafael J. Wysocki" , Jim Mattson Cc: bp@alien8.de, tglx@kernel.org, x86@kernel.org, viresh.kumar@linaro.org, yosry@kernel.org, andrew.cooper3@citrix.com, ludloff@gmail.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Sashiko , zhongqiu.han@oss.qualcomm.com References: <20260618224527.1506419-1-jmattson@google.com> <20260618224527.1506419-4-jmattson@google.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjI0MDA5NSBTYWx0ZWRfX1Y2tJiX4JAfq j7tSdhIG35jhy3/ZvFH5+Ipo0C+XHRbPYR61S52TgU0stZurSwSbyZjXejtdLvXengYxoXXhGHj EW19EmXhConC4ki0cxyqwFwRnxnj6O7MbVF8fRYkkyktQ8fXkEgdb1ijkF23Zyxpc4geLvdbRAi gA5w18RJ4tSe5pGRS8w6/WuT5RBW2SzVc6HKQQU7msTvR3HOmNGJtj0RTeZp6/kt7qDJvvdOsEN jFf2ixWA7NbM+6z3UYG57aN3QFat1tyk5Tc0KNZd7UZM+NMDbrfjgNxyc7pYoeDdciTI/dwIdMB ZJJao+US53LrnKe8hdUVbIxvTMtQyviX+E/htIm0RwCr45ZcAAPolDiE26Lfta4iLi8FhUv6Mi9 tXGl5TEdyvSfkrEoDYgnXUe9Szd1ROmJd6WsO3CERNlgtDXJ4ddungLIXXl14YhVRth3eAMZ+Aq MRDsHm4BH0X5xPfYyjg== X-Proofpoint-ORIG-GUID: c1To4YhWKzMkCLvugmRtPx4X44dajmlJ X-Authority-Analysis: v=2.4 cv=ZM7nX37b c=1 sm=1 tr=0 ts=6a3bbec7 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=c92rfblmAAAA:8 a=1XWaLZrsAAAA:8 a=VwQbUJbxAAAA:8 a=eh6w_bVcWWKbaMIl5p0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-GUID: c1To4YhWKzMkCLvugmRtPx4X44dajmlJ X-Proofpoint-Spam-Info: AW1haW4tMjYwNjI0MDA5NSBTYWx0ZWRfXy1PfeEh/s1Q+ Gx+XWixYGz/XcAjG1UHU4C/f4OgvXtck8qzeNclpbZauiFW0VpPL09IbnbVZdzb2jdvyl1l6RDx pjSIP/zm9Lfa7GhTlEz/L3t5Yg+nYA0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-24_03,2026-06-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 impostorscore=0 clxscore=1015 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606240095 On 6/23/2026 8:47 PM, Rafael J. Wysocki wrote: > On Fri, Jun 19, 2026 at 12:45 AM Jim Mattson wrote: >> >> During driver exit or CPU hotplug, acpi_cpufreq_cpu_exit() calls >> cpufreq_boost_down_prep() to re-enable boost on the target CPU. However, >> cpufreq_boost_down_prep() ignores the target CPU parameter and calls >> boost_set_msr(1) locally. Since this runs in an unbound process context, it >> updates the local CPU's MSR while leaving the target CPU's boost state >> unchanged. >> >> On Intel platforms, the open-coded read-modify-write of >> MSR_IA32_MISC_ENABLE in boost_set_msr() is vulnerable to preemption and >> thread migration if executed in process context. >> >> Fix both issues by routing the MSR update through >> smp_call_function_single() to execute boost_set_msr() synchronously on the >> target CPU. This ensures the correct CPU is updated and that the RMW >> sequence on Intel executes safely in IPI context with interrupts disabled. >> >> Fixes: a3605c46e0c0 ("cpufreq: acpi-cpufreq: drop rdmsr_on_cpus() usage") >> Reported-by: Sashiko >> Closes: https://sashiko.dev/#/patchset/20260612215729.1532175-1-jmattson%40google.com >> Assisted-by: Gemini:gemini-3.5-pro >> Signed-off-by: Jim Mattson >> --- >> drivers/cpufreq/acpi-cpufreq.c | 7 ++++--- >> 1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c >> index 21639d9ac753..48d678812fd6 100644 >> --- a/drivers/cpufreq/acpi-cpufreq.c >> +++ b/drivers/cpufreq/acpi-cpufreq.c >> @@ -528,10 +528,11 @@ static void free_acpi_perf_data(void) >> static int cpufreq_boost_down_prep(unsigned int cpu) >> { >> /* >> - * Clear the boost-disable bit on the CPU_DOWN path so that >> - * this cpu cannot block the remaining ones from boosting. >> + * Clear the boost-disable bit on the target CPU so that >> + * it cannot block the remaining ones from boosting. >> */ >> - return boost_set_msr(1); >> + return smp_call_function_single(cpu, boost_set_msr_each, >> + (void *)1L, 1); > > While I have not investigated the history of this code, I'm wondering > why cpufreq_boost_down_prep() is a separate function and why it takes > the CPU number argument. > > The only caller of it is acpi_cpufreq_cpu_exit() which could just do > > set_boost(policy, 1); > > instead of calling it (and might check if boost was supported at all > for that matter). 1) It seems that set_boost(policy, 1) would be a no-op here, since policy->cpus appears to be empty by the time ->exit() is called. acpi-cpufreq only implements ->exit (no ->offline), and ->exit() is reached only when policy_is_inactive() (i.e. cpumask_empty (policy->cpus)) is true. set_boost() does on_each_cpu_mask(policy->cpus, ...), which on an empty mask runs nothing. 2) The patch's restore on only policy->cpu (smp_call_function_single(policy->cpu, ...) will not fully cover shared policies, and how much it covers seems to depend on the boost-disable bit's scope (but that seems to be already discussed in the cover letter and is probably a separate topic). Please feel free to correct me if I'm misunderstanding the scope of the boost-disable bit: On driver unload the policy CPUs are removed from policy->cpus but seem to stay hardware-online, so a stale disable bit on a non-last CPU might still matter (those CPUs are presumably still running and may want to boost). Abstractly: - if the bit is per-CPU independent: clearing policy->cpu seems to fix only that CPU, and the other still-online CPUs in the policy may stay disabled. - if the bit is shared within a group (e.g. core/package), "disabled if any member set": clearing policy->cpu maybe only covers its own group, and other groups spanned by the policy could stay disabled. > >> } >> >> /* >> -- > -- Thx and BRs, Zhongqiu Han