From patchwork Wed Mar 28 06:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Jerez X-Patchwork-Id: 10312247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16F6C60325 for ; Wed, 28 Mar 2018 06:43:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095E32993B for ; Wed, 28 Mar 2018 06:43:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F287929A18; Wed, 28 Mar 2018 06:43:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 983A02993B for ; Wed, 28 Mar 2018 06:43:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DAE676E203; Wed, 28 Mar 2018 06:43:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CB5E6E203 for ; Wed, 28 Mar 2018 06:43:51 +0000 (UTC) Received: from cotinga.riseup.net (cotinga-pn.riseup.net [10.0.1.164]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id DD62A1A09EA; Tue, 27 Mar 2018 23:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1522219431; bh=Tz7W4AFQHJc1KxB8/AqoMXV3SCm5atXR2bba+KZdzy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1fPSvySBdgeeBSwAtXrUYT+Xmpe1tv8ShLXJHf3Yyt4tQlDk3PFrgF3JkB72Ltvg vogy8P703LuXsZUq6GYtW+FHGV9qzvB+68BCea6eDbKZQNBXoQ1jBlHTi/UPikoqoa UHpy+N3QK6zqVZtq1ZiTywOBoslnvXQ4OSLEWp/g= X-Riseup-User-ID: 75D9D7A54172DB5F41D421DC0462E19D8C917F8C4FB9FE0DA3214B1752C1E581 Received: from [127.0.0.1] (localhost [127.0.0.1]) by cotinga.riseup.net with ESMTPSA id 8ED4A6C448; Tue, 27 Mar 2018 23:43:50 -0700 (PDT) From: Francisco Jerez To: linux-pm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Srinivas Pandruvada Date: Tue, 27 Mar 2018 23:38:44 -0700 Message-Id: <20180328063845.4884-9-currojerez@riseup.net> In-Reply-To: <20180328063845.4884-1-currojerez@riseup.net> References: <20180328063845.4884-1-currojerez@riseup.net> Subject: [Intel-gfx] [PATCH 8/9] OPTIONAL: cpufreq/intel_pstate: Expose LP controller parameters via debugfs. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eero Tamminen , "Rafael J. Wysocki" MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This is not required for the controller to work but has proven very useful for debugging and testing of alternative heuristic parameters, which may offer a better trade-off between energy efficiency and latency -- The default parameters are rather aggressively latency-minimizing in order to keep up with the big-core controller and avoid regressions in latency-sensitive applications, however a more energy-efficient trade-off may be preferable in practice. E.g.: { .sample_interval_ms = 10, .setpoint_pml = 700, .p_base_avg_hz = 3, .io_active_threshold_pml = 950, .io_active_avg_hz = 10 } A warning is printed out which should taint the kernel for the non-standard calibration of the heuristic to be obvious in bug reports. Signed-off-by: Francisco Jerez --- drivers/cpufreq/intel_pstate.c | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index d0e212387755..7b1666c34273 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -862,6 +862,92 @@ static void intel_pstate_update_policies(void) cpufreq_update_policy(cpu); } +/************************** debugfs begin ************************/ +static void intel_pstate_lp_reset(struct cpudata *cpu); + +static int lp_param_set(void *data, u64 val) +{ + unsigned int cpu; + + *(u32 *)data = val; + for_each_possible_cpu(cpu) { + if (all_cpu_data[cpu]) + intel_pstate_lp_reset(all_cpu_data[cpu]); + } + + WARN_ONCE(1, "Unsupported P-state LP parameter update via debugging interface"); + + return 0; +} + +static int lp_param_get(void *data, u64 *val) +{ + *val = *(u32 *)data; + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(fops_lp_param, lp_param_get, lp_param_set, "%llu\n"); + +static struct dentry *debugfs_parent; + +struct lp_param { + char *name; + void *value; + struct dentry *dentry; +}; + +static struct lp_param lp_files[] = { + {"lp_sample_interval_ms", &lp_params.sample_interval_ms, }, + {"lp_setpoint_pml", &lp_params.setpoint_pml, }, + {"lp_p_base_avg_hz", &lp_params.p_base_avg_hz, }, + {"lp_io_active_threshold_pml", &lp_params.io_active_threshold_pml, }, + {"lp_io_active_avg_hz", &lp_params.io_active_avg_hz, }, + {NULL, NULL, } +}; + +static void intel_pstate_update_util_lp(struct update_util_data *data, + u64 time, unsigned int flags); + +static void intel_pstate_debug_expose_params(void) +{ + int i; + + if (hwp_active || + pstate_funcs.update_util != intel_pstate_update_util_lp) + return; + + debugfs_parent = debugfs_create_dir("pstate_snb", NULL); + if (IS_ERR_OR_NULL(debugfs_parent)) + return; + + for (i = 0; lp_files[i].name; i++) { + struct dentry *dentry; + + dentry = debugfs_create_file(lp_files[i].name, 0660, + debugfs_parent, lp_files[i].value, + &fops_lp_param); + if (!IS_ERR(dentry)) + lp_files[i].dentry = dentry; + } +} + +static void intel_pstate_debug_hide_params(void) +{ + int i; + + if (IS_ERR_OR_NULL(debugfs_parent)) + return; + + for (i = 0; lp_files[i].name; i++) { + debugfs_remove(lp_files[i].dentry); + lp_files[i].dentry = NULL; + } + + debugfs_remove(debugfs_parent); + debugfs_parent = NULL; +} + +/************************** debugfs end ************************/ + /************************** sysfs begin ************************/ #define show_one(file_name, object) \ static ssize_t show_##file_name \ @@ -2423,6 +2509,8 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver) global.min_perf_pct = min_perf_pct_min(); + intel_pstate_debug_expose_params(); + return 0; } @@ -2431,6 +2519,8 @@ static int intel_pstate_unregister_driver(void) if (hwp_active) return -EBUSY; + intel_pstate_debug_hide_params(); + cpufreq_unregister_driver(intel_pstate_driver); intel_pstate_driver_cleanup();