cmdline: configure input buffer size

Message ID 20240501052659.231457-1-getelson@nvidia.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series cmdline: configure input buffer size |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional fail Functional Testing issues

Commit Message

Gregory Etelson May 1, 2024, 5:26 a.m. UTC
  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' ...`

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 lib/cmdline/cmdline_private.h | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Bruce Richardson May 1, 2024, 9:08 a.m. UTC | #1
On Wed, May 01, 2024 at 08:26:59AM +0300, Gregory Etelson wrote:
> 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' ...`
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
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
  
Gregory Etelson May 1, 2024, 10:06 a.m. UTC | #2
Hello Bruce,

>> Application can set custom cmdline size during DPDK configuration:
>>
>> `meson setup ... -Dc_args='-DRDLINE_CUSTOM_BUF_SIZE=4096' ...`
>>
>> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>> ---
> 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
  
Stephen Hemminger May 1, 2024, 2:42 p.m. UTC | #3
On Wed, 1 May 2024 13:06:47 +0300 (IDT)
"Etelson, Gregory" <getelson@nvidia.com> wrote:

> > 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


The buffer is transient so should have little impact.
Why not just use LINE_MAX from limits.h?
  
Gregory Etelson May 1, 2024, 3:56 p.m. UTC | #4
Hello Stephen,

>>> 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
>
>
> 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
  
Bruce Richardson May 1, 2024, 4:30 p.m. UTC | #5
On Wed, May 01, 2024 at 06:56:37PM +0300, Etelson, Gregory wrote:
> Hello Stephen,
> 
> > > > 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
> > 
> > 
> > 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.
  

Patch

diff --git a/lib/cmdline/cmdline_private.h b/lib/cmdline/cmdline_private.h
index b64f363903..7908d963f9 100644
--- a/lib/cmdline/cmdline_private.h
+++ b/lib/cmdline/cmdline_private.h
@@ -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