From nobody Mon Oct 6 13:39:29 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 55AB22D3EC5; Mon, 21 Jul 2025 12:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101710; cv=none; b=I9q9fo1HQhDjE7O8n4hw4/ZG/VKHUziTcRSj12rkuFJ6s3EdtIixhRvL2K5uBKmlSHLZAbmp9xfAtqY3ldal92KtfLMRH7tMRPQ+wlUsZle2hrK1l5srmJ4y3LFNE6w6hU8oenCF1sTVH3o4NLFgzsCADu/hIC1UBLzK4kR+4qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101710; c=relaxed/simple; bh=qQsUHeoJ/j4D0gircpwU6t8Vcf76jammambJP2bRpHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sY+4oGTlWpuM9iwDmzPuveRiKFeT+0QBQYrTGNoCy37ImBQH0ETCWYtufG/KR6mpUVC6jsejkOFCsYoAa231jZPxMqPbZi1ojO+nBqvzmanR1DxKoZZzTOxGrmYa10wFrR5In1tskgiEnd1MeLqfX5qvGV4/6bYqrD0Y0+meFy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=JjUTKPJ7; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="JjUTKPJ7" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56LA4hWG015762; Mon, 21 Jul 2025 12:41:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= NbnzzDg7ZFxM4Sy8hBjxkah1SmY2zoBVYeJhIOgf2vU=; b=JjUTKPJ7vZCJZyoK biNBawQWUwT2crFmcon/6v3pbP7TqUeraKGO5hS9qgSdEccgk8AJJnTwIAPw/rri pWinqt6XploghpTNnVIqufYX3MJjkWlADBEwaaQ7Tr6K0PsT9rcjZr1g4Z1VsOaE hix1toPPWTdwyhrGPYw+rTc8uMJh7Rmop4xb5tomcNkB/TBKJkgZisM/OzfbE1nl S55Rwl3TyrER+am67IUWWucvjd1D1j0oLyRMVHHhCPoQWUpY2VSJMFF+4ZyAMEZT 2Vn3lMDTltisKJGn1wl1O/98Eut+mkO9CZCA9pmHN6NKPTJ1v9yz/ePHsUo8Qo9V 4NyQdw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 480451d11q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:39 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 56LCfcwU015641 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:38 GMT Received: from zhonhan-gv.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 21 Jul 2025 05:41:35 -0700 From: Zhongqiu Han To: , , , , , , , , , CC: , , Subject: [PATCH v2 1/5] PM: QoS: Add support for CPU affinity latency PM QoS Date: Mon, 21 Jul 2025 20:41:00 +0800 Message-ID: <20250721124104.806120-2-quic_zhonhan@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721124104.806120-1-quic_zhonhan@quicinc.com> References: <20250721124104.806120-1-quic_zhonhan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=EIMG00ZC c=1 sm=1 tr=0 ts=687e3583 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=tExEg1ksGLqWEgzjn1MA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: S3-RiFUH3mf_BEtztJi2CLMuxTvDnl9w X-Proofpoint-GUID: S3-RiFUH3mf_BEtztJi2CLMuxTvDnl9w X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIxMDExMiBTYWx0ZWRfX1tlSbUmk+mCR lRxIMNxtQcGNILwYm4KGxvyUQo133jXw2bcLkQwtLQO9H2y5WwPB+NOCwu54nY1CeLfFbv3wm5R 35rufHpPo7+2VxLkVwf+Elqev3dRflwBkM8lm7b3lQRaZtDeoPI/6Cci6+MNMQ5lfBXblhTl5eK KG6+mK2nebyCFxKHtt0NtcTSkx5mVG/F9F+ylpS1B/mG3VBhu8RiA3tsa+MnE+CHfV+Vh5mGWFQ aopnkMGhbYEubebIqGqEiKNSsRYkfmkb5L467C6HM98vptdKatbg9/keYvSWDtBF9S0HBV0pe5l zrPwftt+tcNw93kockC8rd2zlY3fALzOmAEqcy0EZ/Z4ntsYXU61LflAhbcFkoRuW1z0FoOi0Rd xhrkk8GMddaakr5qH5c4LZhGSCeJ6Iu70NAI8lb72GeI0/Y9pV+OKG6h6VxixkJQZx77TIWs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-21_03,2025-07-21_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 mlxscore=0 clxscore=1011 suspectscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507210112 Content-Type: text/plain; charset="utf-8" Currently, the PM QoS framework supports global CPU latency QoS and per-device CPU latency QoS requests. An example of using global CPU latency QoS is a commit 2777e73fc154 ("scsi: ufs: core: Add CPU latency QoS support for UFS driver") that improved random io performance by 15% for ufs on specific device platform. However, this prevents all CPUs in the system from entering C states. Typically, some threads or drivers know which specific CPUs they are interested in. For example, drivers with IRQ affinity only want interrupts to wake up and be handled on specific CPUs. Similarly, kernel thread bound to specific CPUs through affinity only care about the latency of those particular CPUs. This patch introduces support for partial CPUs PM QoS using a CPU affinity mask, allowing flexible and more precise latency QoS settings for specific CPUs. This can help save power, especially on heterogeneous platforms with big and little cores, as well as some power-conscious embedded systems for example: driver A rt kthread B module C CPU IDs (mask): 0-3 2-5 6-7 target latency(us): 20 30 100 | | | v v v +---------------------------------+ | PM QoS Framework | +---------------------------------+ | | | v v v CPU IDs (mask): 0-3 2-3,4-5 6-7 runtime latency(us): 20 20, 30 100 Implement this support based on per-device CPU latency PM QoS. Signed-off-by: Zhongqiu Han --- include/linux/pm_qos.h | 40 +++++++++++ kernel/power/qos.c | 160 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 4a69d4af3ff8..2dbad825f8bd 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -131,6 +131,15 @@ enum pm_qos_req_action { PM_QOS_REMOVE_REQ /* Remove an existing request */ }; =20 +/* cpu affinity pm latency qos request handle */ +struct cpu_affinity_qos_req { + struct list_head list; + union { + struct dev_pm_qos_request req; + void *req_ptr; + }; +}; + static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req) { return req->dev !=3D NULL; @@ -208,6 +217,13 @@ static inline s32 dev_pm_qos_raw_resume_latency(struct= device *dev) PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : pm_qos_read_value(&dev->power.qos->resume_latency); } + +int cpu_affinity_latency_qos_add(struct cpu_affinity_qos_req *pm_req, + const cpumask_t *affinity_mask, s32 latency_value); +int cpu_affinity_latency_qos_remove(struct cpu_affinity_qos_req *pm_req); +int cpu_affinity_latency_qos_release(struct cpu_affinity_qos_req *pm_req); +bool cpu_affinity_latency_qos_active(struct cpu_affinity_qos_req *pm_req); +void wakeup_qos_affinity_idle_cpu(int cpu); #else static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *d= ev, s32 mask) @@ -289,6 +305,30 @@ static inline s32 dev_pm_qos_raw_resume_latency(struct= device *dev) { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } + +static inline int cpu_affinity_latency_qos_add(struct cpu_affinity_qos_req= *pm_req, + const cpumask_t *affinity_mask, + s32 latency_value) +{ + return 0; +} + +static inline int cpu_affinity_latency_qos_remove( + struct cpu_affinity_qos_req *pm_req) +{ + return 0; +} +static inline int cpu_affinity_latency_qos_release( + struct cpu_affinity_qos_req *pm_req) +{ + return 0; +} +static inline bool cpu_affinity_latency_qos_active( + struct cpu_affinity_qos_req *pm_req) +{ + return false; +} +static inline void wakeup_qos_affinity_idle_cpu(int cpu) {} #endif =20 static inline int freq_qos_request_active(struct freq_qos_request *req) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 4244b069442e..5e507ed8d077 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -335,6 +335,166 @@ void cpu_latency_qos_remove_request(struct pm_qos_req= uest *req) } EXPORT_SYMBOL_GPL(cpu_latency_qos_remove_request); =20 +#ifdef CONFIG_PM + +/** + * wakeup_qos_affinity_idle_cpu - break one specific cpu out of idle. + * @cpu: the CPU to be woken up from idle. + */ +void wakeup_qos_affinity_idle_cpu(int cpu) +{ + preempt_disable(); + if (cpu !=3D smp_processor_id() && cpu_online(cpu)) + wake_up_if_idle(cpu); + preempt_enable(); +} + +/** + * cpu_affinity_latency_qos_add - Add new CPU affinity latency QoS request. + * @pm_req: Pointer to a preallocated handle. + * @affinity_mask: Mask to determine which CPUs need latency QoS. + * @latency_value: New requested constraint value. + * + * Use @latency_value to initialize the request handle pointed to by @pm_r= eq, + * insert it as a new entry to the CPU latency QoS list and recompute the + * effective QoS constraint for that list, @affinity_mask determine which = CPUs + * need the latency QoS. + * + * Callers need to save the handle for later use in updates and removal of= the + * QoS request represented by it. + * + * Returns 0 or a positive value on success, or a negative error code on f= ailure. + */ +int cpu_affinity_latency_qos_add(struct cpu_affinity_qos_req *pm_req, + const cpumask_t *affinity_mask, + s32 latency_value) +{ + int cpu; + cpumask_t actual_mask; + struct cpu_affinity_qos_req *cpu_pm_req; + int ret =3D 0; + + if (!pm_req) { + pr_err("%s: invalid PM Qos request\n", __func__); + return -EINVAL; + } + + if (cpu_affinity_latency_qos_active(pm_req)) { + WARN(1, "%s called for already added request\n", __func__); + return -EBUSY; + } + + INIT_LIST_HEAD(&pm_req->list); + + if (!affinity_mask || cpumask_empty(affinity_mask) || + latency_value < 0) { + pr_err("%s: invalid PM Qos request value\n", __func__); + return -EINVAL; + } + + for_each_cpu(cpu, affinity_mask) { + cpu_pm_req =3D kzalloc(sizeof(struct cpu_affinity_qos_req), + GFP_KERNEL); + if (!cpu_pm_req) { + ret =3D -ENOMEM; + goto out_err; + } + ret =3D dev_pm_qos_add_request(get_cpu_device(cpu), + &cpu_pm_req->req, + DEV_PM_QOS_RESUME_LATENCY, + latency_value); + if (ret < 0) { + pr_err("failed to add latency req for cpu%d", cpu); + kfree(cpu_pm_req); + goto out_err; + } else if (ret > 0) { + wakeup_qos_affinity_idle_cpu(cpu); + } + + cpumask_set_cpu(cpu, &actual_mask); + list_add(&cpu_pm_req->list, &pm_req->list); + } + + pr_info("PM Qos latency: %d added on cpus %*pb\n", latency_value, + cpumask_pr_args(&actual_mask)); + pm_req->req_ptr =3D pm_req; + return ret; + +out_err: + cpu_affinity_latency_qos_release(pm_req); + pr_err("failed to add PM QoS latency req, removed all added requests\n"); + return ret; +} +EXPORT_SYMBOL_GPL(cpu_affinity_latency_qos_add); + + +/** + * cpu_affinity_latency_qos_remove - Remove an existing CPU affinity laten= cy QoS. + * @pm_req: Handle to the QoS request to be removed. + * + * Remove the CPU latency QoS request represented by @pm_req from the CPU = latency + * QoS list. This handle must have been previously initialized and added v= ia + * cpu_affinity_latency_qos_add(). + */ +int cpu_affinity_latency_qos_remove(struct cpu_affinity_qos_req *pm_req) +{ + if (!pm_req) { + pr_err("%s: invalid PM Qos request value\n", __func__); + return -EINVAL; + } + + if (!cpu_affinity_latency_qos_active(pm_req)) { + WARN(1, "%s called for unknown object\n", __func__); + return -EINVAL; + } + + return cpu_affinity_latency_qos_release(pm_req); +} +EXPORT_SYMBOL_GPL(cpu_affinity_latency_qos_remove); + +/** + * cpu_affinity_latency_qos_release - Release pm_reqs latency QoS resource. + * @pm_req: QoS request to be released. + * + * Release pm_reqs managed CPU affinity latency QoS resource. + * + * Returns a negative value indicates failure. + */ +int cpu_affinity_latency_qos_release(struct cpu_affinity_qos_req *pm_req) +{ + int ret =3D 0; + struct cpu_affinity_qos_req *cpu_pm_req, *next; + + list_for_each_entry_safe(cpu_pm_req, next, &pm_req->list, list) { + ret =3D dev_pm_qos_remove_request(&cpu_pm_req->req); + if (ret < 0) + pr_err("failed to remove qos request for %s\n", + dev_name(cpu_pm_req->req.dev)); + list_del(&cpu_pm_req->list); + kfree(cpu_pm_req); + cpu_pm_req =3D NULL; + } + + memset(pm_req, 0, sizeof(*pm_req)); + return ret; +} + +/** + * cpu_affinity_latency_qos_active - Check if a CPU affinity latency QoS + * request is active. + * @pm_req: Handle to the QoS request. + * + * Return: 'true' if @pm_req has been added to the CPU latency QoS list, + * 'false' otherwise. + */ +bool cpu_affinity_latency_qos_active(struct cpu_affinity_qos_req *pm_req) +{ + return pm_req->req_ptr =3D=3D pm_req; +} +EXPORT_SYMBOL_GPL(cpu_affinity_latency_qos_active); + +#endif /* CONFIG_PM */ + /* User space interface to the CPU latency QoS via misc device. */ =20 static int cpu_latency_qos_open(struct inode *inode, struct file *filp) --=20 2.43.0 From nobody Mon Oct 6 13:39:29 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 D05B32D46A6; Mon, 21 Jul 2025 12:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101711; cv=none; b=cOjUaUYyXd6r97bb6c8WmBACaROH8sXYugDWH5uFNO7vVrbnBD7q+r0WA7ZAJDCklGX4EQU+jzc6nRAKHY5cZCl0murC2ooxCeTO+vgnsX9LkA4nFoSYdAAutrClL1bPqugrabCvUp09ezXU6Q3NCNPfjcLKzYsK7lhXlAFEE1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101711; c=relaxed/simple; bh=/O0oL8M5iv3njslxJtm0ds9/xnPMTHj3/8kLM17CYT8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ihf6hST/VYhFBmUMNG0KcvkFZSVMV7UpTZsaHQXT8WTR3yBffLEGYs909GgURId7IhqQnI0ltLwR2JYPcFM8yq+GTZZehfTwUaM5OOdQ9nUufGTgv0RLkhJzzC8Y+29szPmK2+PCC6Zscgn9FPqei/+wfS8AYJYQp0kCYDluRjc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ZUmHj5CK; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ZUmHj5CK" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56LAMn2D015997; Mon, 21 Jul 2025 12:41:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= I7R+WwqsFV5K3j9XqjXcaemw9xPBfHZ8TMOu7cwD9C8=; b=ZUmHj5CKdeyQ6KCC /URcCe0tUCPDrpnFnKAsXfyM5E2kNFHDN21vF4o+D6pWYMd/qnWGFIVvBB7Y/v2P ar3o9IPoJ+JZVbJJqJVHmU/ux3TcCsxM0BsNO0nR7QV9yex71Ih72zqLAjywOpv7 v6SX3S8/ckbA+jvE4zICZ67aTWo+Ha7cfWhsMEGmLIcZ5tIZb2gcQR+Z+2czNW3i ZppgwTHMfUEgBFqlcu5TX/JeoDVpxAfede1+TAWfFP6VyxDlLJi6IeIY7sbjd14Q Y0ga+w6M5jmvk87qQ3PfxQX3MWrJzvFxkihVzLkfb8T8F2PQHCyWattvrlIondde eVrPbg== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 480451d11w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:43 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 56LCfg2X013973 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:42 GMT Received: from zhonhan-gv.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 21 Jul 2025 05:41:38 -0700 From: Zhongqiu Han To: , , , , , , , , , CC: , , Subject: [PATCH v2 2/5] PM: QOS: Remove unnecessary KERN_ERR on WARN() calls Date: Mon, 21 Jul 2025 20:41:01 +0800 Message-ID: <20250721124104.806120-3-quic_zhonhan@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721124104.806120-1-quic_zhonhan@quicinc.com> References: <20250721124104.806120-1-quic_zhonhan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=EIMG00ZC c=1 sm=1 tr=0 ts=687e3587 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=k7MmHeaFQfK7UbCyMzYA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: A2Sfi7SJmZpCH5Byr5an09FqytF1BlCg X-Proofpoint-GUID: A2Sfi7SJmZpCH5Byr5an09FqytF1BlCg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIxMDExMiBTYWx0ZWRfX80h3PNe/XjJc 5lcP3CqLYbWk/zOytKDwUYNDjA+mdnBP0XOLxl1P2LMtEgJIWPrsS7wimVnEdOPTVEkp4HKEC1W UtvsyfD7+/I6MVuFiIrwjQUiPAgj/bJfytOSN3PEyZPssujDFGEmqZuv698I5SeWsfq7OLjNPZ8 V2yTEZOHMiCF3wLnG4h0aICOFk+8iytDGnQSJr0Wzb36o97QW1VlqTQdRo3QmDed1OR/DijH9hl SBG0RK3QfUcKrVsFGEF/+1zzAt1UZKyjmLdr10L4eD+EE5i9UZ766fxEppN8H3CGJnHe7KBcDyk WnPvgaUnxEpBTFituNakNdAvYQF0CbPo5VGK4yJAx1z+XpYtFq9BfLK3FA2poZEvu7AXoJ5oTvF R+W7LHJmeEV3X2E0plr1DswylI8oB8ymBhJIOMn7XvlA8ni5Y+fpINJ05IRxGsxQ6J5936Oi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-21_03,2025-07-21_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 mlxscore=0 clxscore=1015 suspectscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507210112 Content-Type: text/plain; charset="utf-8" Remove unnecessary KERN_ERR in WARN() calls and the latest version of scripts/checkpatch.pl also warns about such a pattern. Signed-off-by: Zhongqiu Han --- kernel/power/qos.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 5e507ed8d077..5c157004b78f 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -272,7 +272,7 @@ void cpu_latency_qos_add_request(struct pm_qos_request = *req, s32 value) return; =20 if (cpu_latency_qos_request_active(req)) { - WARN(1, KERN_ERR "%s called for already added request\n", __func__); + WARN(1, "%s called for already added request\n", __func__); return; } =20 @@ -298,7 +298,7 @@ void cpu_latency_qos_update_request(struct pm_qos_reque= st *req, s32 new_value) return; =20 if (!cpu_latency_qos_request_active(req)) { - WARN(1, KERN_ERR "%s called for unknown object\n", __func__); + WARN(1, "%s called for unknown object\n", __func__); return; } =20 @@ -324,7 +324,7 @@ void cpu_latency_qos_remove_request(struct pm_qos_reque= st *req) return; =20 if (!cpu_latency_qos_request_active(req)) { - WARN(1, KERN_ERR "%s called for unknown object\n", __func__); + WARN(1, "%s called for unknown object\n", __func__); return; } =20 --=20 2.43.0 From nobody Mon Oct 6 13:39:29 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 042502D59EF; Mon, 21 Jul 2025 12:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101715; cv=none; b=I9E0JRHdnjt+D0lDlvAy5vObHmcdw+5IcDm5xrk5QQrdPOuplrM4O/qbnyxA1xqHYhKbVdaieyCsFyHWhM3bQdnYY5SItywoiJhIObneHCjmiJrKU+aAatRX81BZQj74Ho4lF3mmcN31i6JXh/YWBpKOAjhDg9e2MbAH07LAgCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101715; c=relaxed/simple; bh=lAZPNUeeuhhsP5b0+OmxKzK/GjGMxwF1LiTfBK38Ofw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SuqA+YedFMsCrI49Y8ho6X53w5w9mh2ofFnrNm8taUkwpDYq5xXMnP6Fif+NOEKy6TtRurWsSW/G0oaoQceptm82se4+Sg4LkSLNKyiatZfPl3AX6qw0jq8bshjb+mJewfI0t75+Iq9lt3NMnq/GlIAgD6zWgzSek5IM62X/6tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=VfByTHY/; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="VfByTHY/" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56LAWE8j015737; Mon, 21 Jul 2025 12:41:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= lZfSS9a2l7X18pJgkXw1vbBprrrii+uTqrpX09plhr0=; b=VfByTHY/HMShgMIr x4fp5cVi8QyTJpmGUXLHLQR6TlPVmJd7BULDqyADxqodL7d2zoyYQ5YGpGv4PSGk FACszzqc/jjdigT/jlGXD6qQ1P2Igb1tHpmUIlI6vM7CnhuUqP295hDlgPwmbtbV sBNKJBVrD92Kzys+nW9eVWZzLwTyW9htsHqCB9U+PHScn6ZQWk16TFszX33o5Nu6 iqThCK2LI7B9W9XQvhYcYZ6viyNuGAMfUzkI52DUK4mo0+EJmE4Tn6BEbBZJo/zt GlX815w3cfNtsKyVaPV+Csm9ubviEuxM0Ndtl8K7hWOjc1D+BRdZ11PI+6+EZISk H6NCWg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 480451d123-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:46 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 56LCfjwX002213 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:45 GMT Received: from zhonhan-gv.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 21 Jul 2025 05:41:42 -0700 From: Zhongqiu Han To: , , , , , , , , , CC: , , Subject: [PATCH v2 3/5] Documentation: PM: QoS: Add CPU affinity latency PM QoS Interface documentation Date: Mon, 21 Jul 2025 20:41:02 +0800 Message-ID: <20250721124104.806120-4-quic_zhonhan@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721124104.806120-1-quic_zhonhan@quicinc.com> References: <20250721124104.806120-1-quic_zhonhan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=EIMG00ZC c=1 sm=1 tr=0 ts=687e358a cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=jR7MCmn6jQT2zHobaZIA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: ub5fD4xF7k6-1WrxgLLlbm3LQFoYOlfI X-Proofpoint-GUID: ub5fD4xF7k6-1WrxgLLlbm3LQFoYOlfI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIxMDExMiBTYWx0ZWRfX/KEBGx9hzkxS cJj0+092j01tiXYytWSzVn5AW3AS8WnsNXVLa7bCGju9rrzob7689pdYkAYRu8WrZjliBEqjRBD vJK5qtBLdeSxRwii9UH/va+glsEFGejFBXFMxYU0PEVDcQpZYclqA7U0Qs8uLQYCLlKoV72JOcy 1WyoYwl3L+hQmHY72HZ+XiMlWQM6RJ6Fth0L9bCUcDkNw0GjGkzNNb5o24VSyUUd5uupJWNiTOJ Edxbs//b7yB4fCqpTUOKZve2KA73iCHhV7zhPT5lew8ZN92PPPxy38UBXt/pVPnX2dxP8kFcv4k fDFEDlHTwXZKe6gO9KeW8qtKuYu3byq0mneyEOc6JA2y8Q5oR3cWnvuUxSuZ6PCUZ6jyraWSPPm 2cYhRisLoDGgjYM8c6mue9otf8Kp0m56Q9bRfbs15Np67T2z5YwxMtXh9xFZxFSakvoRa667 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-21_03,2025-07-21_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 mlxscore=0 clxscore=1015 suspectscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507210112 Content-Type: text/plain; charset="utf-8" Adds documentation for the CPU affinity latency PM QoS interface, enabling latency constraints to be applied to specific CPUs according to a defined CPU mask. Signed-off-by: Zhongqiu Han --- Documentation/power/pm_qos_interface.rst | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Documentation/power/pm_qos_interface.rst b/Documentation/power= /pm_qos_interface.rst index 5019c79c7710..1ede4cafc2e3 100644 --- a/Documentation/power/pm_qos_interface.rst +++ b/Documentation/power/pm_qos_interface.rst @@ -17,6 +17,13 @@ The latency unit used in the PM QoS framework is the mic= rosecond (usec). 1. PM QoS framework =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 +For CPU latency QoS, there are two types of interfaces: one is the global = CPU +latency QoS interface, and the other is the CPU affinity latency QoS, wher= e the +CPU is determined by the CPU affinity mask, which can apply to part or all= of +the CPUs. + +1) Global CPU latency QoS interface: + A global list of CPU latency QoS requests is maintained along with an aggr= egated (effective) target value. The aggregated target value is updated with cha= nges to the request list or elements of the list. For CPU latency QoS, the @@ -76,6 +83,56 @@ cpu_latency_qos_update_request() call. To remove the user mode request for a target value simply close the device node. =20 +2) CPU affinity latency QoS interface: + +The Global CPU latency QoS interface can easily limit the latency for all = CPUs. +If we want to limit the CPU latency for partial CPUs specified by a CPU +affinity mask, we can use the CPU affinity latency QoS interface. Currentl= y, +this is only supported for kernel users. This will only prevent the CPUs +specified by the mask from entering C states. Typically, some threads or +drivers know which specific CPUs they are interested in. For example, driv= ers +with IRQ affinity only want interrupts to wake up and be handled on specif= ic +CPUs. Similarly, kernel thread bound to specific CPUs through affinity only +care about the latency of those particular CPUs. + +It allows flexible and precise latency QoS settings for specific CPUs. Thi= s can +help save power, especially on heterogeneous platforms with big and little= cores, +as well as power-conscious embedded systems. For example: + + driver A rt kthread B module C + CPU IDs (mask): 0-3 2-5 6-7 + target latency(us): 20 30 100 + | | | + v v v + +---------------------------------+ + | PM QoS Framework | + +---------------------------------+ + | | | + v v v + CPU IDs (mask): 0-3 2-3,4-5 6-7 + runtime latency(us): 20 20,30 100 + +The usage of kernel space is: + +int cpu_affinity_latency_qos_add(handle, affinity_mask, latency_value); + Will insert an element into the CPUs specified by the affinity_mask late= ncy + QoS list with the target value. Upon change to this list the new target = is + recomputed. Clients of PM QoS need to save the returned handle for futur= e use + in other PM QoS API functions. + +int cpu_affinity_latency_qos_remove(handle); + Will remove the element. After removal it will update the aggregate targ= et + and call the notification tree if the target was changed as a result of + removing the request. + +bool cpu_affinity_latency_qos_active(handle); + Returns true if the request is still active, i.e. it has not been remove= d from + the CPU latency QoS list. + +Note: +a) The CPU affinity latency QoS interface uses a mutex, which might sleep. +b) Use dev_pm_qos_raw_resume_latency(device) to read the CPU latency set b= y the + above interface, by passing the CPU device. =20 2. PM QoS per-device latency and flags framework =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.43.0 From nobody Mon Oct 6 13:39:29 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 C59982D5A04; Mon, 21 Jul 2025 12:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101719; cv=none; b=Lc5pz6RjLkI/hIzqmqrI741byjQFaM9ky7nK6dnUJBIXjG+xwZhmeyqTOD4n7k2z72dg+6geAayHi/FsoY8uGuNl0/EHVHeVFrM+T7s03cmH3oB169I77XVVqRC+uyLYsUo/3vmds1sF7EIux+RiPVYduLTDPLGrLbzCvvH8mGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101719; c=relaxed/simple; bh=w6KY0bttrOjHkYZY0aEkpiy2ZPnPtR9Qkt4ba5opjrk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KUwwFc3QyC5IVzgL+IF9qU1/BRGlJjfga6DhTAYsbdgOfibcrTErHHk9uKqEr73M8JT8fj/7wCHTqSz0nygfymMHWOpBl7tjA1pPiHGVwgSdIXl7NIYE1u5TdIzzYc6rJSH4O0bjpgArsL9wI3IO3KFh+o3lRTrXyYIY3qpNqHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=hng8XynC; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="hng8XynC" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56LAFx8e027797; Mon, 21 Jul 2025 12:41:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= LBjBWJVPt/vr1haA2zED4BkOuELCVeXVsGzVfTOwRBo=; b=hng8XynCV6yADuRW E8C1Vq5r1J6WYrKhFj+7Y6BBvQlQ4WT/M+85cxSNYiQtEUS5yD0Wm9SPYJEbL4yw t24OHkv76qBKvwzbke0yRazCNCSvmuD7C8dzZKC9RdTzROalXpdcUzugTSs1M/wX dRM40elbky/YWczhdTD1OzXv9cpwAlqM39mEU62Gv15Kw32FZWjAFnkfq5ACUY8p EikUgQw+s3KxOo0c3PGRWKqkYNUPms5YK769HYWKgICxBh21hqLeDhnVdfETqYvI bdEcVoYHbSB0NUdPd/cTWtyf7fMt1xOSRALPExPPSvwUe6mrSDjFYRUSOKj6I7lU 61Xc1g== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 48045hd0j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:49 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 56LCfmeH002263 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:48 GMT Received: from zhonhan-gv.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 21 Jul 2025 05:41:45 -0700 From: Zhongqiu Han To: , , , , , , , , , CC: , , Subject: [PATCH v2 4/5] Documentation: PM: QoS: Fix return type and return value description Date: Mon, 21 Jul 2025 20:41:03 +0800 Message-ID: <20250721124104.806120-5-quic_zhonhan@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721124104.806120-1-quic_zhonhan@quicinc.com> References: <20250721124104.806120-1-quic_zhonhan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ZtDtK87G c=1 sm=1 tr=0 ts=687e358d cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=2Mn5PldW32zOEzkLXbQA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIxMDExMiBTYWx0ZWRfX74HhvHfgQUwu fvzhC1dMgi5Tjv6TptZlvqxf01Xhhoh6xgLB/wrq0vfN6MF3j4QT8XYWl3777D9md2Z0cqrHCM9 ZbgF/6BHbc+qYuy14YbLrvxdw37PGSy+q9+/DabPxlWJweiG8oZFSsi4duX3GZsEjO6qiSwbbxi 399REZgpeER552ecmR0Z+FVcg5aF2ujCOu8eS2G6+Fi5bs+BcY0jf1vBheqXhQt+Y3w9pkAd12Q YDl/mis+k/cYDrRKkEFR410gKk1IxeGuhd/AEVO+TG9sT7287glSOgNJk1G8auG8z6/Xa2kjaIZ yUbw/9BwrjOi/B9XFjFtYSnR8AXwnB9peSYBQe8PaQiwaCqWxtq5wxfmmGQy66TnVovUgu3LFnf Ub8AI05h1tURU9Bv650CHhCXUD8654Z8wfVhormLN6GSXCLL6nyxcgdGjIMcOHlzFzh9t/bh X-Proofpoint-GUID: 8XvAua4r59u_aJHHNE5Lmg5G_x9lVbYZ X-Proofpoint-ORIG-GUID: 8XvAua4r59u_aJHHNE5Lmg5G_x9lVbYZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-21_03,2025-07-21_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 clxscore=1015 spamscore=0 phishscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxlogscore=994 suspectscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507210112 Content-Type: text/plain; charset="utf-8" The documentation for cpu_latency_qos_request_active() incorrectly stated the return type as 'int' instead of 'bool', and the return value description was incomplete. This patch corrects the return type and clarifies the return value semantics. Fixes: b8e6e27c626e ("Documentation: PM: QoS: Update to reflect previous co= de changes") Signed-off-by: Zhongqiu Han Reviewed-by: Christian Loehle --- Documentation/power/pm_qos_interface.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/power/pm_qos_interface.rst b/Documentation/power= /pm_qos_interface.rst index 1ede4cafc2e3..c6b8b9cda166 100644 --- a/Documentation/power/pm_qos_interface.rst +++ b/Documentation/power/pm_qos_interface.rst @@ -55,9 +55,9 @@ void cpu_latency_qos_remove_request(handle): int cpu_latency_qos_limit(): Returns the aggregated value for the CPU latency QoS. =20 -int cpu_latency_qos_request_active(handle): - Returns if the request is still active, i.e. it has not been removed fro= m the - CPU latency QoS list. +bool cpu_latency_qos_request_active(handle): + Returns true if the request is still active, i.e. it has not been remove= d from + the CPU latency QoS list. =20 =20 From user space: --=20 2.43.0 From nobody Mon Oct 6 13:39:29 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 A06762D5A19; Mon, 21 Jul 2025 12:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101722; cv=none; b=Dl20CS2SnVdCHIjE1KXsYjjZ0d8qco2PmfjBP4L5unbzlIZCWpgUXBEDm065JN8PjPSJMypohR6K3nRon7N7NQ+Hhtx6v2THXhWk6nYkROxbum9gT35rycISIWH8QGedS64SjqP5AXGWIt6nsQvNiiG2BCtIRvJCDmTT2IvZoFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753101722; c=relaxed/simple; bh=oXq2pB+fx59/NhTUlH8KT9gRtGuAabW6XMQl5gp5MFI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uG+tttEO/jSXH0mv1PtJtzIrJTAnUjsnmCOFIh9/W6CY9uv8p3RtDRlc7Q8Frk3a/5CBKGIW8MeRmDpajkhfmvqkZyUkqs2271mpsR501vX4t06xKyjmc/FNo8fwdBf/Z0+uDOt9PWQCeGVcQHRNXUmsbaIL2nOLIRhvrccFlzk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ht5jarW3; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ht5jarW3" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56LAI8po000902; Mon, 21 Jul 2025 12:41:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 1Ql3MhLlWSmZVDLj1v+Nf2U93SFaRmXviMo7cDR5L+s=; b=ht5jarW3cIxGWDMa 89wRJ9zjbM0FsNaDB20A662rJp/FZ+4VGM83o1Lb0KX47C9TkE1W6suMV9y4n7aC KnADOJTzP9lCdyTThZsetL0muFew9mCnrvwRhgAvwUzl+yiccGndHT2zRmcfmwab ZImmy9eZfGqkrjENRT2HqllufZdr9x+YeLSpSbgyL9uDPfbRyKsWhyIGJhD4L4UK Q3LuoqJzqIpE3mWPbbK8MF9ICZPX4EBLbg6+I4o8lRt7dgSSo0fVY6FTVPay+7G4 JN4lSpxF+Y2Utj2P7MuaJvi9ECo+IG8tvGpfLEQGZptqrjLTLl2KJwizmm4Q98CH IbG3cg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 48044dd1um-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:52 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 56LCfp6V002289 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Jul 2025 12:41:51 GMT Received: from zhonhan-gv.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 21 Jul 2025 05:41:48 -0700 From: Zhongqiu Han To: , , , , , , , , , CC: , , Subject: [PATCH v2 5/5] resctrl: Replace PM QoS logic with cpu_affinity_latency_qos_* helpers Date: Mon, 21 Jul 2025 20:41:04 +0800 Message-ID: <20250721124104.806120-6-quic_zhonhan@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721124104.806120-1-quic_zhonhan@quicinc.com> References: <20250721124104.806120-1-quic_zhonhan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=BJ6zrEQG c=1 sm=1 tr=0 ts=687e3590 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=tAw3UdR0-tMnE-oq3cEA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-GUID: L-E2Bej92DRaPOnHhqroaeaIYjBZ675a X-Proofpoint-ORIG-GUID: L-E2Bej92DRaPOnHhqroaeaIYjBZ675a X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIxMDExMiBTYWx0ZWRfX2hX+tsfOR8+L CrsHM67GJZ+LpPI1djbqRT2aC6RiN3yJbF/z5/CSB9PsMOD7cwFtkgadwRmhUxYYKgeIMj3vUbY OhcgGo+r24B738cmVPKCa6I9v8WCqYOVdwZFdsPXV/iwxgz8wBGX/P7njCzq2z8Pem5A2TH843M 7WaIbUEtjIElXdurWGznhvgzqBBCMqdx0j5HKUCiqYt+SKFSj3IckWugB/zyB0YuxrrEZ+7JCtE UmQEhL7K/94d0CWM+srWsbwtxKAT14zoy2+dYV/NuqfOlvNztzcF3gqGyS8gHBmjC66PIxeS2M7 msTzm4vIzxoTZmWdjxW+7hxDWNHMjgM9UM7T26hvYo90o9h0mqenrepcEWO/U82pyGwoGK/gG4E Fid9JDgRN5gLMO+OlqeSOG8aGXkMexXCVOicSxMi+AhUlP+vnqWXNte7GtpN8m0ByK9X/cyJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-21_03,2025-07-21_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 phishscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507210112 Content-Type: text/plain; charset="utf-8" Use cpu_affinity_latency_qos_* helpers to replace the dev_pm_qos_request handling for CPU masks in pseudo-locking. These helpers encapsulate latency QoS operations for a group of CPUs, providing a consistent mechanism for request addition, removal, and error handling. This improves code clarity and maintainability. As resctrlfs is used on different platforms, a unified interface also makes it easier to adapt to platform-specific CPU masks and latency QoS values. The only functional change, and a beneficial one, is that when the latency QoS value is updated for a CPU in the mask, the interface will actively wake up that CPU to ensure the QoS setting takes effect immediately. This helps enforce latency constraints in a timely manner on performance-critical paths. Signed-off-by: Zhongqiu Han --- fs/resctrl/pseudo_lock.c | 51 +++------------------------------------- include/linux/resctrl.h | 3 ++- 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c index 87bbc2605de1..8be3ae804af9 100644 --- a/fs/resctrl/pseudo_lock.c +++ b/fs/resctrl/pseudo_lock.c @@ -108,25 +108,9 @@ static struct rdtgroup *region_find_by_minor(unsigned = int minor) return rdtgrp_match; } =20 -/** - * struct pseudo_lock_pm_req - A power management QoS request list entry - * @list: Entry within the @pm_reqs list for a pseudo-locked region - * @req: PM QoS request - */ -struct pseudo_lock_pm_req { - struct list_head list; - struct dev_pm_qos_request req; -}; - static void pseudo_lock_cstates_relax(struct pseudo_lock_region *plr) { - struct pseudo_lock_pm_req *pm_req, *next; - - list_for_each_entry_safe(pm_req, next, &plr->pm_reqs, list) { - dev_pm_qos_remove_request(&pm_req->req); - list_del(&pm_req->list); - kfree(pm_req); - } + cpu_affinity_latency_qos_remove(&plr->pm_reqs); } =20 /** @@ -149,36 +133,8 @@ static void pseudo_lock_cstates_relax(struct pseudo_lo= ck_region *plr) */ static int pseudo_lock_cstates_constrain(struct pseudo_lock_region *plr) { - struct pseudo_lock_pm_req *pm_req; - int cpu; - int ret; - - for_each_cpu(cpu, &plr->d->hdr.cpu_mask) { - pm_req =3D kzalloc(sizeof(*pm_req), GFP_KERNEL); - if (!pm_req) { - rdt_last_cmd_puts("Failure to allocate memory for PM QoS\n"); - ret =3D -ENOMEM; - goto out_err; - } - ret =3D dev_pm_qos_add_request(get_cpu_device(cpu), - &pm_req->req, - DEV_PM_QOS_RESUME_LATENCY, - 30); - if (ret < 0) { - rdt_last_cmd_printf("Failed to add latency req CPU%d\n", - cpu); - kfree(pm_req); - ret =3D -1; - goto out_err; - } - list_add(&pm_req->list, &plr->pm_reqs); - } - - return 0; - -out_err: - pseudo_lock_cstates_relax(plr); - return ret; + return cpu_affinity_latency_qos_add(&plr->pm_reqs, &plr->d->hdr.cpu_mask, + 30); } =20 /** @@ -275,7 +231,6 @@ static int pseudo_lock_init(struct rdtgroup *rdtgrp) return -ENOMEM; =20 init_waitqueue_head(&plr->lock_thread_wq); - INIT_LIST_HEAD(&plr->pm_reqs); rdtgrp->plr =3D plr; return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 6fb4894b8cfd..521fe70b0425 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -6,6 +6,7 @@ #include #include #include +#include #include =20 #ifdef CONFIG_ARCH_HAS_CPU_RESCTRL @@ -108,7 +109,7 @@ struct pseudo_lock_region { void *kmem; unsigned int minor; struct dentry *debugfs_dir; - struct list_head pm_reqs; + struct cpu_affinity_qos_req pm_reqs; }; =20 /** --=20 2.43.0