get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/90114/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 90114,
    "url": "http://patchwork.dpdk.org/api/patches/90114/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1d84367d34c987398e61374f76fde9b33d2ccbc6.1617114301.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1d84367d34c987398e61374f76fde9b33d2ccbc6.1617114301.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1d84367d34c987398e61374f76fde9b33d2ccbc6.1617114301.git.anatoly.burakov@intel.com",
    "date": "2021-03-30T14:25:10",
    "name": "[v2,2/3] power: refactor pstate sysfs handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0e2e3ac26c703fb3356c6ed540a129fe0db3055f",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1d84367d34c987398e61374f76fde9b33d2ccbc6.1617114301.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 15985,
            "url": "http://patchwork.dpdk.org/api/series/15985/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=15985",
            "date": "2021-03-30T14:25:10",
            "name": null,
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/15985/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/90114/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/90114/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 474A4A034F;\n\tTue, 30 Mar 2021 16:25:25 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 03B30140E39;\n\tTue, 30 Mar 2021 16:25:18 +0200 (CEST)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n by mails.dpdk.org (Postfix) with ESMTP id 86CF7406B4\n for <dev@dpdk.org>; Tue, 30 Mar 2021 16:25:15 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 30 Mar 2021 07:25:15 -0700",
            "from silpixa00399498.ir.intel.com (HELO\n silpixa00399498.ger.corp.intel.com) ([10.237.222.97])\n by orsmga005.jf.intel.com with ESMTP; 30 Mar 2021 07:25:13 -0700"
        ],
        "IronPort-SDR": [
            "\n bkyrkWJyno4hQ8RrI8CRGH50fXGmOPCoYELpckI+RlZbHUw2x7Ua2U30v/Gl4EA1UxI4xt6tF6\n C2F9kKxqxBcw==",
            "\n iat6gHqia7zIwYnl1hjgs77udJJAq9avj2Qo5TkbuMu7fcQlrVjRwCoU68j2adG0gtDz8wvZCD\n 83vLPHVOY9Kg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9939\"; a=\"253116348\"",
            "E=Sophos;i=\"5.81,291,1610438400\"; d=\"scan'208\";a=\"253116348\"",
            "E=Sophos;i=\"5.81,291,1610438400\"; d=\"scan'208\";a=\"595484278\""
        ],
        "X-ExtLoop1": "1",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "David Hunt <david.hunt@intel.com>",
        "Date": "Tue, 30 Mar 2021 14:25:10 +0000",
        "Message-Id": "\n <1d84367d34c987398e61374f76fde9b33d2ccbc6.1617114301.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "\n <d0dc49e5dab4d4c730cc137194350a7d0a8baca8.1617113740.git.anatoly.burakov@intel.com>",
        "References": "\n <d0dc49e5dab4d4c730cc137194350a7d0a8baca8.1617113740.git.anatoly.burakov@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v2 2/3] power: refactor pstate sysfs handling",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Make use of new sysfs handling functions in other pstate code.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_power/power_pstate_cpufreq.c | 177 +++++++++++-------------\n 1 file changed, 80 insertions(+), 97 deletions(-)",
    "diff": "diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c\nindex add06720db..7ea1bf677a 100644\n--- a/lib/librte_power/power_pstate_cpufreq.c\n+++ b/lib/librte_power/power_pstate_cpufreq.c\n@@ -198,6 +198,46 @@ read_core_sysfs_u32(FILE *f, uint32_t *val)\n \treturn 0;\n }\n \n+static int\n+read_core_sysfs_s(FILE *f, char *buf, unsigned int len)\n+{\n+\tchar *s;\n+\n+\ts = fgets(buf, len, f);\n+\tif (s == NULL)\n+\t\treturn -1;\n+\n+\t/* fgets puts null terminator in, but do this just in case */\n+\tbuf[len - 1] = '\\0';\n+\n+\t/* strip off any terminating newlines */\n+\tif (strlen(buf))\n+\t\tstrtok(buf, \"\\n\");\n+\n+\treturn 0;\n+}\n+\n+static int\n+write_core_sysfs_s(FILE *f, const char *str)\n+{\n+\tint ret;\n+\n+\tret = fseek(f, 0, SEEK_SET);\n+\tif (ret != 0)\n+\t\treturn -1;\n+\n+\tret = fputs(str, f);\n+\tif (ret != 0)\n+\t\treturn -1;\n+\n+\t/* flush the output */\n+\tret = fflush(f);\n+\tif (ret != 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n /**\n  * It is to fopen the sys file for the future setting the lcore frequency.\n  */\n@@ -399,22 +439,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)\n static int\n power_set_governor_performance(struct pstate_power_info *pi)\n {\n-\tFILE *f;\n+\tFILE *f_governor = NULL;\n \tint ret = -1;\n \tchar buf[BUFSIZ];\n-\tchar fullpath[PATH_MAX];\n-\tchar *s;\n-\tint val;\n \n-\tsnprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_GOVERNOR,\n-\t\t\tpi->lcore_id);\n-\tf = fopen(fullpath, \"rw+\");\n-\tFOPEN_OR_ERR_RET(f, ret);\n+\topen_core_sysfs_file(POWER_SYSFILE_GOVERNOR, pi->lcore_id, \"rw+\",\n+\t\t\t&f_governor);\n+\tFOPEN_OR_ERR_GOTO(f_governor, out);\n \n-\ts = fgets(buf, sizeof(buf), f);\n-\tFOPS_OR_NULL_GOTO(s, out);\n-\t/* Strip off terminating '\\n' */\n-\tstrtok(buf, \"\\n\");\n+\tret = read_core_sysfs_s(f_governor, buf, sizeof(buf));\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n \t/* Check if current governor is performance */\n \tif (strncmp(buf, POWER_GOVERNOR_PERF,\n@@ -428,21 +462,15 @@ power_set_governor_performance(struct pstate_power_info *pi)\n \tstrlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori));\n \n \t/* Write 'performance' to the governor */\n-\tval = fseek(f, 0, SEEK_SET);\n-\tFOPS_OR_ERR_GOTO(val, out);\n-\n-\tval = fputs(POWER_GOVERNOR_PERF, f);\n-\tFOPS_OR_ERR_GOTO(val, out);\n-\n-\t/* We need to flush to see if the fputs succeeds */\n-\tval = fflush(f);\n-\tFOPS_OR_ERR_GOTO(val, out);\n+\tret = write_core_sysfs_s(f_governor, POWER_GOVERNOR_PERF);\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n \tret = 0;\n \tRTE_LOG(INFO, POWER, \"Power management governor of lcore %u has been \"\n \t\t\t\"set to performance successfully\\n\", pi->lcore_id);\n out:\n-\tfclose(f);\n+\tif (f_governor != NULL)\n+\t\tfclose(f_governor);\n \n \treturn ret;\n }\n@@ -454,20 +482,16 @@ power_set_governor_performance(struct pstate_power_info *pi)\n static int\n power_set_governor_original(struct pstate_power_info *pi)\n {\n-\tFILE *f;\n+\tFILE *f_governor = NULL;\n \tint ret = -1;\n \tchar buf[BUFSIZ];\n-\tchar fullpath[PATH_MAX];\n-\tchar *s;\n-\tint val;\n \n-\tsnprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_GOVERNOR,\n-\t\t\tpi->lcore_id);\n-\tf = fopen(fullpath, \"rw+\");\n-\tFOPEN_OR_ERR_RET(f, ret);\n+\topen_core_sysfs_file(POWER_SYSFILE_GOVERNOR, pi->lcore_id, \"rw+\",\n+\t\t\t&f_governor);\n+\tFOPEN_OR_ERR_GOTO(f_governor, out);\n \n-\ts = fgets(buf, sizeof(buf), f);\n-\tFOPS_OR_NULL_GOTO(s, out);\n+\tret = read_core_sysfs_s(f_governor, buf, sizeof(buf));\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n \t/* Check if the governor to be set is the same as current */\n \tif (strncmp(buf, pi->governor_ori, sizeof(pi->governor_ori)) == 0) {\n@@ -479,19 +503,16 @@ power_set_governor_original(struct pstate_power_info *pi)\n \t}\n \n \t/* Write back the original governor */\n-\tval = fseek(f, 0, SEEK_SET);\n-\tFOPS_OR_ERR_GOTO(val, out);\n-\n-\tval = fputs(pi->governor_ori, f);\n-\tFOPS_OR_ERR_GOTO(val, out);\n+\tret = write_core_sysfs_s(f_governor, pi->governor_ori);\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n \tret = 0;\n \tRTE_LOG(INFO, POWER, \"Power management governor of lcore %u \"\n \t\t\t\"has been set back to %s successfully\\n\",\n \t\t\tpi->lcore_id, pi->governor_ori);\n out:\n-\tfclose(f);\n-\n+\tif (f_governor != NULL)\n+\t\tfclose(f_governor);\n \treturn ret;\n }\n \n@@ -502,51 +523,26 @@ power_set_governor_original(struct pstate_power_info *pi)\n static int\n power_get_available_freqs(struct pstate_power_info *pi)\n {\n-\tFILE *f_min, *f_max;\n+\tFILE *f_min = NULL, *f_max = NULL;\n \tint ret = -1;\n-\tchar *p_min, *p_max;\n-\tchar buf_min[BUFSIZ];\n-\tchar buf_max[BUFSIZ];\n-\tchar fullpath_min[PATH_MAX];\n-\tchar fullpath_max[PATH_MAX];\n-\tchar *s_min, *s_max;\n \tuint32_t sys_min_freq = 0, sys_max_freq = 0, base_max_freq = 0;\n \tuint32_t i, num_freqs = 0;\n \n-\tsnprintf(fullpath_max, sizeof(fullpath_max),\n-\t\t\tPOWER_SYSFILE_BASE_MAX_FREQ,\n-\t\t\tpi->lcore_id);\n-\tsnprintf(fullpath_min, sizeof(fullpath_min),\n-\t\t\tPOWER_SYSFILE_BASE_MIN_FREQ,\n-\t\t\tpi->lcore_id);\n+\t/* open all files */\n+\topen_core_sysfs_file(POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id, \"r\",\n+\t\t\t&f_max);\n+\tFOPEN_OR_ERR_GOTO(f_max, out);\n \n-\tf_min = fopen(fullpath_min, \"r\");\n-\tFOPEN_OR_ERR_RET(f_min, ret);\n+\topen_core_sysfs_file(POWER_SYSFILE_BASE_MIN_FREQ, pi->lcore_id, \"r\",\n+\t\t\t     &f_min);\n+\tFOPEN_OR_ERR_GOTO(f_max, out);\n \n-\tf_max = fopen(fullpath_max, \"r\");\n-\tif (f_max == NULL)\n-\t\tfclose(f_min);\n+\t/* read base ratios */\n+\tret = read_core_sysfs_u32(f_max, &sys_max_freq);\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n-\tFOPEN_OR_ERR_RET(f_max, ret);\n-\n-\ts_min = fgets(buf_min, sizeof(buf_min), f_min);\n-\tFOPS_OR_NULL_GOTO(s_min, out);\n-\n-\ts_max = fgets(buf_max, sizeof(buf_max), f_max);\n-\tFOPS_OR_NULL_GOTO(s_max, out);\n-\n-\n-\t/* Strip the line break if there is */\n-\tp_min = strchr(buf_min, '\\n');\n-\tif (p_min != NULL)\n-\t\t*p_min = 0;\n-\n-\tp_max = strchr(buf_max, '\\n');\n-\tif (p_max != NULL)\n-\t\t*p_max = 0;\n-\n-\tsys_min_freq = strtoul(buf_min, &p_min, POWER_CONVERT_TO_DECIMAL);\n-\tsys_max_freq = strtoul(buf_max, &p_max, POWER_CONVERT_TO_DECIMAL);\n+\tret = read_core_sysfs_u32(f_min, &sys_min_freq);\n+\tFOPS_OR_ERR_GOTO(ret, out);\n \n \tif (sys_max_freq < sys_min_freq)\n \t\tgoto out;\n@@ -605,27 +601,14 @@ power_get_cur_idx(struct pstate_power_info *pi)\n {\n \tFILE *f_cur;\n \tint ret = -1;\n-\tchar *p_cur;\n-\tchar buf_cur[BUFSIZ];\n-\tchar fullpath_cur[PATH_MAX];\n-\tchar *s_cur;\n \tuint32_t sys_cur_freq = 0;\n \tunsigned int i;\n \n-\tsnprintf(fullpath_cur, sizeof(fullpath_cur),\n-\t\t\tPOWER_SYSFILE_CUR_FREQ,\n-\t\t\tpi->lcore_id);\n-\tf_cur = fopen(fullpath_cur, \"r\");\n-\tFOPEN_OR_ERR_RET(f_cur, ret);\n+\topen_core_sysfs_file(POWER_SYSFILE_CUR_FREQ, pi->lcore_id, \"r\", &f_cur);\n+\tFOPEN_OR_ERR_GOTO(f_cur, fail);\n \n-\t/* initialize the cur_idx to matching current frequency freq index */\n-\ts_cur = fgets(buf_cur, sizeof(buf_cur), f_cur);\n-\tFOPS_OR_NULL_GOTO(s_cur, fail);\n-\n-\tp_cur = strchr(buf_cur, '\\n');\n-\tif (p_cur != NULL)\n-\t\t*p_cur = 0;\n-\tsys_cur_freq = strtoul(buf_cur, &p_cur, POWER_CONVERT_TO_DECIMAL);\n+\tret = read_core_sysfs_u32(f_cur, &sys_cur_freq);\n+\tFOPS_OR_ERR_GOTO(ret, fail);\n \n \t/* convert the frequency to nearest 100000 value\n \t * Ex: if sys_cur_freq=1396789 then freq_conv=1400000\n@@ -644,10 +627,10 @@ power_get_cur_idx(struct pstate_power_info *pi)\n \t\t}\n \t}\n \n-\tfclose(f_cur);\n-\treturn 0;\n+\tret = 0;\n fail:\n-\tfclose(f_cur);\n+\tif (f_cur != NULL)\n+\t\tfclose(f_cur);\n \treturn ret;\n }\n \n",
    "prefixes": [
        "v2",
        "2/3"
    ]
}