Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2226193/?format=api
{ "id": 2226193, "url": "http://patchwork.ozlabs.org/api/patches/2226193/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260422103542.20933-2-piotr.kubaj@intel.com/", "project": { "id": 59, "url": "http://patchwork.ozlabs.org/api/projects/59/?format=api", "name": "Linux Test Project development", "link_name": "ltp", "list_id": "ltp.lists.linux.it", "list_email": "ltp@lists.linux.it", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260422103542.20933-2-piotr.kubaj@intel.com>", "list_archive_url": null, "date": "2026-04-22T10:35:43", "name": "cpufreq.c: add new test for cpufreq sysfs interface validation", "commit_ref": null, "pull_url": null, "state": "needs-review-ack", "archived": false, "hash": "92a0a920c292579df68197ed54cae7b060b4187f", "submitter": { "id": 92049, "url": "http://patchwork.ozlabs.org/api/people/92049/?format=api", "name": "Piotr Kubaj", "email": "piotr.kubaj@intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260422103542.20933-2-piotr.kubaj@intel.com/mbox/", "series": [ { "id": 500971, "url": "http://patchwork.ozlabs.org/api/series/500971/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=500971", "date": "2026-04-22T10:35:43", "name": "cpufreq.c: add new test for cpufreq sysfs interface validation", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500971/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226193/comments/", "check": "fail", "checks": "http://patchwork.ozlabs.org/api/patches/2226193/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "ltp@lists.linux.it" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "ltp@picard.linux.it" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=NPIgqDUa;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from picard.linux.it (unknown [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0wdM65CBz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:36:54 +1000 (AEST)", "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 35E683E4A7A\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:36:42 +0200 (CEST)", "from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 4853A3E2332\n for <ltp@lists.linux.it>; Wed, 22 Apr 2026 12:36:39 +0200 (CEST)", "from mgamail.intel.com (mgamail.intel.com [192.198.163.10])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 865E5100035D\n for <ltp@lists.linux.it>; Wed, 22 Apr 2026 12:36:36 +0200 (CEST)", "from fmviesa004.fm.intel.com ([10.60.135.144])\n by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 22 Apr 2026 03:36:34 -0700", "from pkubaj-desk.igk.intel.com (HELO intel.com) ([10.217.160.221])\n by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 22 Apr 2026 03:36:32 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1776854198; x=1808390198;\n h=from:to:cc:subject:date:message-id:mime-version:\n content-transfer-encoding;\n bh=nTf2GTGYgOyYjFRWdkItPlYi+fPFO5GSMUXrVH1aBg8=;\n b=NPIgqDUaZc7hnnZk30Qn0jVAYzZbKGvVpiyLs6FyYs89sM/0LoYq6Qav\n G82EKBdQJfibBoyFzcLGkA+U2jPBuWS7KCmZa96JPw3Mee06Lf+O9fvMI\n jL2yubsNZlefudVDDGjXDC3vvWO5+iPxYV0hx0mWl3ghbqVzuY/g5EP9x\n nPk2icRnH6F5zvZXoCDnV2sCbJoA4wbeGX2GTpEM8TJSIwIkKWNdDXWuA\n qh6uDCxssJjRx/pwMEzMYeB0cLsNgmIobMo7W6BuBRGwwb/QrLq9dbKEx\n z613b+Nz4GQtC9fqUoV5fexjzPfclwLsrwQZIJiQgHlNMmEvYmQ3nw7Bj A==;", "X-CSE-ConnectionGUID": [ "b98DHa9TSO+QaPvSDgkZug==", "Q5IXrqWJRDei8BUynFRsoA==" ], "X-CSE-MsgGUID": [ "jnIr3s0yTial4h+zbIndpw==", "R3ZXtRc5Rn+GkCi6Tqwjxg==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6800,10657,11763\"; a=\"89190714\"", "E=Sophos;i=\"6.23,192,1770624000\"; d=\"scan'208\";a=\"89190714\"", "E=Sophos;i=\"6.23,192,1770624000\"; d=\"scan'208\";a=\"234107963\"" ], "X-ExtLoop1": "1", "From": "Piotr Kubaj <piotr.kubaj@intel.com>", "To": "ltp@lists.linux.it", "Date": "Wed, 22 Apr 2026 12:35:43 +0200", "Message-ID": "<20260422103542.20933-2-piotr.kubaj@intel.com>", "X-Mailer": "git-send-email 2.47.3", "MIME-Version": "1.0", "X-Spam-Status": "No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-4.smtp.seeweb.it", "X-Virus-Scanned": "clamav-milter 1.0.9 at in-4.smtp.seeweb.it", "X-Virus-Status": "Clean", "Subject": "[LTP] [PATCH] cpufreq.c: add new test for cpufreq sysfs interface\n validation", "X-BeenThere": "ltp@lists.linux.it", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Linux Test Project <ltp.lists.linux.it>", "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>", "List-Archive": "<http://lists.linux.it/pipermail/ltp/>", "List-Post": "<mailto:ltp@lists.linux.it>", "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>", "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>", "Cc": "helena.anna.dubel@intel.com, tomasz.ossowski@intel.com,\n rafael.j.wysocki@intel.com, daniel.niestepski@intel.com", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it", "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>" }, "content": "Runs various sanity checks for intel_pstate cpufreq sysfs interface.\n\nChecks whether intel_pstate driver is used, whether it is possible\nto switch scaling_governor to powersave and performance,\nwhether it is possible to disable turbo frequency and\nwhether it is possible to change scaling_min_freq and scaling_max_freq\nto its minimal valid and maximal valid values.\n\nSigned-off-by: Piotr Kubaj <piotr.kubaj@intel.com>\n---\n runtest/power_management_tests | 1 +\n testcases/kernel/power_management/.gitignore | 1 +\n testcases/kernel/power_management/cpufreq.c | 355 +++++++++++++++++++\n 3 files changed, 357 insertions(+)\n create mode 100644 testcases/kernel/power_management/cpufreq.c", "diff": "diff --git a/runtest/power_management_tests b/runtest/power_management_tests\nindex 884e615cd..f235f8f0b 100644\n--- a/runtest/power_management_tests\n+++ b/runtest/power_management_tests\n@@ -1,4 +1,5 @@\n #POWER_MANAGEMENT\n+cpufreq cpufreq\n runpwtests01 runpwtests01.sh\n runpwtests02 runpwtests02.sh\n runpwtests03 runpwtests03.sh\ndiff --git a/testcases/kernel/power_management/.gitignore b/testcases/kernel/power_management/.gitignore\nindex 0c2a3ed4b..d0d7336ad 100644\n--- a/testcases/kernel/power_management/.gitignore\n+++ b/testcases/kernel/power_management/.gitignore\n@@ -1 +1,2 @@\n+cpufreq\n pm_get_sched_values\ndiff --git a/testcases/kernel/power_management/cpufreq.c b/testcases/kernel/power_management/cpufreq.c\nnew file mode 100644\nindex 000000000..379aac0fe\n--- /dev/null\n+++ b/testcases/kernel/power_management/cpufreq.c\n@@ -0,0 +1,355 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Copyright (c) 2026 Piotr Kubaj <piotr.kubaj@intel.com>\n+ */\n+\n+/*\\\n+ * Runs various sanity checks for intel_pstate cpufreq sysfs interface.\n+ *\n+ * Checks whether intel_pstate driver is used, whether it is possible to switch\n+ * scaling_governor to powersave and performance, whether it is possible\n+ * to disable turbo frequency and whether it is possible to change\n+ * scaling_min_freq and scaling_max_freq to its minimal valid and maximal valid\n+ * values.\n+ */\n+\n+#include \"tst_test.h\"\n+\n+static bool *online;\n+static char path[PATH_MAX], intel_pstate_status[16];\n+static int no_turbo, nproc;\n+static long *previous_scaling_max_freq, *previous_scaling_min_freq;\n+\n+static void cleanup(void)\n+{\n+\tSAFE_FILE_PRINTF(\"/sys/devices/system/cpu/intel_pstate/no_turbo\", \"%d\", no_turbo);\n+\tSAFE_FILE_PRINTF(\"/sys/devices/system/cpu/intel_pstate/status\", intel_pstate_status);\n+\tfor (int i = 0; i < nproc; i++) {\n+\t\tif (!online[i])\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq\", i);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", previous_scaling_max_freq[i]);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\", i);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", previous_scaling_min_freq[i]);\n+\t}\n+\tfree(online);\n+\tfree(previous_scaling_max_freq);\n+\tfree(previous_scaling_min_freq);\n+}\n+\n+static void setup(void)\n+{\n+\tSAFE_FILE_SCANF(\"/sys/devices/system/cpu/intel_pstate/no_turbo\", \"%d\", &no_turbo);\n+\tSAFE_FILE_SCANF(\"/sys/devices/system/cpu/intel_pstate/status\", \"%15s\", intel_pstate_status);\n+\tSAFE_FILE_PRINTF(\"/sys/devices/system/cpu/intel_pstate/status\", \"active\");\n+\n+\tnproc = tst_ncpus_conf();\n+\tonline = SAFE_CALLOC(nproc, sizeof(*online));\n+\tprevious_scaling_max_freq = SAFE_CALLOC(nproc, sizeof(*previous_scaling_max_freq));\n+\tprevious_scaling_min_freq = SAFE_CALLOC(nproc, sizeof(*previous_scaling_min_freq));\n+\tonline[0] = true;\n+\tfor (int i = 1; i < nproc; i++) {\n+\t\tint tmp;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/online\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%d\", &tmp);\n+\t\tonline[i] = (bool)tmp;\n+\t}\n+}\n+\n+static void run(void)\n+{\n+\tconst char * const cpufreq_nodes[] = {\n+\t\t\"affected_cpus\",\n+\t\t\"cpuinfo_max_freq\",\n+\t\t\"cpuinfo_min_freq\",\n+\t\t\"cpuinfo_transition_latency\",\n+\t\t\"related_cpus\",\n+\t\t\"scaling_available_governors\",\n+\t\t\"scaling_cur_freq\",\n+\t\t\"scaling_driver\",\n+\t\t\"scaling_governor\",\n+\t\t\"scaling_max_freq\",\n+\t\t\"scaling_min_freq\",\n+\t\t\"scaling_setspeed\",\n+\t\tNULL\n+\t};\n+\tchar contents[256] = {0}, path_cpuinfo_min_freq[PATH_MAX];\n+\tint fd;\n+\tlong cpuinfo_max_freq = 0, cpuinfo_min_freq = 0, scaling_max_freq, scaling_min_freq;\n+\n+\tfor (int i = 0; i < nproc; i++) {\n+\t\tif (!online[i])\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_driver\", i);\n+\n+\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\t\ttst_res(TDEBUG, \"Checking whether %s is \\\"intel_pstate\\\"\", path);\n+\t\tif (strstr(contents, \"intel_pstate\"))\n+\t\t\ttst_res(TPASS, \"%s is intel_pstate\", path);\n+\t\telse {\n+\t\t\ttst_res(TINFO, \"%s contains: %s\", path, contents);\n+\t\t\ttst_res(TFAIL, \"%s is not intel_pstate\", path);\n+\t\t}\n+\n+\t\tfor (int j = 0; cpufreq_nodes[j] != NULL; j++) {\n+\t\t\tstruct stat stats;\n+\n+\t\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/%s\", i, cpufreq_nodes[j]);\n+\t\t\ttst_res(TDEBUG, \"Checking whether %s is a regular file\", path);\n+\t\t\tSAFE_STAT(path, &stats);\n+\t\t\tif (!S_ISREG(stats.st_mode)) {\n+\t\t\t\ttst_res(TINFO, \"%s mode: %o\\n\", path, stats.st_mode);\n+\t\t\t\ttst_res(TFAIL, \"%s is not a regular file\", path);\n+\t\t\t} else\n+\t\t\t\ttst_res(TPASS, \"%s is a regular file\", path);\n+\t\t}\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors\", i);\n+\t\tmemset(contents, 0, sizeof(contents));\n+\t\tfd = SAFE_OPEN(path, O_RDONLY);\n+\t\tSAFE_READ(0, fd, contents, sizeof(contents));\n+\t\tSAFE_CLOSE(fd);\n+\n+\t\ttst_res(TDEBUG, \"Checking whether %s is \\\"performance powersave\\\"\", path);\n+\t\tif (strstr(contents, \"performance powersave\"))\n+\t\t\ttst_res(TPASS, \"%s contains: %s\", path, contents);\n+\t\telse {\n+\t\t\ttst_res(TINFO, \"%s contains: %s\", path, contents);\n+\t\t\ttst_res(TFAIL, \"%s is not \\\"performance powersave\\\"\", path);\n+\t\t}\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor\", i);\n+\t\ttst_res(TDEBUG, \"Checking %s\", path);\n+\t\tmemset(contents, 0, sizeof(contents));\n+\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\t\tif (strstr(contents, \"performance\")) {\n+\t\t\ttst_res(TDEBUG, \"%s is \\\"performance\\\"\", path);\n+\t\t\ttst_res(TDEBUG, \"Checking whether %s can be switched to \\\"powersave\\\"\", path);\n+\t\t\tSAFE_FILE_PRINTF(path, \"powersave\");\n+\t\t\tmemset(contents, 0, sizeof(contents));\n+\t\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\t\t\tif (strstr(contents, \"powersave\"))\n+\t\t\t\ttst_res(TPASS, \"Changing scaling_governor from performance to powersave succeeded\");\n+\t\t\telse\n+\t\t\t\ttst_res(TFAIL, \"%s: failed to change scaling_governor from performance to powersave, current scaling_governor: %s\", path, contents);\n+\n+\t\t} else if (strstr(contents, \"powersave\")) {\n+\t\t\ttst_res(TDEBUG, \"%s is \\\"powersave\\\"\", path);\n+\t\t\ttst_res(TDEBUG, \"Checking whether %s can be switched to \\\"performance\\\"\", path);\n+\t\t\tSAFE_FILE_PRINTF(path, \"performance\");\n+\t\t\tmemset(contents, 0, sizeof(contents));\n+\t\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\t\t\tif (strstr(contents, \"performance\"))\n+\t\t\t\ttst_res(TPASS, \"Changing scaling_governor from powersave to performance succeeded\");\n+\t\t\telse\n+\t\t\t\ttst_res(TFAIL, \"%s: failed to change scaling_governor from powersave to performance, current scaling_governor: %s\", path, contents);\n+\n+\t\t} else\n+\t\t\ttst_brk(TBROK, \"Unknown scaling_governor: %s\", contents);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq\", i);\n+\t\tsnprintf(path_cpuinfo_min_freq, sizeof(path_cpuinfo_min_freq), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_min_freq\", i);\n+\t\ttst_res(TDEBUG, \"Checking whether %s is bigger than cpuinfo_min_freq\", path);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &cpuinfo_max_freq);\n+\n+\t\tSAFE_FILE_SCANF(path_cpuinfo_min_freq, \"%ld\", &cpuinfo_min_freq);\n+\n+\t\tif (cpuinfo_min_freq > cpuinfo_max_freq)\n+\t\t\ttst_res(TFAIL, \"Value in %s: %ld, should be bigger than cpuinfo_min_freq: %ld\", path, cpuinfo_max_freq, cpuinfo_min_freq);\n+\t\telse\n+\t\t\ttst_res(TPASS, \"Value in %s: %ld, is bigger than cpuinfo_min_freq: %ld\", path, cpuinfo_max_freq, cpuinfo_min_freq);\n+\t}\n+\n+\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/intel_pstate/status\");\n+\ttst_res(TDEBUG, \"Checking whether %s contains \\\"active\\\"\", path);\n+\tmemset(contents, 0, sizeof(contents));\n+\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\tif (strstr(contents, \"active\"))\n+\t\ttst_res(TPASS, \"%s is \\\"active\\\"\", path);\n+\telse\n+\t\ttst_res(TFAIL, \"%s is not \\\"active\\\", but %s\", path, contents);\n+\n+\ttst_res(TDEBUG, \"Checking whether %s can be switched to \\\"passive\\\"\", path);\n+\tSAFE_FILE_PRINTF(path, \"passive\");\n+\tmemset(contents, 0, sizeof(contents));\n+\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\tif (strstr(contents, \"passive\"))\n+\t\ttst_res(TPASS, \"%s is \\\"passive\\\"\", path);\n+\telse\n+\t\ttst_res(TFAIL, \"%s is not \\\"passive\\\", but %s\", path, contents);\n+\n+\ttst_res(TDEBUG, \"Checking whether %s can be switched back to \\\"active\\\"\", path);\n+\tSAFE_FILE_PRINTF(path, \"active\");\n+\tmemset(contents, 0, sizeof(contents));\n+\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\tif (strstr(contents, \"active\"))\n+\t\ttst_res(TPASS, \"%s is \\\"active\\\"\", path);\n+\telse\n+\t\ttst_res(TFAIL, \"%s is not \\\"active\\\", but %s\", path, contents);\n+\n+\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/intel_pstate/no_turbo\");\n+\ttst_res(TDEBUG, \"Checking whether %s can be switched to 1\", path);\n+\tSAFE_FILE_PRINTF(path, \"1\");\n+\tmemset(contents, 0, sizeof(contents));\n+\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\tif (strstr(contents, \"1\"))\n+\t\ttst_res(TPASS, \"%s is \\\"1\\\"\", path);\n+\telse\n+\t\ttst_res(TFAIL, \"%s is not \\\"1\\\", but %s\", path, contents);\n+\n+\ttst_res(TDEBUG, \"Checking whether %s can be switched back to 0\", path);\n+\tSAFE_FILE_PRINTF(path, \"0\");\n+\tmemset(contents, 0, sizeof(contents));\n+\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\tif (strstr(contents, \"0\"))\n+\t\ttst_res(TPASS, \"%s is \\\"0\\\"\", path);\n+\telse\n+\t\ttst_res(TFAIL, \"%s is not \\\"0\\\", but %s\", path, contents);\n+\n+\ttst_res(TDEBUG, \"Checking whether scaling_available_governors changes to \\\"performance schedutil \\\" after switching /sys/devices/system/cpu/intel_pstate/status to \\\"passive\\\"\");\n+\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/intel_pstate/status\");\n+\tSAFE_FILE_PRINTF(path, \"passive\");\n+\n+\tfor (int i = 0; i < nproc; i++) {\n+\t\tif (!online[i])\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors\", i);\n+\t\tmemset(contents, 0, sizeof(contents));\n+\t\tfd = SAFE_OPEN(path, O_RDONLY);\n+\t\tSAFE_READ(0, fd, contents, sizeof(contents));\n+\t\tSAFE_CLOSE(fd);\n+\n+\t\ttst_res(TDEBUG, \"Checking whether %s is \\\"performance schedutil\\\"\", path);\n+\t\tif (strstr(contents, \"performance schedutil\"))\n+\t\t\ttst_res(TPASS, \"%s contains: %s\", path, contents);\n+\t\telse {\n+\t\t\ttst_res(TINFO, \"%s contains: %s\", path, contents);\n+\t\t\ttst_res(TFAIL, \"%s is not \\\"performance schedutil \\\"\", path);\n+\t\t}\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor\", i);\n+\t\ttst_res(TDEBUG, \"Checking whether %s can be changed to performance\", path);\n+\t\tSAFE_FILE_PRINTF(path, \"performance\");\n+\t\tmemset(contents, 0, sizeof(contents));\n+\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\t\tif (strstr(contents, \"performance\"))\n+\t\t\ttst_res(TPASS, \"%s is \\\"performance\\\"\", path);\n+\t\telse\n+\t\t\ttst_res(TFAIL, \"%s is not \\\"performance\\\", but %s\", path, contents);\n+\n+\t\ttst_res(TDEBUG, \"Checking whether %s can be changed to schedutil\", path);\n+\t\tSAFE_FILE_PRINTF(path, \"schedutil\");\n+\t\tmemset(contents, 0, sizeof(contents));\n+\t\tSAFE_FILE_SCANF(path, \"%255s\", contents);\n+\n+\t\tif (strstr(contents, \"schedutil\"))\n+\t\t\ttst_res(TPASS, \"%s is \\\"schedutil\\\"\", path);\n+\t\telse\n+\t\t\ttst_res(TFAIL, \"%s is not \\\"schedutil\\\", but %s\", path, contents);\n+\t}\n+\n+\tfor (int i = 0; i < nproc; i++) {\n+\t\tif (!online[i])\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq\", i);\n+\t\ttst_res(TDEBUG, \"Checking whether %s can be assigned to scaling_max_freq and scaling_min_freq\", path);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &cpuinfo_max_freq);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_min_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &cpuinfo_min_freq);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &previous_scaling_max_freq[i]);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", cpuinfo_max_freq);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &scaling_max_freq);\n+\n+\t\tif (cpuinfo_max_freq < scaling_max_freq) {\n+\t\t\ttst_res(TINFO, \"cpuinfo_max_freq: %ld\", cpuinfo_max_freq);\n+\t\t\ttst_res(TINFO, \"scaling_max_freq: %ld\", scaling_max_freq);\n+\t\t\ttst_res(TFAIL, \"Failure setting %s\", path);\n+\t\t} else\n+\t\t\ttst_res(TPASS, \"Successfully set up %s\", path);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &previous_scaling_min_freq[i]);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", cpuinfo_max_freq);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &scaling_min_freq);\n+\n+\t\tif (cpuinfo_max_freq < scaling_min_freq) {\n+\t\t\ttst_res(TINFO, \"cpuinfo_max_freq: %ld\", cpuinfo_max_freq);\n+\t\t\ttst_res(TINFO, \"scaling_min_freq: %ld\", scaling_min_freq);\n+\t\t\ttst_res(TFAIL, \"Failure setting %s\", path);\n+\t\t} else\n+\t\t\ttst_res(TPASS, \"Successfully set up %s\", path);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\", i);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", previous_scaling_min_freq[i]);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq\", i);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", previous_scaling_max_freq[i]);\n+\t}\n+\n+\tfor (int i = 0; i < nproc; i++) {\n+\t\tif (!online[i])\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq\", i);\n+\t\ttst_res(TDEBUG, \"Checking whether %s can be assigned to scaling_max_freq and scaling_min_freq\", path);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &cpuinfo_max_freq);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_min_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &cpuinfo_min_freq);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &previous_scaling_min_freq[i]);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", cpuinfo_min_freq);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &scaling_min_freq);\n+\n+\t\tif (cpuinfo_min_freq > scaling_min_freq) {\n+\t\t\ttst_res(TINFO, \"cpuinfo_min_freq: %ld\", cpuinfo_min_freq);\n+\t\t\ttst_res(TINFO, \"scaling_min_freq: %ld\", scaling_min_freq);\n+\t\t\ttst_res(TFAIL, \"Failure setting %s\", path);\n+\t\t} else\n+\t\t\ttst_res(TPASS, \"Successfully set up %s\", path);\n+\n+\t\tsnprintf(path, sizeof(path), \"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq\", i);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &previous_scaling_max_freq[i]);\n+\t\tSAFE_FILE_PRINTF(path, \"%ld\", cpuinfo_min_freq);\n+\t\tSAFE_FILE_SCANF(path, \"%ld\", &scaling_max_freq);\n+\n+\t\tif (cpuinfo_min_freq > scaling_max_freq) {\n+\t\t\ttst_res(TINFO, \"cpuinfo_min_freq: %ld\", cpuinfo_min_freq);\n+\t\t\ttst_res(TINFO, \"scaling_max_freq: %ld\", scaling_max_freq);\n+\t\t\ttst_res(TFAIL, \"Failure setting %s\", path);\n+\t\t} else\n+\t\t\ttst_res(TPASS, \"Successfully set up %s\", path);\n+\t}\n+}\n+\n+static struct tst_test test = {\n+\t.cleanup = cleanup,\n+\t.needs_kconfigs = (const char *const []) {\n+\t\t\"CONFIG_X86_INTEL_PSTATE\",\n+\t\tNULL\n+\t},\n+\t.needs_root = 1,\n+\t.setup = setup,\n+\t.supported_archs = (const char *const []) {\n+\t\t\"x86\",\n+\t\t\"x86_64\",\n+\t\tNULL\n+\t},\n+\t.test_all = run\n+};\n", "prefixes": [] }