On 5/26/2026 6:16 PM, Bruce Richardson wrote:
On Fri, Mar 13, 2026 at 04:06:37PM +0000, Anatoly Burakov wrote:
Currently, the VA space limits placed on DPDK memory are only informed by
the default configuration coming from `rte_config.h` file. Add an EAL flag
to specify per-page size memory limits explicitly, thereby overriding the
default VA space reservations.

Signed-off-by: Anatoly Burakov <[email protected]>
---
Acked-by: Bruce Richardson <[email protected]>


Hi Bruce,

+static int
+eal_parse_pagesz_mem(char *strval, struct internal_config *internal_cfg)
+{
+       char strval_cpy[1024];
+       char *fields[3];
+       char *pagesz_str, *mem_str;
+       int arg_num;
+       int len;
+       unsigned int i;
+       uint64_t pagesz, mem_limit;
+       struct pagesz_mem_override *pmo;
+
+       len = strnlen(strval, 1024);
+       if (len >= 1024) {
+               EAL_LOG(ERR, "--pagesz-mem parameter is too long");
+               return -1;
+       }
+
+       rte_strlcpy(strval_cpy, strval, sizeof(strval_cpy));
+
+       /* parse exactly one pagesz:mem pair per --pagesz-mem option */
+       arg_num = rte_strsplit(strval_cpy, len, fields, RTE_DIM(fields), ':');
+       if (arg_num != 2 || fields[0][0] == '\0' || fields[1][0] == '\0') {
+               EAL_LOG(ERR, "--pagesz-mem parameter format is invalid, expected 
<pagesz>:<limit>");
+               return -1;
+       }
+       pagesz_str = fields[0];
+       mem_str = fields[1];
+
+       /* reject accidental multiple pairs in one option */
+       if (strchr(mem_str, ',') != NULL) {
+               EAL_LOG(ERR, "--pagesz-mem accepts one <pagesz>:<limit> pair per 
option");
+               return -1;
+       }

If multiple options are given, then the rte_strsplit should return >2 when
splitting on ":". I'd suggest checking for the comma first, before even
doing the strlcpy.

+
+       /* parse page size */
+       errno = 0;
+       pagesz = rte_str_to_size(pagesz_str);
+       if (pagesz == 0 || errno != 0) {
+               EAL_LOG(ERR, "invalid page size in --pagesz-mem: '%s'", 
pagesz_str);
+               return -1;
+       }
+       if (!rte_is_power_of_2(pagesz)) {
+               EAL_LOG(ERR, "invalid page size in --pagesz-mem: '%s' (must be a 
power of two)",
+                       pagesz_str);
+               return -1;
+       }
+
+       /* parse memory limit (0 is valid: disables allocation for this page 
size) */
+       errno = 0;
+       mem_limit = rte_str_to_size(mem_str);
+       if (errno != 0) {
+               EAL_LOG(ERR, "invalid memory limit in --pagesz-mem: '%s'", 
mem_str);
+               return -1;
+       }
+
+       /* validate alignment: memory limit must be divisible by page size */
+       if (mem_limit % pagesz != 0) {
+               EAL_LOG(ERR, "--pagesz-mem memory limit must be aligned to page 
size");
+               return -1;
+       }
+
+       for (i = 0; i < internal_cfg->num_pagesz_mem_overrides; i++) {
+               pmo = &internal_cfg->pagesz_mem_overrides[i];
+               if (pmo->pagesz != pagesz)
+                       continue;
+
+               EAL_LOG(WARNING,
+                       "--pagesz-mem specified multiple times for page size '%s'; 
later limit '%s' will be used",
+                       pagesz_str, mem_str);
+               pmo->limit = mem_limit;
+               return 0;

Rather than just warning, I'd make this a hard error and say you can't
duplicate the hugepage limits on commandline. Saves confusion when
examining a commandline, having to check if a value is overridden later.

Apologies, missed these comments in v3, will resubmit a v4.

--
Thanks,
Anatoly

Reply via email to