[PATCH net-next v2 4/4] netconsole: Increase MAX_USERDATA_ITEMS

Gustavo Luiz Duarte posted 4 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH net-next v2 4/4] netconsole: Increase MAX_USERDATA_ITEMS
Posted by Gustavo Luiz Duarte 2 months, 3 weeks ago
Increase MAX_USERDATA_ITEMS from 16 to 256 entries now that the userdata
buffer is allocated dynamically.

The previous limit of 16 was necessary because the buffer was statically
allocated for all targets. With dynamic allocation, we can support more
entries without wasting memory on targets that don't use userdata.

This allows users to attach more metadata to their netconsole messages,
which is useful for complex debugging and logging scenarios.

Also update the testcase accordingly.

Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
---
 drivers/net/netconsole.c                                | 2 +-
 tools/testing/selftests/drivers/net/netcons_overflow.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 12fbc303a8240..36ce19936fa39 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
 /* The number 3 comes from userdata entry format characters (' ', '=', '\n') */
 #define MAX_EXTRADATA_NAME_LEN		(MAX_EXTRADATA_ENTRY_LEN - \
 					MAX_EXTRADATA_VALUE_LEN - 3)
-#define MAX_USERDATA_ITEMS		16
+#define MAX_USERDATA_ITEMS		256
 #define MAX_PRINT_CHUNK			1000
 
 static char config[MAX_PARAM_LENGTH];
diff --git a/tools/testing/selftests/drivers/net/netcons_overflow.sh b/tools/testing/selftests/drivers/net/netcons_overflow.sh
index 29bad56448a24..06089643b7716 100755
--- a/tools/testing/selftests/drivers/net/netcons_overflow.sh
+++ b/tools/testing/selftests/drivers/net/netcons_overflow.sh
@@ -15,7 +15,7 @@ SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
 
 source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh
 # This is coming from netconsole code. Check for it in drivers/net/netconsole.c
-MAX_USERDATA_ITEMS=16
+MAX_USERDATA_ITEMS=256
 
 # Function to create userdata entries
 function create_userdata_max_entries() {

-- 
2.47.3
Re: [PATCH net-next v2 4/4] netconsole: Increase MAX_USERDATA_ITEMS
Posted by Breno Leitao 2 months, 3 weeks ago
On Thu, Nov 13, 2025 at 08:42:21AM -0800, Gustavo Luiz Duarte wrote:
> Increase MAX_USERDATA_ITEMS from 16 to 256 entries now that the userdata
> buffer is allocated dynamically.
> 
> The previous limit of 16 was necessary because the buffer was statically
> allocated for all targets. With dynamic allocation, we can support more
> entries without wasting memory on targets that don't use userdata.
> 
> This allows users to attach more metadata to their netconsole messages,
> which is useful for complex debugging and logging scenarios.
> 
> Also update the testcase accordingly.
> 
> Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>

Reviewed-by: Breno Leitao <leitao@debian.org>

Please expand netcons_fragmented_msg.sh selftest to have ~100 userdata,
so, we can exercise this code in NIPA.

Thanks for all this patchset and improving netconsole!
--breno
Re: [PATCH net-next v2 4/4] netconsole: Increase MAX_USERDATA_ITEMS
Posted by Gustavo Luiz Duarte 2 months, 3 weeks ago
On Fri, Nov 14, 2025 at 1:07 PM Breno Leitao <leitao@debian.org> wrote:
>
> On Thu, Nov 13, 2025 at 08:42:21AM -0800, Gustavo Luiz Duarte wrote:
> > Increase MAX_USERDATA_ITEMS from 16 to 256 entries now that the userdata
> > buffer is allocated dynamically.
> >
> > The previous limit of 16 was necessary because the buffer was statically
> > allocated for all targets. With dynamic allocation, we can support more
> > entries without wasting memory on targets that don't use userdata.
> >
> > This allows users to attach more metadata to their netconsole messages,
> > which is useful for complex debugging and logging scenarios.
> >
> > Also update the testcase accordingly.
> >
> > Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
>
> Reviewed-by: Breno Leitao <leitao@debian.org>
>
> Please expand netcons_fragmented_msg.sh selftest to have ~100 userdata,
> so, we can exercise this code in NIPA.

I had a quick look and netcons_fragmented_msg.sh needs some
refactoring to be more reliable before I can do this. I will send this
as a separate patch set.