Skip to contentSkip to conversation

cmdline: configure input buffer size

PATCH Superseded Gregory Etelson 5 participants 12 messages May 1, 2024 – Jun 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmdline: configure input buffer size

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```

The patch introduces conditional RDLINE_CUSTOM_BUF_SIZE definition. Application can set custom cmdline size during DPDK configuration:

meson setup ... -Dc_args='-DRDLINE_CUSTOM_BUF_SIZE=4096' ...

---
 lib/cmdline/cmdline_private.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/cmdline/cmdline_private.h +4 -0
index b64f363903..7908d963f9 100644
@@ -17,7 +17,11 @@
 
 #include <cmdline.h>
 
+#ifndef RDLINE_CUSTOM_BUF_SIZE
 #define RDLINE_BUF_SIZE 512
+#else
+#define RDLINE_BUF_SIZE RDLINE_CUSTOM_BUF_SIZE
+#endif
 #define RDLINE_PROMPT_SIZE  32
 #define RDLINE_VT100_BUF_SIZE  8
 #define RDLINE_HISTORY_BUF_SIZE BUFSIZ
Signature · 1 line
2.43.0
#1 lore raw
Quoted 16 lines · Gregory Etelson

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```
Quoted 7 lines

The patch introduces conditional RDLINE_CUSTOM_BUF_SIZE definition. Application can set custom cmdline size during DPDK configuration:

meson setup ... -Dc_args='-DRDLINE_CUSTOM_BUF_SIZE=4096' ...

---

Basic question, what would be the impact of increasing the default from 512 to 1k or 2k? Do we get a large memory footprint increase, or is it just an extra 1 or 2k of memory used?

/Bruce

#2 lore raw

Hello Bruce,

Quoted 4 lines
Quoted 4 lines

Application can set custom cmdline size during DPDK configuration:

meson setup ... -Dc_args='-DRDLINE_CUSTOM_BUF_SIZE=4096' ...

Quoted 8 lines
Quoted 2 lines

---

Basic question, what would be the impact of increasing the default from 512 to 1k or 2k? Do we get a large memory footprint increase, or is it just an extra 1 or 2k of memory used?

/Bruce

Increasing the RDLINE_BUF_SIZE size will also increase application memory usage.
However, that memory increase was required, because application could not fit it's command line into the default buffer.

Applications that can run with the default RDLINE_BUF_SIZE are not affected by that patch.

Regards,
Gregory

#3 lore raw
Quoted 11 lines · Gregory
Quoted 6 lines

Basic question, what would be the impact of increasing the default from 512 to 1k or 2k? Do we get a large memory footprint increase, or is it just an extra 1 or 2k of memory used?

/Bruce

Increasing the RDLINE_BUF_SIZE size will also increase application memory usage. However, that memory increase was required, because application could not fit it's command line into the default buffer.

Quoted 5 lines

Applications that can run with the default RDLINE_BUF_SIZE are not affected by that patch.

Regards,
Gregory

The buffer is transient so should have little impact. Why not just use LINE_MAX from limits.h?

#4 lore raw

Hello Stephen,

Quoted 14 lines
Quoted 14 lines
Quoted 6 lines

Basic question, what would be the impact of increasing the default from 512 to 1k or 2k? Do we get a large memory footprint increase, or is it just an extra 1 or 2k of memory used?

/Bruce

Increasing the RDLINE_BUF_SIZE size will also increase application memory usage. However, that memory increase was required, because application could not fit it's command line into the default buffer.

Applications that can run with the default RDLINE_BUF_SIZE are not affected by that patch.

Quoted 7 lines
Quoted 2 lines

Regards,
Gregory

The buffer is transient so should have little impact. Why not just use LINE_MAX from limits.h?

The LINE_MAX value will be enough even for the template API testpmd commands. If there will be no objections, I'll set LINE_MAX as the new RDLINE_BUF_SIZE.

Regards,
Gregory

#5 lore raw
Quoted 20 lines · Gregory

Hello Stephen,

Quoted 18 lines
Quoted 16 lines
Quoted 6 lines

Basic question, what would be the impact of increasing the default from 512 to 1k or 2k? Do we get a large memory footprint increase, or is it just an extra 1 or 2k of memory used?

/Bruce

Increasing the RDLINE_BUF_SIZE size will also increase application memory usage. However, that memory increase was required, because application could not fit it's command line into the default buffer.

Applications that can run with the default RDLINE_BUF_SIZE are not affected by that patch.

Regards,
Gregory

Quoted 8 lines
Quoted 3 lines

The buffer is transient so should have little impact. Why not just use LINE_MAX from limits.h?

The LINE_MAX value will be enough even for the template API testpmd commands. If there will be no objections, I'll set LINE_MAX as the new RDLINE_BUF_SIZE.

+1 for just upping the size.
Thanks.

#6 lore raw

PATCH v2 1/1 cmdline: increase input buffer size

