On Thu, Nov 13, 2025 at 08:42:19AM -0800, Gustavo Luiz Duarte wrote:
> Separate userdata and sysdata into distinct buffers to enable independent
> management. Previously, both were stored in a single extradata_complete
> buffer with a fixed size that accommodated both types of data.
> 
> This separation allows:
> - userdata to grow dynamically (in subsequent patch)
> - sysdata to remain in a small static buffer
> - removal of complex entry counting logic that tracked both types together
> 
> The split also simplifies the code by eliminating the need to check total
> entry count across both userdata and sysdata when enabling features,
> which allows to drop holding su_mutex on sysdata_*_enabled_store().
> 
> No functional change in this patch, just structural preparation for
> dynamic userdata allocation.
> 
> Signed-off-by: Gustavo Luiz Duarte <[email protected]>

Reviewed-by: Breno Leitao <[email protected]>

<snip>
> @@ -1608,13 +1575,24 @@ static void send_fragmented_body(struct 
> netconsole_target *nt,
>               buf_offset += this_chunk;
>               data_sent += this_chunk;
>  
> -             /* after msgbody, append extradata */
> -             if (extradata_ptr && extradata_left) {
> -                     this_chunk = min(extradata_left,
> +             /* after msgbody, append userdata */
> +             if (userdata_ptr && userdata_left) {
> +                     this_chunk = min(userdata_left,
>                                        MAX_PRINT_CHUNK - buf_offset);
>                       memcpy(nt->buf + buf_offset,
> -                            extradata_ptr + extradata_offset, this_chunk);
> -                     extradata_offset += this_chunk;
> +                            userdata_ptr + userdata_offset, this_chunk);
> +                     userdata_offset += this_chunk;
> +                     buf_offset += this_chunk;
> +                     data_sent += this_chunk;
> +             }
> +
> +             /* after userdata, append sysdata */
> +             if (sysdata_ptr && sysdata_left) {
> +                     this_chunk = min(sysdata_left,
> +                                      MAX_PRINT_CHUNK - buf_offset);
> +                     memcpy(nt->buf + buf_offset,
> +                            sysdata_ptr + sysdata_offset, this_chunk);
> +                     sysdata_offset += this_chunk;

This seems all correct and improved, but, I would like to improve this a bit
better.

I would like to have a function to append_msg_body(), append_sysdata() and 
append_userdata(),
which is not possible today given these variables.

A possibility is to have a local "struct fat_buffer" that contains all these
pointers and offset, then we can pass the struct to these append_XXXXX(struct
fat_buffer *) in a row.

I envision something as:

        int buf_offset = 0;

        while (data_sent < data_len) {
                buf_offset += append_msgbody(&fat_buffer)
                buf_offset += append_sysdata(&fat_buffer)
                buf_offset += append_userdata(&fat_buffer)

                send_udp(nt, nt->buf, buf_offset);
        }

Not sure it will be possible to be as simple as  above, but, it will definitely
make review easier.

Just to be clear, this is not a request for this patch, but, something that I'd
love to have.

Reply via email to