get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44278,
    "url": "http://patchwork.dpdk.org/api/patches/44278/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/6a24b2f23baccc78b7bab7ecfee84d3ed477ab80.1536073997.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": "<6a24b2f23baccc78b7bab7ecfee84d3ed477ab80.1536073997.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/6a24b2f23baccc78b7bab7ecfee84d3ed477ab80.1536073997.git.anatoly.burakov@intel.com",
    "date": "2018-09-04T15:15:47",
    "name": "[v3,6/9] memalloc: add EAL-internal API to get and set segment fd's",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "e51aa1c08753c684cee6dd046dd3ed957570dda2",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "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/6a24b2f23baccc78b7bab7ecfee84d3ed477ab80.1536073997.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1177,
            "url": "http://patchwork.dpdk.org/api/series/1177/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=1177",
            "date": "2018-09-04T15:15:41",
            "name": "Improve running DPDK without hugetlbfs mounpoint",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/1177/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/44278/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/44278/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 C7AF24CBD;\n\tTue,  4 Sep 2018 17:16:01 +0200 (CEST)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id EADC62B92\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 17:15:54 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 08:15:53 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby FMSMGA003.fm.intel.com with ESMTP; 04 Sep 2018 08:15:52 -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\tw84FFpgO025481; Tue, 4 Sep 2018 16:15:51 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84FFpoL022293;\n\tTue, 4 Sep 2018 16:15:51 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84FFphU022285;\n\tTue, 4 Sep 2018 16:15:51 +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,329,1531810800\"; d=\"scan'208\";a=\"77880039\"",
        "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": "Tue,  4 Sep 2018 16:15:47 +0100",
        "Message-Id": "<6a24b2f23baccc78b7bab7ecfee84d3ed477ab80.1536073997.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1536073996.git.anatoly.burakov@intel.com>",
            "<cover.1536073996.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1536073996.git.anatoly.burakov@intel.com>",
            "<cover.1536072550.git.anatoly.burakov@intel.com>\n\t<cover.1536073996.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 6/9] 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   | 44 +++++++++++++---\n 5 files changed, 109 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..e3ac24815 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,10 @@ 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\tif (eal_memalloc_set_seg_fd(msl_idx, ms_idx, fd) < 0)\n+\t\t\tRTE_LOG(ERR, EAL, \"Could not store segment fd: %s\\n\",\n+\t\t\t\trte_strerror(rte_errno));\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 +1774,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 +1818,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 +1838,50 @@ 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\tif (eal_memalloc_set_seg_fd(msl_idx, ms_idx, fd) < 0)\n+\t\t\tRTE_LOG(ERR, EAL, \"Could not store segment fd: %s\\n\",\n+\t\t\t\trte_strerror(rte_errno));\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": [
        "v3",
        "6/9"
    ]
}