get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 43841,
    "url": "http://patches.dpdk.org/api/patches/43841/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/55accff3d2854f7213f671f029149ead5927a087.1535041359.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": "<55accff3d2854f7213f671f029149ead5927a087.1535041359.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/55accff3d2854f7213f671f029149ead5927a087.1535041359.git.anatoly.burakov@intel.com",
    "date": "2018-08-23T16:59:53",
    "name": "[6/8] memalloc: add EAL-internal API to get and set segment fd's",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "595aae8b421e0c4b12f6d019215d3243009a72b6",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "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/55accff3d2854f7213f671f029149ead5927a087.1535041359.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1040,
            "url": "http://patches.dpdk.org/api/series/1040/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1040",
            "date": "2018-08-23T16:59:47",
            "name": "Improve running DPDK without hugetlbfs mounpoint",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1040/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/43841/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/43841/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 07DAB4C97;\n\tThu, 23 Aug 2018 19:02:13 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id B125698\n\tfor <dev@dpdk.org>; Thu, 23 Aug 2018 19:02:11 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Aug 2018 10:01:56 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga003.jf.intel.com with ESMTP; 23 Aug 2018 09:59:56 -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\tw7NGxuAZ025442; Thu, 23 Aug 2018 17:59:56 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w7NGxu3q006726;\n\tThu, 23 Aug 2018 17:59:56 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w7NGxuxE006722;\n\tThu, 23 Aug 2018 17:59:56 +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,278,1531810800\"; d=\"scan'208\";a=\"77818988\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Bruce Richardson <bruce.richardson@intel.com>, tiwei.bie@intel.com,\n\tray.kinsella@intel.com, zhihong.wang@intel.com,\n\tmaxime.coquelin@redhat.com, kuralamudhan.ramakrishnan@intel.com",
        "Date": "Thu, 23 Aug 2018 17:59:53 +0100",
        "Message-Id": "<55accff3d2854f7213f671f029149ead5927a087.1535041359.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1535041359.git.anatoly.burakov@intel.com>",
            "<cover.1535041359.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1535041359.git.anatoly.burakov@intel.com>",
            "<cover.1535041359.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH 6/8] memalloc: add EAL-internal API to get and\n\tset segment fd's",
        "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": "Enable setting and retrieving segment fd's internally.\n\nFor now, retrieving fd's will not be used anywhere until we\nget an external API, but it will be useful for things like\nvirtio, where we wish to share segment fd's.\n\nSetting segment fd's will not be available as a public API\nat this time, but internally it is needed for legacy mode,\nbecause we're not allocating our hugepages in memalloc in\nlegacy mode case, and we still need to store the fd.\n\nAnother user of get segment fd API is memseg info dump, to\nshow which pages use which fd's.\n\nNot supported on FreeBSD.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal_memalloc.c   | 12 +++++\n lib/librte_eal/common/eal_common_memory.c  |  8 +--\n lib/librte_eal/common/eal_memalloc.h       |  6 +++\n lib/librte_eal/linuxapp/eal/eal_memalloc.c | 60 +++++++++++++++++-----\n lib/librte_eal/linuxapp/eal/eal_memory.c   | 40 ++++++++++++---\n 5 files changed, 105 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_memalloc.c b/lib/librte_eal/bsdapp/eal/eal_memalloc.c\nindex f7f07abd6..a5fb09f71 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_memalloc.c\n@@ -47,6 +47,18 @@ eal_memalloc_sync_with_primary(void)\n \treturn -1;\n }\n \n+int\n+eal_memalloc_get_seg_fd(int list_idx, int seg_idx)\n+{\n+\treturn -1;\n+}\n+\n+int\n+eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)\n+{\n+\treturn -1;\n+}\n+\n int\n eal_memalloc_init(void)\n {\ndiff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex fbfb1b055..034c2026a 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -294,7 +294,7 @@ dump_memseg(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n \t\tvoid *arg)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n-\tint msl_idx, ms_idx;\n+\tint msl_idx, ms_idx, fd;\n \tFILE *f = arg;\n \n \tmsl_idx = msl - mcfg->memsegs;\n@@ -305,10 +305,11 @@ dump_memseg(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n \tif (ms_idx < 0)\n \t\treturn -1;\n \n+\tfd = eal_memalloc_get_seg_fd(msl_idx, ms_idx);\n \tfprintf(f, \"Segment %i-%i: IOVA:0x%\"PRIx64\", len:%zu, \"\n \t\t\t\"virt:%p, socket_id:%\"PRId32\", \"\n \t\t\t\"hugepage_sz:%\"PRIu64\", nchannel:%\"PRIx32\", \"\n-\t\t\t\"nrank:%\"PRIx32\"\\n\",\n+\t\t\t\"nrank:%\"PRIx32\" fd:%i\\n\",\n \t\t\tmsl_idx, ms_idx,\n \t\t\tms->iova,\n \t\t\tms->len,\n@@ -316,7 +317,8 @@ dump_memseg(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n \t\t\tms->socket_id,\n \t\t\tms->hugepage_sz,\n \t\t\tms->nchannel,\n-\t\t\tms->nrank);\n+\t\t\tms->nrank,\n+\t\t\tfd);\n \n \treturn 0;\n }\ndiff --git a/lib/librte_eal/common/eal_memalloc.h b/lib/librte_eal/common/eal_memalloc.h\nindex 36bb1a027..a46c69c72 100644\n--- a/lib/librte_eal/common/eal_memalloc.h\n+++ b/lib/librte_eal/common/eal_memalloc.h\n@@ -76,6 +76,12 @@ eal_memalloc_mem_alloc_validator_unregister(const char *name, int socket_id);\n int\n eal_memalloc_mem_alloc_validate(int socket_id, size_t new_len);\n \n+int\n+eal_memalloc_get_seg_fd(int list_idx, int seg_idx);\n+\n+int\n+eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd);\n+\n int\n eal_memalloc_init(void);\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\nindex 7d536350e..b820989e9 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n@@ -1334,16 +1334,10 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl,\n }\n \n static int\n-fd_list_create_walk(const struct rte_memseg_list *msl,\n-\t\tvoid *arg __rte_unused)\n+alloc_list(int list_idx, int len)\n {\n-\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n-\tunsigned int i, len;\n-\tint msl_idx;\n \tint *data;\n-\n-\tmsl_idx = msl - mcfg->memsegs;\n-\tlen = msl->memseg_arr.len;\n+\tint i;\n \n \t/* ensure we have space to store fd per each possible segment */\n \tdata = malloc(sizeof(int) * len);\n@@ -1355,14 +1349,56 @@ fd_list_create_walk(const struct rte_memseg_list *msl,\n \tfor (i = 0; i < len; i++)\n \t\tdata[i] = -1;\n \n-\tfd_list[msl_idx].fds = data;\n-\tfd_list[msl_idx].len = len;\n-\tfd_list[msl_idx].count = 0;\n-\tfd_list[msl_idx].memseg_list_fd = -1;\n+\tfd_list[list_idx].fds = data;\n+\tfd_list[list_idx].len = len;\n+\tfd_list[list_idx].count = 0;\n+\tfd_list[list_idx].memseg_list_fd = -1;\n \n \treturn 0;\n }\n \n+static int\n+fd_list_create_walk(const struct rte_memseg_list *msl,\n+\t\tvoid *arg __rte_unused)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tunsigned int len;\n+\tint msl_idx;\n+\n+\tmsl_idx = msl - mcfg->memsegs;\n+\tlen = msl->memseg_arr.len;\n+\n+\treturn alloc_list(msl_idx, len);\n+}\n+\n+int\n+eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\n+\t/* if list is not allocated, allocate it */\n+\tif (fd_list[list_idx].len == 0) {\n+\t\tint len = mcfg->memsegs[list_idx].memseg_arr.len;\n+\n+\t\tif (alloc_list(list_idx, len) < 0)\n+\t\t\treturn -1;\n+\t}\n+\tfd_list[list_idx].fds[seg_idx] = fd;\n+\n+\treturn 0;\n+}\n+\n+int\n+eal_memalloc_get_seg_fd(int list_idx, int seg_idx)\n+{\n+\tif (internal_config.single_file_segments)\n+\t\treturn fd_list[list_idx].memseg_list_fd;\n+\t/* list not initialized */\n+\tif (fd_list[list_idx].len == 0)\n+\t\treturn -1;\n+\treturn fd_list[list_idx].fds[seg_idx];\n+}\n+\n int\n eal_memalloc_init(void)\n {\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c\nindex dfb537f59..ace14c877 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memory.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c\n@@ -772,7 +772,8 @@ remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end)\n \n \t\trte_fbarray_set_used(arr, ms_idx);\n \n-\t\tclose(fd);\n+\t\t/* store segment fd internally */\n+\t\teal_memalloc_set_seg_fd(msl_idx, ms_idx, fd);\n \t}\n \tRTE_LOG(DEBUG, EAL, \"Allocated %\" PRIu64 \"M on socket %i\\n\",\n \t\t\t(seg_len * page_sz) >> 20, socket_id);\n@@ -1771,6 +1772,7 @@ getFileSize(int fd)\n static int\n eal_legacy_hugepage_attach(void)\n {\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tstruct hugepage_file *hp = NULL;\n \tunsigned int num_hp = 0;\n \tunsigned int i = 0;\n@@ -1814,6 +1816,9 @@ eal_legacy_hugepage_attach(void)\n \t\tstruct hugepage_file *hf = &hp[i];\n \t\tsize_t map_sz = hf->size;\n \t\tvoid *map_addr = hf->final_va;\n+\t\tint msl_idx, ms_idx;\n+\t\tstruct rte_memseg_list *msl;\n+\t\tstruct rte_memseg *ms;\n \n \t\t/* if size is zero, no more pages left */\n \t\tif (map_sz == 0)\n@@ -1831,25 +1836,48 @@ eal_legacy_hugepage_attach(void)\n \t\tif (map_addr == MAP_FAILED) {\n \t\t\tRTE_LOG(ERR, EAL, \"Could not map %s: %s\\n\",\n \t\t\t\thf->filepath, strerror(errno));\n-\t\t\tclose(fd);\n-\t\t\tgoto error;\n+\t\t\tgoto fd_error;\n \t\t}\n \n \t\t/* set shared lock on the file. */\n \t\tif (flock(fd, LOCK_SH) < 0) {\n \t\t\tRTE_LOG(DEBUG, EAL, \"%s(): Locking file failed: %s\\n\",\n \t\t\t\t__func__, strerror(errno));\n-\t\t\tclose(fd);\n-\t\t\tgoto error;\n+\t\t\tgoto fd_error;\n \t\t}\n \n-\t\tclose(fd);\n+\t\t/* find segment data */\n+\t\tmsl = rte_mem_virt2memseg_list(map_addr);\n+\t\tif (msl == NULL) {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"%s(): Cannot find memseg list\\n\",\n+\t\t\t\t__func__);\n+\t\t\tgoto fd_error;\n+\t\t}\n+\t\tms = rte_mem_virt2memseg(map_addr, msl);\n+\t\tif (ms == NULL) {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"%s(): Cannot find memseg\\n\",\n+\t\t\t\t__func__);\n+\t\t\tgoto fd_error;\n+\t\t}\n+\n+\t\tmsl_idx = msl - mcfg->memsegs;\n+\t\tms_idx = rte_fbarray_find_idx(&msl->memseg_arr, ms);\n+\t\tif (ms_idx < 0) {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"%s(): Cannot find memseg idx\\n\",\n+\t\t\t\t__func__);\n+\t\t\tgoto fd_error;\n+\t\t}\n+\n+\t\t/* store segment fd internally */\n+\t\teal_memalloc_set_seg_fd(msl_idx, ms_idx, fd);\n \t}\n \t/* unmap the hugepage config file, since we are done using it */\n \tmunmap(hp, size);\n \tclose(fd_hugepage);\n \treturn 0;\n \n+fd_error:\n+\tclose(fd);\n error:\n \t/* map all segments into memory to make sure we get the addrs */\n \tcur_seg = 0;\n",
    "prefixes": [
        "6/8"
    ]
}