From: Sven Schnelle <svens@linux.ibm.com>
To: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>, linux-s390@vger.kernel.org
Subject: Re: [PATCH] trace-cmd: fix writing of uncompressed size
Date: Mon, 11 Jul 2022 11:14:49 +0200 [thread overview]
Message-ID: <yt9d35f857ue.fsf@linux.ibm.com> (raw)
In-Reply-To: <CAPpZLN45rz5nTn-XixV_pozdxHQREZymP_Vp8PDQAPXRDwguXA@mail.gmail.com> (Tzvetomir Stoyanov's message of "Mon, 11 Jul 2022 11:55:34 +0300")
Tzvetomir Stoyanov <tz.stoyanov@gmail.com> writes:
> On Mon, Jul 11, 2022 at 10:44 AM Sven Schnelle <svens@linux.ibm.com> wrote:
>>
>> Pass &size instead of &handle->pointer. Interestingly this doesn't hurt
>> on x86, but makes trace-cmd fail on s390.
>
> Hi Sven,
> Thanks for testing this code on s390, I've tested it only on x86.
> Please, can you give more information about the trace-cmd failure on
> s390?
>
>>
>> Fixes: 3f8447b1 ("trace-cmd library: Add support for compression algorithms")
>> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
>> ---
>> lib/trace-cmd/trace-compress.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/trace-cmd/trace-compress.c b/lib/trace-cmd/trace-compress.c
>> index a63295e..ad9b7fc 100644
>> --- a/lib/trace-cmd/trace-compress.c
>> +++ b/lib/trace-cmd/trace-compress.c
>> @@ -331,7 +331,7 @@ int tracecmd_compress_block(struct tracecmd_compression *handle)
>> goto out;
>>
>> /* Write uncompressed data size */
>> - endian4 = tep_read_number(handle->tep, &handle->pointer, 4);
>> + endian4 = tep_read_number(handle->tep, &size, 4);
>
> Here 'size' is the size of the buffer, used by the compression
> algorithm to compress the data block. That size depends on the
> algorithm, but usually it is less than the uncompressed data size and
> bigger than the compressed data size. On this position in the file
> must be written the size of the uncompressed data, that is
> 'handle->pointer'. I agree that the name is a bit misleading, as this
> is not a pointer to a memory address. The 'handle->pointer' is the
> offset within the compression buffer, where the next uncompressed data
> will be written. The logic uses a dynamic buffer with given capacity.
> When the buffer is empty, 'handle->pointer' is 0. With each
> uncompressed data chunk, written into that buffer, 'handle->pointer'
> increases with its size - i.e. the first byte is written on position 0
> (the initial 'handle->pointer') and the pointer increases to 1. That's
> why it reflects the size of the uncompressed data. When the pointer
> reaches the capacity of the buffer, the buffer is extended. At the
> end, that buffer is passed to the compression algorithm, to compress
> the block.
I see that 'handle->pointer' is unsigned long, which is 8 bytes on
s390. But it is converted as 4 byte int. That would work on LE
platforms, but not on BE.
next prev parent reply other threads:[~2022-07-11 9:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 7:44 [PATCH] trace-cmd: fix writing of uncompressed size Sven Schnelle
2022-07-11 8:55 ` Tzvetomir Stoyanov
2022-07-11 9:06 ` Sven Schnelle
2022-07-11 9:14 ` Sven Schnelle [this message]
2022-07-11 9:25 ` Tzvetomir Stoyanov
2022-07-11 9:34 ` Sven Schnelle
-- strict thread matches above, loose matches on Subject: below --
2022-07-11 18:21 [PATCH] trace-cmd: Fix " Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yt9d35f857ue.fsf@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tz.stoyanov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).