In reply to Gregory Etelson

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```

The patch increases cmdline input buffer size to the LINE_MAX value.

---
v2: set RDLINE_BUF_SIZE to LINE_MAX
change the patch subject

---
 lib/cmdline/cmdline_private.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cmdline/cmdline_private.h +1 -1
index b64f363903..3d0168ce03 100644
@@ -17,7 +17,7 @@
 
 #include <cmdline.h>
 
-#define RDLINE_BUF_SIZE 512
+#define RDLINE_BUF_SIZE LINE_MAX
 #define RDLINE_PROMPT_SIZE  32
 #define RDLINE_VT100_BUF_SIZE  8
 #define RDLINE_HISTORY_BUF_SIZE BUFSIZ

--
2.43.0

Reviewed-by on v2 1/1
#7 lore raw

RE: [PATCH v2] cmdline: increase input buffer size

+CC: Bruce, Stephen

Quoted 19 lines

From: Gregory Etelson [mailto:[email protected]]
Sent: Wednesday, 1 May 2024 19.18

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```
Quoted 1 line

The patch increases cmdline input buffer size to the LINE_MAX value.

+ ... , which typically is 2048.

Quoted 3 lines

---

With or without suggested patch description change,

#8 lore raw

Re: [PATCH v2] cmdline: increase input buffer size

Quoted 23 lines · Morten Brørup

+CC: Bruce, Stephen

Quoted 19 lines

From: Gregory Etelson [mailto:[email protected]]
Sent: Wednesday, 1 May 2024 19.18

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```
Quoted 1 line

The patch increases cmdline input buffer size to the LINE_MAX value.

Quoted 9 lines

+ ... , which typically is 2048.

Quoted 3 lines

---

With or without suggested patch description change,

#9 lore raw

PATCH v3 1/1 cmdline: increase input buffer size

In reply to Gregory Etelson

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```

The patch increases cmdline input buffer size to the LINE_MAX value, which typically is 2048 bytes.

---
v2: set RDLINE_BUF_SIZE to LINE_MAX
change the patch subject.
v3: fix Windows compilation error.

---
 lib/cmdline/cmdline_private.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/cmdline/cmdline_private.h +8 -1
index b64f363903..f00b025ecb 100644
@@ -11,13 +11,20 @@
 #include <rte_os_shim.h>
 #ifdef RTE_EXEC_ENV_WINDOWS
 #include <rte_windows.h>
+#ifndef LINE_MAX
+/**
+ * The LINE_MAX value is derived from POSIX.
+ * Windows environment may not have POSIX definitions.
+ */
+#define LINE_MAX 2048
+#endif
 #else
 #include <termios.h>
 #endif
 
 #include <cmdline.h>
 
-#define RDLINE_BUF_SIZE 512
+#define RDLINE_BUF_SIZE LINE_MAX
 #define RDLINE_PROMPT_SIZE  32
 #define RDLINE_VT100_BUF_SIZE  8
 #define RDLINE_HISTORY_BUF_SIZE BUFSIZ
Signature · 1 line
2.43.0
author Acked-by Bruce Richardson Reviewed-by Morten Brørup on v3 1/1
#10 lore raw

Re: [PATCH v3] cmdline: increase input buffer size

Hello,

What is the status of that patch ?

Regards,
Gregory
________________________________
From: Gregory Etelson <[email protected]>
Sent: Friday, May 3, 2024 07:27
To: Gregory Etelson <[email protected]>
Cc: Ali Alnubani <[email protected]>; [email protected] <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH v3] cmdline: increase input buffer size

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```

The patch increases cmdline input buffer size to the LINE_MAX value, which typically is 2048 bytes.

---
v2: set RDLINE_BUF_SIZE to LINE_MAX
change the patch subject.
v3: fix Windows compilation error.

---
 lib/cmdline/cmdline_private.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/cmdline/cmdline_private.h +8 -1
index b64f363903..f00b025ecb 100644
@@ -11,13 +11,20 @@
 #include <rte_os_shim.h>
 #ifdef RTE_EXEC_ENV_WINDOWS
 #include <rte_windows.h>
+#ifndef LINE_MAX
+/**
+ * The LINE_MAX value is derived from POSIX.
+ * Windows environment may not have POSIX definitions.
+ */
+#define LINE_MAX 2048
+#endif
 #else
 #include <termios.h>
 #endif
 
 #include <cmdline.h>
 
-#define RDLINE_BUF_SIZE 512
+#define RDLINE_BUF_SIZE LINE_MAX
 #define RDLINE_PROMPT_SIZE  32
 #define RDLINE_VT100_BUF_SIZE  8
 #define RDLINE_HISTORY_BUF_SIZE BUFSIZ

--
2.43.0

#11 lore raw

Re: [PATCH v3] cmdline: increase input buffer size

In reply to Gregory Etelson
Quoted 17 lines · Gregory Etelson

DPDK defines cmdline input buffer size to 512 characters. That buffer size can be too small for long application input. For example, the following flow template API testpmd command is 444 bytes long:

```
flow queue 0 create 0 template_table 1000 \
  pattern_template 0 actions_template 0 postpone no \
  pattern eth / ipv4 / udp / end \
  actions modify_field op set dst_type tag dst_level 0 dst_offset 0 \
    src_type value src_value 0x31 width 32 /  \
    modify_field op set dst_type ipv4_src src_type value \
    src_value 10101010 width 32 / modify_field op add dst_type \
    ipv4_ttl dst_level 0 dst_offset 0 src_type value \
    src_value ff width 8 / count / jump group 100 / end
```
Quoted 6 lines

The patch increases cmdline input buffer size to the LINE_MAX value, which typically is 2048 bytes.

Applied, thanks.

Signature · 1 line
David Marchand