Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/43974/?format=api
http://patches.dpdk.org/api/patches/43974/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "http://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": "<2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com", "date": "2018-08-29T12:21:13", "name": "mem: fix undefined behavior in NUMA code", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "8826ed58094b1f83647d7c8da1955b3ea24a100f", "submitter": { "id": 4, "url": "http://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com/mbox/", "series": [ { "id": 1092, "url": "http://patches.dpdk.org/api/series/1092/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1092", "date": "2018-08-29T12:21:13", "name": "mem: fix undefined behavior in NUMA code", "version": 1, "mbox": "http://patches.dpdk.org/series/1092/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/43974/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/43974/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7CDA94C88;\n\tWed, 29 Aug 2018 14:21:37 +0200 (CEST)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id 205D2F11;\n\tWed, 29 Aug 2018 14:21:34 +0200 (CEST)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Aug 2018 05:21:34 -0700", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga001.fm.intel.com with ESMTP; 29 Aug 2018 05:21:15 -0700", "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw7TCLErD004502; Wed, 29 Aug 2018 13:21:14 +0100", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w7TCLE7N007507;\n\tWed, 29 Aug 2018 13:21:14 +0100", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w7TCLDno007485;\n\tWed, 29 Aug 2018 13:21:13 +0100" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.53,303,1531810800\"; d=\"scan'208\";a=\"85457034\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "solal.pirelli@gmail.com, i.maximets@samsung.com, stable@dpdk.org", "Date": "Wed, 29 Aug 2018 13:21:13 +0100", "Message-Id": "<2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "Subject": "[dpdk-dev] [PATCH] mem: fix undefined behavior in NUMA code", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "When NUMA-aware hugepages config option is set, we rely on\nlibnuma to tell the kernel to allocate hugepages on a specific\nNUMA node. However, we allocate node mask before we check if\nNUMA is available in the first place, which, according to\nthe manpage [1], causes undefined behaviour.\n\nFix by only using nodemask when we have NUMA available.\n\n[1] https://linux.die.net/man/3/numa_alloc_onnode\n\nBugzilla ID: 20\n\nFixes: 1b72605d2416 (\"mem: balanced allocation of hugepages\")\nCc: i.maximets@samsung.com\nCc: stable@dpdk.org\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/linuxapp/eal/eal_memory.c | 28 ++++++++++++++----------\n 1 file changed, 16 insertions(+), 12 deletions(-)", "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c\nindex dbf19499e..4976eeacd 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memory.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c\n@@ -263,7 +263,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \tint node_id = -1;\n \tint essential_prev = 0;\n \tint oldpolicy;\n-\tstruct bitmask *oldmask = numa_allocate_nodemask();\n+\tstruct bitmask *oldmask = NULL;\n \tbool have_numa = true;\n \tunsigned long maxnode = 0;\n \n@@ -275,6 +275,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \n \tif (have_numa) {\n \t\tRTE_LOG(DEBUG, EAL, \"Trying to obtain current memory policy.\\n\");\n+\t\toldmask = numa_allocate_nodemask();\n \t\tif (get_mempolicy(&oldpolicy, oldmask->maskp,\n \t\t\t\t oldmask->size + 1, 0, 0) < 0) {\n \t\t\tRTE_LOG(ERR, EAL,\n@@ -390,19 +391,22 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \n out:\n #ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES\n-\tif (maxnode) {\n-\t\tRTE_LOG(DEBUG, EAL,\n-\t\t\t\"Restoring previous memory policy: %d\\n\", oldpolicy);\n-\t\tif (oldpolicy == MPOL_DEFAULT) {\n-\t\t\tnuma_set_localalloc();\n-\t\t} else if (set_mempolicy(oldpolicy, oldmask->maskp,\n-\t\t\t\t\t oldmask->size + 1) < 0) {\n-\t\t\tRTE_LOG(ERR, EAL, \"Failed to restore mempolicy: %s\\n\",\n-\t\t\t\tstrerror(errno));\n-\t\t\tnuma_set_localalloc();\n+\tif (have_numa) {\n+\t\tif (maxnode) {\n+\t\t\tRTE_LOG(DEBUG, EAL,\n+\t\t\t\t\"Restoring previous memory policy: %d\\n\",\n+\t\t\t\t\toldpolicy);\n+\t\t\tif (oldpolicy == MPOL_DEFAULT) {\n+\t\t\t\tnuma_set_localalloc();\n+\t\t\t} else if (set_mempolicy(oldpolicy, oldmask->maskp,\n+\t\t\t\t\t\t oldmask->size + 1) < 0) {\n+\t\t\t\tRTE_LOG(ERR, EAL, \"Failed to restore mempolicy: %s\\n\",\n+\t\t\t\t\tstrerror(errno));\n+\t\t\t\tnuma_set_localalloc();\n+\t\t\t}\n \t\t}\n+\t\tnuma_free_cpumask(oldmask);\n \t}\n-\tnuma_free_cpumask(oldmask);\n #endif\n \treturn i;\n }\n", "prefixes": [] }{ "id": 43974, "url": "