Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1392/?format=api
https://patches.dpdk.org/api/patches/1392/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416492419-11957-2-git-send-email-sergio.gonzalez.monroy@intel.com/", "project": { "id": 1, "url": "https://patches.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": "<1416492419-11957-2-git-send-email-sergio.gonzalez.monroy@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1416492419-11957-2-git-send-email-sergio.gonzalez.monroy@intel.com", "date": "2014-11-20T14:06:58", "name": "[dpdk-dev,1/2] eal: use sysctl in BSD to set TSC freq", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "34cef98fa0b7698e9d8f6653fe4006fa6dd83918", "submitter": { "id": 73, "url": "https://patches.dpdk.org/api/people/73/?format=api", "name": "Sergio Gonzalez Monroy", "email": "sergio.gonzalez.monroy@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416492419-11957-2-git-send-email-sergio.gonzalez.monroy@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/1392/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/1392/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 15B027F40;\n\tThu, 20 Nov 2014 14:56:34 +0100 (CET)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 707177F11\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 14:56:32 +0100 (CET)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga103.fm.intel.com with ESMTP; 20 Nov 2014 06:00:08 -0800", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2014 05:57:33 -0800", "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tsAKE701f008152 for <dev@dpdk.org>; Thu, 20 Nov 2014 14:07:00 GMT", "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id sAKE6xl9012003\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 14:06:59 GMT", "(from smonroy@localhost)\n\tby sivswdev02.ir.intel.com with id sAKE6xPN011999\n\tfor dev@dpdk.org; Thu, 20 Nov 2014 14:06:59 GMT" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"4.97,862,1389772800\"; d=\"scan'208\";a=\"419260740\"", "From": "Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>", "To": "dev@dpdk.org", "Date": "Thu, 20 Nov 2014 14:06:58 +0000", "Message-Id": "<1416492419-11957-2-git-send-email-sergio.gonzalez.monroy@intel.com>", "X-Mailer": "git-send-email 1.8.5.4", "In-Reply-To": "<1416492419-11957-1-git-send-email-sergio.gonzalez.monroy@intel.com>", "References": "<1416492419-11957-1-git-send-email-sergio.gonzalez.monroy@intel.com>", "Subject": "[dpdk-dev] [PATCH 1/2] eal: use sysctl in BSD to set TSC freq", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "BSD provides the TSC frequency value through sysctl.\n\nSigned-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal_timer.c | 46 ++++++++++++++++++++---------------\n 1 file changed, 27 insertions(+), 19 deletions(-)", "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_timer.c b/lib/librte_eal/bsdapp/eal/eal_timer.c\nindex fd800b9..67da167 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_timer.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c\n@@ -41,6 +41,8 @@\n #include <sys/mman.h>\n #include <sys/queue.h>\n #include <pthread.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n #include <errno.h>\n \n #include <rte_common.h>\n@@ -241,29 +243,34 @@ rte_eal_hpet_init(int make_default)\n #endif\n \n static int\n-set_tsc_freq_from_clock(void)\n+set_tsc_freq_from_sysctl(void)\n {\n-#ifdef CLOCK_MONOTONIC_RAW\n-#define NS_PER_SEC 1E9\n+\tsize_t sz;\n+\tint tmp;\n \n-\tstruct timespec sleeptime = {.tv_nsec = 5E8 }; /* 1/2 second */\n+\tsz = sizeof(tmp);\n+\ttmp = 0;\n \n-\tstruct timespec t_start, t_end;\n+\tif (sysctlbyname(\"kern.timecounter.smp_tsc\", &tmp, &sz, NULL, 0))\n+\t\tRTE_LOG(WARNING, EAL, \"%s\\n\", strerror(errno));\n+\telse if (tmp != 1)\n+\t\tRTE_LOG(WARNING, EAL, \"TSC is not safe to use in SMP mode\\n\");\n \n-\tif (clock_gettime(CLOCK_MONOTONIC_RAW, &t_start) == 0) {\n-\t\tuint64_t ns, end, start = rte_rdtsc();\n-\t\tnanosleep(&sleeptime,NULL);\n-\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &t_end);\n-\t\tend = rte_rdtsc();\n-\t\tns = ((t_end.tv_sec - t_start.tv_sec) * NS_PER_SEC);\n-\t\tns += (t_end.tv_nsec - t_start.tv_nsec);\n+\ttmp = 0;\n \n-\t\tdouble secs = (double)ns/NS_PER_SEC;\n-\t\teal_tsc_resolution_hz = (uint64_t)((end - start)/secs);\n-\t\treturn 0;\n+\tif (sysctlbyname(\"kern.timecounter.invariant_tsc\", &tmp, &sz, NULL, 0))\n+\t\tRTE_LOG(WARNING, EAL, \"%s\\n\", strerror(errno));\n+\telse if (tmp != 1)\n+\t\tRTE_LOG(WARNING, EAL, \"TSC is not invariant\\n\");\n+\n+\tsz = sizeof(eal_tsc_resolution_hz);\n+\n+\tif (sysctlbyname(\"machdep.tsc_freq\", &eal_tsc_resolution_hz, &sz, NULL, 0)) {\n+\t\tRTE_LOG(WARNING, EAL, \"%s\\n\", strerror(errno));\n+\t\treturn -1;\n \t}\n-#endif\n-\treturn -1;\n+\n+\treturn 0;\n }\n \n static void\n@@ -277,10 +284,11 @@ set_tsc_freq_fallback(void)\n \tsleep(1);\n \teal_tsc_resolution_hz = rte_rdtsc() - start;\n }\n+\n /*\n * This function measures the TSC frequency. It uses a variety of approaches.\n *\n- * 1. If kernel provides CLOCK_MONOTONIC_RAW we use that to tune the TSC value\n+ * 1. Read the TSC frequency value provided by the kernel\n * 2. If kernel does not provide that, and we have HPET support, tune using HPET\n * 3. Lastly, if neither of the above can be used, just sleep for 1 second and\n * tune off that, printing a warning about inaccuracy of timing\n@@ -288,7 +296,7 @@ set_tsc_freq_fallback(void)\n static void\n set_tsc_freq(void)\n {\n-\tif (set_tsc_freq_from_clock() < 0)\n+\tif (set_tsc_freq_from_sysctl() < 0)\n \t\tset_tsc_freq_fallback();\n \n \tRTE_LOG(INFO, EAL, \"TSC frequency is ~%\"PRIu64\" KHz\\n\",\n", "prefixes": [ "dpdk-dev", "1/2" ] }{ "id": 1392, "url": "