From patchwork Mon Apr 29 23:41:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 13647860 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 1F283194C7D; Mon, 29 Apr 2024 23:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433713; cv=none; b=p53/ll7TPFM6PLFukebTTr+i/ugdez0nEDGiGBBHRqv43AtdJB90LiAysobzUQJ0mKWxZy2j366PqQuY92y9OKW+5lb5CtqOTmB/tDH9dS3HY2jXLJS+SQTIumucQYgDMOsWGgL2CdiNmLl+33xlYzMPKOyH74ZYv0jYzjw0i2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433713; c=relaxed/simple; bh=TFPGY+ddCwHX9312u/U1NxmZ4OYD0jX/msGOy3fTFSg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=POf/5nFv7hmmJDOZEPBWCrFIdF4D/XPMJKmHe9nAFPeeqvLi1QRmAXkjueEfVZtBinAFaeQ3O65BEO3PXkd+PAJH5JATpdCYHW4+5Mg/B5XoLeG02RND9jNGgqHI6rKuw/3cO+EW2nkaDTcQwklfnKCIH5FulNWcUVdQpLX9A3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eoRklByC; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eoRklByC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714433712; x=1745969712; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=TFPGY+ddCwHX9312u/U1NxmZ4OYD0jX/msGOy3fTFSg=; b=eoRklByCbkvEiQtVJZ+oM69QGLxAuGue8yX6c9/gr1zD/MVtCdjBy2ZQ Clt1p50ozBxw3YWtYKTVTzrUITp2bmpA9WJhLreBqd30rY1kQxL5ihCd3 xKrmM2+vzFYNfBkd5kwAuL8lVhY0fqjy83l0wr3HrwxSdmw23gK7Pq4fO aJjRxUcTCx2/5UaFk50MbIUHHny+luREJ0dy5o8H8YIhYRnhk87TAi7Tx 1ufIU5E/WkCcO0Atpr4/Q4Cv6OitYMqVrWer743VQCScdljOFWq1LCa36 M3GFEhn2ZeYvg8yIpqFR84T95CKJNeWati8VQ0gfzQXo3Qrz92Laa+gCn Q==; X-CSE-ConnectionGUID: 2rFRirq0RrGCDx+Kh74OkA== X-CSE-MsgGUID: RQRFEapTSTC2VybheHH/vQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="10274508" X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="10274508" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 16:35:09 -0700 X-CSE-ConnectionGUID: WTn4LFf8QsGgfhCNtU+5xg== X-CSE-MsgGUID: BhAfoo7wQNiKotgFHFswdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="26200133" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmviesa009.fm.intel.com with ESMTP; 29 Apr 2024 16:35:08 -0700 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Zhang Rui , Srinivas Pandruvada , Len Brown , Stanislaw Gruszka , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH 1/4] thermal: intel: hfi: Rename HFI_UPDATE_INTERVAL Date: Mon, 29 Apr 2024 16:41:49 -0700 Message-Id: <20240429234152.16230-2-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> References: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The name of the constant HFI_UPDATE_INTERVAL is misleading. It is not a periodic interval at which HFI updates are processed. It is the delay in the processing of an HFI update after the arrival of an HFI interrupt. Signed-off-by: Ricardo Neri Acked-by: Zhang Rui --- Cc: Len Brown Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/intel/intel_hfi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index fbc7f0cd83d7..e2b82d71ab6b 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -166,7 +166,7 @@ static struct hfi_features hfi_features; static DEFINE_MUTEX(hfi_instance_lock); static struct workqueue_struct *hfi_updates_wq; -#define HFI_UPDATE_INTERVAL HZ +#define HFI_UPDATE_DELAY HZ #define HFI_MAX_THERM_NOTIFY_COUNT 16 static void get_hfi_caps(struct hfi_instance *hfi_instance, @@ -322,7 +322,7 @@ void intel_hfi_process_event(__u64 pkg_therm_status_msr_val) raw_spin_unlock(&hfi_instance->event_lock); queue_delayed_work(hfi_updates_wq, &hfi_instance->update_work, - HFI_UPDATE_INTERVAL); + HFI_UPDATE_DELAY); } static void init_hfi_cpu_index(struct hfi_cpu_info *info) From patchwork Mon Apr 29 23:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 13647861 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 85A2F194C99; Mon, 29 Apr 2024 23:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433714; cv=none; b=We6EDEBBEyPEwzpDO29WqqpsaaVDH5MdYfi9dVdElQG3z9QuFnGJpEzKR+VU/1+xEp0zS2tKZRqU0xccOGcC3+1zJmRz1/eQrihxshZxHa1/RasGM8tfWYqUkh/TItQ1rTAUsUo5Iz1h4r7avmUmAWbk5ItSHK01o2zXZPQpGOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433714; c=relaxed/simple; bh=lzO2e+Oo+4UfllUX+wCgOchpiGEB/1rygV2TaWXK7hA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=BDsyeQlhUgYRQ8nR3+hMnStu6OJNFEbVRIQJq9+nhTKoAgJ7AM3ihbT/+pfsIYoLLEX1R5NFSa2sL1PJ5qe+Q8rXkTI7h3PVdpS+j5HB37oDh9Bg5HLvUGEElycc5ZfX8Mo9nNNF+sBKxjPjCZSZHDD++qGwqI08zU0h3rEINuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nIHRtSqt; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nIHRtSqt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714433713; x=1745969713; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lzO2e+Oo+4UfllUX+wCgOchpiGEB/1rygV2TaWXK7hA=; b=nIHRtSqt07gKf94rqPaz/U3c1FbwIoCJaS33t5Nfa36ZyEltubE7vew0 kKiEGuSBB1Kb9wpL7Nu8ifZbjaU1uo8W41mLLPFAE1kRlUjwkb7qd+3xA RwWo8JWLR9HKZfH5As572LnmPx9Gn0SzcQ/MgDUuswYEj8N+MN1toxlAI YZXHhKPZMDhX6lj9mJiB5mCGIz/o4z6tv42hz380cLCsthjRVb4nqEVMU 6seATVKfJnDitVkAJrDM2ozgMP60q52Xx5VlyYUFl9ihLx5H/SG7fG0wl YTOZ8sv4nbcNSR5tVgIEkFEt6MZbVAZpfyy3RmG03UNwVfa/t/X6rUhvp Q==; X-CSE-ConnectionGUID: QQHyUoFDRryiJCQeJLUUcQ== X-CSE-MsgGUID: vxa8zuiJT0e1WQPNrcrzfw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="10274509" X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="10274509" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 16:35:09 -0700 X-CSE-ConnectionGUID: WEkgMhMWQbGf7gLBE2hEGw== X-CSE-MsgGUID: x8CDHq49Qs2OawCtBg6sYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="26200136" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmviesa009.fm.intel.com with ESMTP; 29 Apr 2024 16:35:08 -0700 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Zhang Rui , Srinivas Pandruvada , Len Brown , Stanislaw Gruszka , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH 2/4] thermal: intel: hfi: Tune the HFI thermal netlink event delay via debugfs Date: Mon, 29 Apr 2024 16:41:50 -0700 Message-Id: <20240429234152.16230-3-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> References: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: THe delay between an HFI interrupt and its corresponding thermal netlink event has so far been hard-coded to CONFIG_HZ jiffies. This may not suit the needs of all hardware configurations or listeners of events. If the update delay is too long, much of the information of consecutive hardware updates will be lost as the HFI delayed workqueue posts a new thermal netlink event only when there are no previous pending events. If the delay is too short, multiple, events may overwhelm listeners. Listeners are better placed to determine the delay of events. They know how quickly they can act on them effectively. They may also want to experiment with different values. Start a debugfs interface to tune the notification delay. Keep things simple and do not add extra locking or memory barriers. This may result in the HFI interrupt ocassionally queueing work using stale delay values, if at all. This should not be a problem: the debugfs file will update the delay value atomically, we do not expect users to update the delay value frequently, and the delayed workqueue operates in jiffies resolution. Suggested-by: Srinivas Pandruvada Signed-off-by: Ricardo Neri --- Cc: Len Brown Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/intel/intel_hfi.c | 77 ++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index e2b82d71ab6b..24d708268c68 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -43,6 +43,10 @@ #include +#ifdef CONFIG_DEBUG_FS +#include +#endif + #include "intel_hfi.h" #include "thermal_interrupt.h" @@ -169,6 +173,70 @@ static struct workqueue_struct *hfi_updates_wq; #define HFI_UPDATE_DELAY HZ #define HFI_MAX_THERM_NOTIFY_COUNT 16 +/* Keep this variable 8-byte aligned to get atomic accesses. */ +static unsigned long hfi_update_delay = HFI_UPDATE_DELAY; + +#ifdef CONFIG_DEBUG_FS +static int hfi_update_delay_get(void *data, u64 *val) +{ + mutex_lock(&hfi_instance_lock); + *val = jiffies_to_msecs(hfi_update_delay); + mutex_unlock(&hfi_instance_lock); + return 0; +} + +static int hfi_update_delay_set(void *data, u64 val) +{ + /* + * The mutex only serializes access to the debugfs file. + * + * hfi_process_event() loads @hfi_update_delay from interrupt context. + * We could have serialized accesses with a spinlock or a memory barrier. + * But this is a debug feature, the store of @hfi_update_delay is + * atomic, and will seldom change. A few loads of @hfi_update_delay may + * see stale values but the updated value will be seen eventually. + */ + mutex_lock(&hfi_instance_lock); + hfi_update_delay = msecs_to_jiffies(val); + mutex_unlock(&hfi_instance_lock); + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(hfi_update_delay_fops, hfi_update_delay_get, + hfi_update_delay_set, "%llu\n"); + +static struct dentry *hfi_debugfs_dir; + +static void hfi_debugfs_unregister(void) +{ + debugfs_remove_recursive(hfi_debugfs_dir); + hfi_debugfs_dir = NULL; +} + +static void hfi_debugfs_register(void) +{ + struct dentry *f; + + hfi_debugfs_dir = debugfs_create_dir("intel_hfi", NULL); + if (!hfi_debugfs_dir) + return; + + f = debugfs_create_file("update_delay_ms", 0644, hfi_debugfs_dir, + NULL, &hfi_update_delay_fops); + if (!f) + goto err; + + return; +err: + hfi_debugfs_unregister(); +} + +#else +static void hfi_debugfs_register(void) +{ +} +#endif /* CONFIG_DEBUG_FS */ + static void get_hfi_caps(struct hfi_instance *hfi_instance, struct thermal_genl_cpu_caps *cpu_caps) { @@ -321,8 +389,13 @@ void intel_hfi_process_event(__u64 pkg_therm_status_msr_val) raw_spin_unlock(&hfi_instance->table_lock); raw_spin_unlock(&hfi_instance->event_lock); + /* + * debugfs may atomically store @hfi_update_delay without locking. The + * updated value may not be immediately observed. See note in + * hfi_update_delay_set(). + */ queue_delayed_work(hfi_updates_wq, &hfi_instance->update_work, - HFI_UPDATE_DELAY); + hfi_update_delay); } static void init_hfi_cpu_index(struct hfi_cpu_info *info) @@ -708,6 +781,8 @@ void __init intel_hfi_init(void) register_syscore_ops(&hfi_pm_ops); + hfi_debugfs_register(); + return; err_nl_notif: From patchwork Mon Apr 29 23:41:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 13647862 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 C835E199EB9; Mon, 29 Apr 2024 23:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433715; cv=none; b=o9+DHBBgRVkSXNDxjjHaRQNPQbQilg7Z3B4mTS4iHONFrPL8dBBfKnMYW/BLslo4YB550V+H8tFHKKbf3ICCu6/Mv9qc8gh2tWBjzdCYNx3g8o+s0qvQrsZG73zGkVdw7P286l5BzkalJzB2RN9t0JvTFMFXbcaQqh9QmuigTkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433715; c=relaxed/simple; bh=U0zOPBg06/Ek10lV/P5KRW59pMlND6/3ke+JnVTjiek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Hu7pgLBPMx+JnQosvgivoGDk6HqSKrlHzQn6mtFuXsRIP8nsB3LwOamxyTrwUJV9Wnkulf9ST3K4MXgwj5uXTXAl3jBxV+gOQDek+UB3913gd0Uu06/p0+zjvsHERZ8L0kX8JtZNnT97XFfZc6GQvqoxHpL6lZ8uY3IH8H5V4tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DsvmkLoU; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DsvmkLoU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714433714; x=1745969714; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=U0zOPBg06/Ek10lV/P5KRW59pMlND6/3ke+JnVTjiek=; b=DsvmkLoUWoAqDowigSrM7YBPO68e/xZTESeM6VKbYvKC3dQjk0H1Xe7/ wvjHC+b1HhjA8UdgU4YHN1DLX+87P42PDggmg2CCRgdZJmeL+y2VGPt2I pLZ7SqVVtvPO8EZfsD5bDdY57E20ZRUejEJYXZI/RqXZruhqO8XxcTcqz LKvhvEBHcgAWfFbH4hOddSonDnaUWMobvq30vLE4JtEP7ofczY7plSo5V 0eSSCP+SF3VyGdKNWtiInlLkq1pZc6Ms0a65tczA36LTSMNdbN5Maheiu 8VCpm6oroOULRtq6ElHiGUxqP9G/QXXVrY2k00g8SMGbA6vtolpXbn5Tc A==; X-CSE-ConnectionGUID: ZuArEuUlRUKHquD1ynocFg== X-CSE-MsgGUID: ON+c4UCGTleTO/I97FhJwA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="10274511" X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="10274511" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 16:35:09 -0700 X-CSE-ConnectionGUID: oNC+hNXiSnCIa+eGtRA/Zg== X-CSE-MsgGUID: E1i4qlq/QSiv4RamYiSiJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="26200139" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmviesa009.fm.intel.com with ESMTP; 29 Apr 2024 16:35:09 -0700 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Zhang Rui , Srinivas Pandruvada , Len Brown , Stanislaw Gruszka , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH 3/4] thermal: intel: hfi: Rename HFI_MAX_THERM_NOTIFY_COUNT Date: Mon, 29 Apr 2024 16:41:51 -0700 Message-Id: <20240429234152.16230-4-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> References: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: When processing a hardware update, HFI generates as many thermal netlink events as needed to relay all the updated CPU capabilities to user space. The constant HFI_MAX_THERM_NOTIFY_COUNT is the number of CPU capabilities updated per each of those events. Give this constant a more descriptive name. Signed-off-by: Ricardo Neri --- Cc: Len Brown Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/intel/intel_hfi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index 24d708268c68..d6d3544509fc 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -171,7 +171,7 @@ static DEFINE_MUTEX(hfi_instance_lock); static struct workqueue_struct *hfi_updates_wq; #define HFI_UPDATE_DELAY HZ -#define HFI_MAX_THERM_NOTIFY_COUNT 16 +#define HFI_THERMNL_CAPS_PER_EVENT 16 /* Keep this variable 8-byte aligned to get atomic accesses. */ static unsigned long hfi_update_delay = HFI_UPDATE_DELAY; @@ -286,14 +286,14 @@ static void update_capabilities(struct hfi_instance *hfi_instance) get_hfi_caps(hfi_instance, cpu_caps); - if (cpu_count < HFI_MAX_THERM_NOTIFY_COUNT) + if (cpu_count < HFI_THERMNL_CAPS_PER_EVENT) goto last_cmd; - /* Process complete chunks of HFI_MAX_THERM_NOTIFY_COUNT capabilities. */ + /* Process complete chunks of HFI_THERMNL_CAPS_PER_EVENT capabilities. */ for (i = 0; - (i + HFI_MAX_THERM_NOTIFY_COUNT) <= cpu_count; - i += HFI_MAX_THERM_NOTIFY_COUNT) - thermal_genl_cpu_capability_event(HFI_MAX_THERM_NOTIFY_COUNT, + (i + HFI_THERMNL_CAPS_PER_EVENT) <= cpu_count; + i += HFI_THERMNL_CAPS_PER_EVENT) + thermal_genl_cpu_capability_event(HFI_THERMNL_CAPS_PER_EVENT, &cpu_caps[i]); cpu_count = cpu_count - i; From patchwork Mon Apr 29 23:41:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 13647863 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 41E5F19DF4B; Mon, 29 Apr 2024 23:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433715; cv=none; b=eCHWNfnrwSeXrzMm+eBjpyZlYqBMeJA9kRJSxUXEZHu2qQA5hOvX3D5UOmbLhd4hFzp75w135I32oOKaLhFfN8gScYb7JSl5nshRb9hYA16xCKobbMTspL5LmikZt3Q1uspu+5MbtyKJLOopvDOvsyLnSoQhYKIEY1htWrWiuTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714433715; c=relaxed/simple; bh=J/IFFBDpfs1UKr0DRJtcmxEW5FMJCuZ1wc9KBNX67UI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KH4CUxxzEceHJtCCDmMPAOd2JukJfmMaQ/WFXJt1UjSkJFmhSlJ2Bbc3qHqBncFDNoyY/x1zAJWs29MI84PAUzSP8YxjD78B8pi1SOwMZ9XuMQy7jlq4XPosAtbZiwVxPXa0++54J5f1Q4jEfkp/BW5kYdojn6nPBj3k4Yw7nIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=h7ygC37/; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="h7ygC37/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714433714; x=1745969714; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=J/IFFBDpfs1UKr0DRJtcmxEW5FMJCuZ1wc9KBNX67UI=; b=h7ygC37/WuIdzbvwscH8/EkeHjbTVHni+PEYxXUsQVAF2ntbzhrcaVeZ 2ETcNmtiSc6/CFAITJGHV39/DjEpk6JwWtp7E7eP9KCP8LwwY0gwIsqVS 8cbbMc6XYPA+aSYxQNqC4l0N7Vdsohg7ZLMZGjUsqiJpViudSLVxv9wvP GQ2K45BfC6+viFzInHyZaSGMsMXrIh9rifqZC+U7UEcKuiA/mu29i5Ptd xCvh0R755a4iq3HxmVRo3lrd0EyAcO3uWyyNYGk/jKpCfNIurUYsBoBTd DTJNsbD87NALmPIMRpbzHTBRDe4QLFwVnTt5owHmtoJWKm/yOuDfkEelL A==; X-CSE-ConnectionGUID: a0JxQcpfQzabiSPqvUSkjA== X-CSE-MsgGUID: 66JydA49QGWhC9yiVQQ5Jw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="10274513" X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="10274513" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 16:35:09 -0700 X-CSE-ConnectionGUID: AzDskLe8T3eZte+HLZbnTA== X-CSE-MsgGUID: cw+k+tOsS7Cu1RywwhMU7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,240,1708416000"; d="scan'208";a="26200142" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmviesa009.fm.intel.com with ESMTP; 29 Apr 2024 16:35:09 -0700 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Zhang Rui , Srinivas Pandruvada , Len Brown , Stanislaw Gruszka , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH 4/4] thermal: intel: hfi: Tune the number of CPU capabilities per netlink event Date: Mon, 29 Apr 2024 16:41:52 -0700 Message-Id: <20240429234152.16230-5-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> References: <20240429234152.16230-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The number of updated CPU capabilities per netlink event is hard-coded to 16. On systems with more than 16 it takes more than one thermal netlink event to relay all the new capabilities when processing an HFI interrupt. This adds unnecessary overhead. Make the number of updated capabilities per event tuneable via debugfs. Users can then experiment with different values. We already take the hfi_instance_lock when submitting thermal netlink updates. Use it to serialize debugfs accesses to hfi_therm_notify_count. Suggested-by: Srinivas Pandruvada Signed-off-by: Ricardo Neri --- Cc: Len Brown Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/intel/intel_hfi.c | 34 ++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index d6d3544509fc..d5163b9766c0 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -175,6 +175,7 @@ static struct workqueue_struct *hfi_updates_wq; /* Keep this variable 8-byte aligned to get atomic accesses. */ static unsigned long hfi_update_delay = HFI_UPDATE_DELAY; +static int hfi_thermnl_caps_per_event = HFI_THERMNL_CAPS_PER_EVENT; #ifdef CONFIG_DEBUG_FS static int hfi_update_delay_get(void *data, u64 *val) @@ -205,6 +206,25 @@ static int hfi_update_delay_set(void *data, u64 val) DEFINE_DEBUGFS_ATTRIBUTE(hfi_update_delay_fops, hfi_update_delay_get, hfi_update_delay_set, "%llu\n"); +static int hfi_thermnl_caps_per_event_get(void *data, u64 *val) +{ + mutex_lock(&hfi_instance_lock); + *val = hfi_thermnl_caps_per_event; + mutex_unlock(&hfi_instance_lock); + return 0; +} + +static int hfi_thermnl_caps_per_event_set(void *data, u64 val) +{ + mutex_lock(&hfi_instance_lock); + hfi_thermnl_caps_per_event = val; + mutex_unlock(&hfi_instance_lock); + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(hfi_thermnl_caps_per_event_fops, + hfi_thermnl_caps_per_event_get, + hfi_thermnl_caps_per_event_set, "%llu\n"); static struct dentry *hfi_debugfs_dir; static void hfi_debugfs_unregister(void) @@ -226,6 +246,11 @@ static void hfi_debugfs_register(void) if (!f) goto err; + f = debugfs_create_file("thermnl_caps_per_event", 0644, hfi_debugfs_dir, + NULL, &hfi_thermnl_caps_per_event_fops); + if (!f) + goto err; + return; err: hfi_debugfs_unregister(); @@ -286,16 +311,15 @@ static void update_capabilities(struct hfi_instance *hfi_instance) get_hfi_caps(hfi_instance, cpu_caps); - if (cpu_count < HFI_THERMNL_CAPS_PER_EVENT) + if (cpu_count < hfi_thermnl_caps_per_event) goto last_cmd; /* Process complete chunks of HFI_THERMNL_CAPS_PER_EVENT capabilities. */ for (i = 0; - (i + HFI_THERMNL_CAPS_PER_EVENT) <= cpu_count; - i += HFI_THERMNL_CAPS_PER_EVENT) - thermal_genl_cpu_capability_event(HFI_THERMNL_CAPS_PER_EVENT, + (i + hfi_thermnl_caps_per_event) <= cpu_count; + i += hfi_thermnl_caps_per_event) + thermal_genl_cpu_capability_event(hfi_thermnl_caps_per_event, &cpu_caps[i]); - cpu_count = cpu_count - i; last_cmd: