get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 100997,
    "url": "http://patches.dpdk.org/api/patches/100997/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211011085644.2716490-2-dkozlyuk@nvidia.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": "<20211011085644.2716490-2-dkozlyuk@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211011085644.2716490-2-dkozlyuk@nvidia.com",
    "date": "2021-10-11T08:56:42",
    "name": "[v6,1/3] eal/linux: make hugetlbfs analysis reusable",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "f1d48a350bdd138160219020e4d444f32b0c3748",
    "submitter": {
        "id": 2367,
        "url": "http://patches.dpdk.org/api/people/2367/?format=api",
        "name": "Dmitry Kozlyuk",
        "email": "dkozlyuk@oss.nvidia.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20211011085644.2716490-2-dkozlyuk@nvidia.com/mbox/",
    "series": [
        {
            "id": 19509,
            "url": "http://patches.dpdk.org/api/series/19509/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=19509",
            "date": "2021-10-11T08:56:41",
            "name": "eal: add memory pre-allocation from existing files",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/19509/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/100997/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/100997/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 E88A4A034F;\n\tMon, 11 Oct 2021 10:57:09 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2CFED410F5;\n\tMon, 11 Oct 2021 10:57:07 +0200 (CEST)",
            "from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com\n [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id EAB46410F0\n for <dev@dpdk.org>; Mon, 11 Oct 2021 10:57:05 +0200 (CEST)",
            "from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.170)\n by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.858.15; Mon, 11 Oct 2021 01:57:04 -0700",
            "from BN8PR04CA0036.namprd04.prod.outlook.com (2603:10b6:408:70::49)\n by CY4PR12MB1829.namprd12.prod.outlook.com (2603:10b6:903:11d::14)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Mon, 11 Oct\n 2021 08:57:02 +0000",
            "from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com\n (2603:10b6:408:70:cafe::80) by BN8PR04CA0036.outlook.office365.com\n (2603:10b6:408:70::49) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend\n Transport; Mon, 11 Oct 2021 08:57:02 +0000",
            "from mail.nvidia.com (216.228.112.34) by\n BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP\n Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id\n 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 08:57:01 +0000",
            "from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com\n (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 11 Oct\n 2021 08:57:00 +0000"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=a57z/DhcXnZ/KJvgp72o5aRH5sP09l7SGA0smsTjeSpZp7eESdgVV/6ARquW7TRffokm+4+MfjVmVxJZtCt/sW68j+8oxTg6Q0LRh4WkWgTTzyZQSPFCSi70ZBpDSC3eBNjVytsrGNALe0vh6EsQp2Gbbr/QnZ3HwjoIuU2MrWRGjkFJgRnITCJC9xBMNINx1+OgsiTxrOdFMk+QBdhjVg3jP6vc48Ubdv0O2NVHeXnErFLvoS8v6vtlCpGBTQ4L2NPJMJt/miB6pVLaP/YtDnB4b8uxvUivadzHV4aNvJBTIRUd93yrIS430LJgPi4S41/UbAFAv5QTSWiSNKnfWg==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=QXPjXzdL/TParYCC/ZYC7uEAdDA0QMY64mWrhT37pCg=;\n b=W4Kd9DL+Bl0WwYjfxwqzSV+O5hmRDfC1K0aq2I+Si9rNq/VjOdVOhrLDLAt2ZQwQ8nPFA9+EWJYdBgDotnq+pow7cGd6KpgVAWIYio+2cFNIT2T3FpYW0FGzDgOztLd+6mTvJ12k3ykMuYCHDZEqihzYp1fpJvC5P5y41f3X+llA7lF0vu4psiffoF2v2a7h0qP7bY5rNgYKJY8TrvCN39roDK2DEgrUZjhbgBId1gdko1zHWniGuEMKQPg6vpVcKu2Ffl6EBv0dU2EML4DXdqs3H3oMMQwmJXv1gJXIEP6V6iSjXR9JEj7wQ8rYr2zPXnu715dTtNAfi3Yzh5JwIQ==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 216.228.112.34) smtp.rcpttodomain=nutanix.com smtp.mailfrom=nvidia.com;\n dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com;\n dkim=none (message not signed); arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;\n s=selector2;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=QXPjXzdL/TParYCC/ZYC7uEAdDA0QMY64mWrhT37pCg=;\n b=l+2z0H2MmigTojGIkXedtn3RQjXGp69xPhl8y1TZFqxiZqWL0ZlWsIs+v17xk50pJH4OQlwlrG979y0gmNYStuypnBvehvYux33JRElnLV8vW7/N0ErCv5PZCzbwaKobS81T7HQmzKcv5e/Bzzgc251NFFJXhcOthMbVt7xTzE27erHBvTKXeeJ/5IQ7hUzbuLjpq4ZJ2+CUa4GhvcRpMNtvLnK01GudOlBlGp3AskIdueqIvo4KUNiXfneU/TIzdeT1zVIJnfJyfEOE/0vFfJid9b3pijChEJlpvx4abMmWEvWMyCzchTguRrYnOoBZOgBrEJSjaKcZyhXSmf3VCw==",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 216.228.112.34)\n smtp.mailfrom=nvidia.com; nutanix.com; dkim=none (message not signed)\n header.d=none;nutanix.com; dmarc=pass action=none header.from=nvidia.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of nvidia.com designates\n 216.228.112.34 as permitted sender) receiver=protection.outlook.com;\n client-ip=216.228.112.34; helo=mail.nvidia.com;",
        "From": "Dmitry Kozlyuk <dkozlyuk@oss.nvidia.com>",
        "To": "<dev@dpdk.org>",
        "CC": "Viacheslav Ovsiienko <viacheslavo@oss.nvidia.com>, John Levon\n <john.levon@nutanix.com>",
        "Date": "Mon, 11 Oct 2021 11:56:42 +0300",
        "Message-ID": "<20211011085644.2716490-2-dkozlyuk@nvidia.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20211011085644.2716490-1-dkozlyuk@nvidia.com>",
        "References": "<20210921081632.858873-1-dkozlyuk@nvidia.com>\n <20211011085644.2716490-1-dkozlyuk@nvidia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[172.20.187.6]",
        "X-ClientProxiedBy": "HQMAIL105.nvidia.com (172.20.187.12) To\n HQMAIL107.nvidia.com (172.20.187.13)",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-Office365-Filtering-Correlation-Id": "a1267eeb-f32d-449b-40c0-08d98c95176d",
        "X-MS-TrafficTypeDiagnostic": "CY4PR12MB1829:",
        "X-Microsoft-Antispam-PRVS": "\n <CY4PR12MB1829529BDAD4223B992A7BD5B9B59@CY4PR12MB1829.namprd12.prod.outlook.com>",
        "X-MS-Exchange-Transport-Forked": "True",
        "X-MS-Oob-TLC-OOBClassifiers": "OLM:5236;",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n RBK+hmewtPc+etWEiv0P6lZF2oC9PYlg9umQ2Up8juyQG7A6ackVADWgeQJbVFmG+bRkjzfc9lgqkouasaN2iCAZL7c8m2yrHYU+mxRwtyh9Ab2MnyAWfkB4lsl0S4zLJE3PYFLLTl6cCXu1nUT14o8PpORij3+ULHTT2FGBDc7pJi7OSN10uHZG2hDFk4lM9zVn2W6PI4535BUfflcKVgFzkzJVrm3gtf+8DWrPfeLVtt6uIMvfmy+3l8f0CvNSWn3AmVIkXHDNNo9wXHqMQ94OgZ53ue5ojMcJNkTBB8ypFERaDciCxO+/7wKxHdTdbp7xup2ASesJLTs9eY/9cE+Palyzge8QCPitTh15y00VBbu+Td90gXJ4ccdvJinQipBJZuQdrbAd9kGqmgy8NGdC33z5QkoTPYW+NwcG8aQIYMoRNnwxKxshnVMKQxIARdzDKIs74ekgNVWzV72yM/qIPWYVz64SQ4po+IAURE1iWTU1MAhmbeG8SiOFKUdFf1isOPBdNDOl8k2ypvz0FSB8ZTtEnLRxUh1aLhVGfggLi54I3cOIeCXqJg61C6+YWV9zYyIHwdffXT+XkvMVLIZsUjPQBQRN1Jm3Zp37eEDG+fTGPeJNKR+7D+lKZNv+ZLxBS9jNCyrF94el+1NBsKsVF9XXw/nRVrYBFiiBane7gf8YtoTmKXlfQIQn9A+3H7+Wy9+Nx6sM187uC9QhrQ==",
        "X-Forefront-Antispam-Report": "CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1;\n SRV:;\n IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE;\n SFS:(4636009)(36840700001)(46966006)(8676002)(6666004)(4326008)(5660300002)(47076005)(316002)(2616005)(508600001)(55016002)(54906003)(36860700001)(26005)(83380400001)(16526019)(6916009)(2906002)(186003)(1076003)(36756003)(426003)(336012)(6286002)(8936002)(70206006)(107886003)(356005)(86362001)(70586007)(82310400003)(7636003)(7696005);\n DIR:OUT; SFP:1101;",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "11 Oct 2021 08:57:01.9028 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n a1267eeb-f32d-449b-40c0-08d98c95176d",
        "X-MS-Exchange-CrossTenant-Id": "43083d15-7273-40c1-b7db-39efd9ccc17a",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34];\n Helo=[mail.nvidia.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n BN8NAM11FT067.eop-nam11.prod.protection.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "CY4PR12MB1829",
        "Subject": "[dpdk-dev] [PATCH v6 1/3] eal/linux: make hugetlbfs analysis\n reusable",
        "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": "get_hugepage_dir() searched for a hugetlbfs mount with a given page size\nusing handcraft parsing of /proc/mounts and mixing traversal logic with\nselecting the needed entry. Separate code to enumerate hugetlbfs mounts\nto eal_hugepage_mount_walk() taking a callback that can inspect already\nparsed entries. Use mntent(3) API for parsing. This allows to reuse\nenumeration logic in subsequent patches.\n\nSigned-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>\nReviewed-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>\nReviewed-by: John Levon <john.levon@nutanix.com>\n---\n lib/eal/linux/eal_hugepage_info.c | 153 +++++++++++++++++++-----------\n lib/eal/linux/eal_hugepage_info.h |  39 ++++++++\n 2 files changed, 135 insertions(+), 57 deletions(-)\n create mode 100644 lib/eal/linux/eal_hugepage_info.h",
    "diff": "diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c\nindex d97792cade..193282e779 100644\n--- a/lib/eal/linux/eal_hugepage_info.c\n+++ b/lib/eal/linux/eal_hugepage_info.c\n@@ -12,6 +12,7 @@\n #include <stdio.h>\n #include <fnmatch.h>\n #include <inttypes.h>\n+#include <mntent.h>\n #include <stdarg.h>\n #include <unistd.h>\n #include <errno.h>\n@@ -34,6 +35,7 @@\n #include \"eal_private.h\"\n #include \"eal_internal_cfg.h\"\n #include \"eal_hugepages.h\"\n+#include \"eal_hugepage_info.h\"\n #include \"eal_filesystem.h\"\n \n static const char sys_dir_path[] = \"/sys/kernel/mm/hugepages\";\n@@ -195,73 +197,110 @@ get_default_hp_size(void)\n \treturn size;\n }\n \n-static int\n-get_hugepage_dir(uint64_t hugepage_sz, char *hugedir, int len)\n+int\n+eal_hugepage_mount_walk(eal_hugepage_mount_walk_cb *cb, void *cb_arg)\n {\n-\tenum proc_mount_fieldnames {\n-\t\tDEVICE = 0,\n-\t\tMOUNTPT,\n-\t\tFSTYPE,\n-\t\tOPTIONS,\n-\t\t_FIELDNAME_MAX\n-\t};\n-\tstatic uint64_t default_size = 0;\n-\tconst char proc_mounts[] = \"/proc/mounts\";\n-\tconst char hugetlbfs_str[] = \"hugetlbfs\";\n-\tconst size_t htlbfs_str_len = sizeof(hugetlbfs_str) - 1;\n-\tconst char pagesize_opt[] = \"pagesize=\";\n-\tconst size_t pagesize_opt_len = sizeof(pagesize_opt) - 1;\n-\tconst char split_tok = ' ';\n-\tchar *splitstr[_FIELDNAME_MAX];\n-\tchar buf[BUFSIZ];\n-\tint retval = -1;\n-\tconst struct internal_config *internal_conf =\n-\t\teal_get_internal_configuration();\n-\n-\tFILE *fd = fopen(proc_mounts, \"r\");\n-\tif (fd == NULL)\n-\t\trte_panic(\"Cannot open %s\\n\", proc_mounts);\n+\tstatic const char PATH[] = \"/proc/mounts\";\n+\tstatic const char OPTION[] = \"pagesize\";\n+\n+\tstatic uint64_t default_size;\n+\n+\tFILE *f = NULL;\n+\tstruct mntent mntent;\n+\tchar strings[PATH_MAX];\n+\tchar *hugepage_sz_str;\n+\tuint64_t hugepage_sz;\n+\tbool stopped = false;\n+\tint ret = -1;\n+\n+\tf = setmntent(PATH, \"r\");\n+\tif (f == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"%s(): setmntent(%s): %s\\n\",\n+\t\t\t\t__func__, PATH, strerror(errno));\n+\t\tgoto exit;\n+\t}\n \n \tif (default_size == 0)\n \t\tdefault_size = get_default_hp_size();\n \n-\twhile (fgets(buf, sizeof(buf), fd)){\n-\t\tif (rte_strsplit(buf, sizeof(buf), splitstr, _FIELDNAME_MAX,\n-\t\t\t\tsplit_tok) != _FIELDNAME_MAX) {\n-\t\t\tRTE_LOG(ERR, EAL, \"Error parsing %s\\n\", proc_mounts);\n-\t\t\tbreak; /* return NULL */\n+\tret = 0;\n+\twhile (getmntent_r(f, &mntent, strings, sizeof(strings)) != NULL) {\n+\t\tif (strcmp(mntent.mnt_type, \"hugetlbfs\") != 0)\n+\t\t\tcontinue;\n+\n+\t\thugepage_sz_str = hasmntopt(&mntent, OPTION);\n+\t\tif (hugepage_sz_str != NULL) {\n+\t\t\thugepage_sz_str += strlen(OPTION) + 1; /* +1 for '=' */\n+\t\t\thugepage_sz = rte_str_to_size(hugepage_sz_str);\n+\t\t\tif (hugepage_sz == 0) {\n+\t\t\t\tRTE_LOG(DEBUG, EAL, \"Cannot parse hugepage size from '%s' for %s\\n\",\n+\t\t\t\t\t\tmntent.mnt_opts, mntent.mnt_dir);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"Hugepage filesystem at %s without %s option\\n\",\n+\t\t\t\t\tmntent.mnt_dir, OPTION);\n+\t\t\thugepage_sz = default_size;\n \t\t}\n \n-\t\t/* we have a specified --huge-dir option, only examine that dir */\n-\t\tif (internal_conf->hugepage_dir != NULL &&\n-\t\t\t\tstrcmp(splitstr[MOUNTPT], internal_conf->hugepage_dir) != 0)\n-\t\t\tcontinue;\n+\t\tif (cb(mntent.mnt_dir, hugepage_sz, cb_arg) != 0) {\n+\t\t\tstopped = true;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n \n-\t\tif (strncmp(splitstr[FSTYPE], hugetlbfs_str, htlbfs_str_len) == 0){\n-\t\t\tconst char *pagesz_str = strstr(splitstr[OPTIONS], pagesize_opt);\n+\tif (ferror(f) || (!stopped && !feof(f))) {\n+\t\tRTE_LOG(ERR, EAL, \"%s(): getmntent_r(): %s\\n\",\n+\t\t\t\t__func__, strerror(errno));\n+\t\tret = -1;\n+\t\tgoto exit;\n+\t}\n \n-\t\t\t/* if no explicit page size, the default page size is compared */\n-\t\t\tif (pagesz_str == NULL){\n-\t\t\t\tif (hugepage_sz == default_size){\n-\t\t\t\t\tstrlcpy(hugedir, splitstr[MOUNTPT], len);\n-\t\t\t\t\tretval = 0;\n-\t\t\t\t\tbreak;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t\t/* there is an explicit page size, so check it */\n-\t\t\telse {\n-\t\t\t\tuint64_t pagesz = rte_str_to_size(&pagesz_str[pagesize_opt_len]);\n-\t\t\t\tif (pagesz == hugepage_sz) {\n-\t\t\t\t\tstrlcpy(hugedir, splitstr[MOUNTPT], len);\n-\t\t\t\t\tretval = 0;\n-\t\t\t\t\tbreak;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t} /* end if strncmp hugetlbfs */\n-\t} /* end while fgets */\n+exit:\n+\tif (f != NULL)\n+\t\tendmntent(f);\n+\treturn ret;\n+}\n \n-\tfclose(fd);\n-\treturn retval;\n+struct match_hugepage_mount_arg {\n+\tuint64_t hugepage_sz;\n+\tchar *hugedir;\n+\tint hugedir_len;\n+\tbool done;\n+};\n+\n+static int\n+match_hugepage_mount(const char *path, uint64_t hugepage_sz, void *cb_arg)\n+{\n+\tconst struct internal_config *internal_conf =\n+\t\teal_get_internal_configuration();\n+\tstruct match_hugepage_mount_arg *arg = cb_arg;\n+\n+\t/* we have a specified --huge-dir option, only examine that dir */\n+\tif (internal_conf->hugepage_dir != NULL &&\n+\t\t\tstrcmp(path, internal_conf->hugepage_dir) != 0)\n+\t\treturn 0;\n+\n+\tif (hugepage_sz == arg->hugepage_sz) {\n+\t\tstrlcpy(arg->hugedir, path, arg->hugedir_len);\n+\t\targ->done = true;\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+get_hugepage_dir(uint64_t hugepage_sz, char *hugedir, int len)\n+{\n+\tstruct match_hugepage_mount_arg arg = {\n+\t\t.hugepage_sz = hugepage_sz,\n+\t\t.hugedir = hugedir,\n+\t\t.hugedir_len = len,\n+\t\t.done = false,\n+\t};\n+\tint ret = eal_hugepage_mount_walk(match_hugepage_mount, &arg);\n+\treturn ret == 0 && arg.done ? 0 : -1;\n }\n \n /*\ndiff --git a/lib/eal/linux/eal_hugepage_info.h b/lib/eal/linux/eal_hugepage_info.h\nnew file mode 100644\nindex 0000000000..bc0e0a616c\n--- /dev/null\n+++ b/lib/eal/linux/eal_hugepage_info.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+ */\n+\n+#ifndef _EAL_HUGEPAGE_INFO_\n+#define _EAL_HUGEPAGE_INFO_\n+\n+#include <stdint.h>\n+\n+/**\n+ * Function called for each hugetlbfs mount point.\n+ *\n+ * @param path\n+ *  Mount point directory.\n+ * @param hugepage_sz\n+ *  Hugepage size for the mount or default system hugepage size.\n+ * @param arg\n+ *  User data.\n+ *\n+ * @return\n+ *  0 to continue walking, 1 to stop.\n+ */\n+typedef int (eal_hugepage_mount_walk_cb)(const char *path, uint64_t hugepage_sz,\n+\t\t\t\t\t void *arg);\n+\n+/**\n+ * Enumerate hugetlbfs mount points.\n+ *\n+ * @param cb\n+ *  Function called for each mount point.\n+ * @param cb_arg\n+ *  User data passed to the callback.\n+ *\n+ * @return\n+ *  0 on success, negative on failure.\n+ */\n+int eal_hugepage_mount_walk(eal_hugepage_mount_walk_cb *cb, void *cb_arg);\n+\n+#endif /* _EAL_HUGEPAGE_INFO_ */\n",
    "prefixes": [
        "v6",
        "1/3"
    ]
}