Skip to contentSkip to conversation

event tracing, ringbuffer and RB_MAX_SMALL_DATA

DISCUSSION Johannes Berg 3 participants 7 messages Jul 14, 2009 – Jul 21, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

By code inspection, I think there's a bug if your event contains only

__dynamic_array(u8, buf, buflen)

and your buflen is only, say, 3. Then the event size will be the common event size (12 bytes) plus this, so 15, which is well below RB_MAX_SMALL_DATA (4*28 = 112), so it'll be divided by four to be stored into type_len. At this point, however, you've lost the information that your dynamic array was only three bytes, and it'll be considered _four_ bytes long by parsers as far as I can tell?

johannes

#1 lore raw
Quoted 4 lines · Johannes Berg

Hi,

By code inspection, I think there's a bug if your event contains only

Quoted 9 lines

__dynamic_array(u8, buf, buflen)

and your buflen is only, say, 3. Then the event size will be the common event size (12 bytes) plus this, so 15, which is well below RB_MAX_SMALL_DATA (4*28 = 112), so it'll be divided by four to be stored into type_len. At this point, however, you've lost the information that your dynamic array was only three bytes, and it'll be considered _four_ bytes long by parsers as far as I can tell?

Right, the length of a dynamic array is not recorded, and this causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a patch today or tomorrow.

#2 lore raw
Quoted 8 lines · Li Zefan

Right, the length of a dynamic array is not recorded, and this causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a patch today or tomorrow.

Well except for the corner case I pointed out, you can determine the length of dynamic arrays by either
- the next dynamic array's offset or
- the length of the item.

So, afaict, the simplest solution would be to not embed the length of the item in type_len if it's not divisible by four and contains dynamic members, though the latter condition might be hard to check.

johannes

#3 lore raw
Quoted 11 lines · Johannes Berg
Quoted 8 lines · Li Zefan

Right, the length of a dynamic array is not recorded, and this causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a patch today or tomorrow.

Quoted 9 lines

Well except for the corner case I pointed out, you can determine the length of dynamic arrays by either
- the next dynamic array's offset or
- the length of the item.

So, afaict, the simplest solution would be to not embed the length of the item in type_len if it's not divisible by four and contains dynamic members, though the latter condition might be hard to check.

Actually I'm going to encode the size of a dynamic array in it's @offset, so the lower 16bits is offset and the higher 16bits is size.

#4 lore raw
Quoted 17 lines · Li Zefan
Quoted 16 lines · Johannes Berg
Quoted 8 lines · Li Zefan

Right, the length of a dynamic array is not recorded, and this causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a patch today or tomorrow.

Well except for the corner case I pointed out, you can determine the length of dynamic arrays by either
- the next dynamic array's offset or
- the length of the item.

Quoted 8 lines
Quoted 4 lines

So, afaict, the simplest solution would be to not embed the length of the item in type_len if it's not divisible by four and contains dynamic members, though the latter condition might be hard to check.

Actually I'm going to encode the size of a dynamic array in it's @offset, so the lower 16bits is offset and the higher 16bits is size.

Was there a patch sent out to do this yet, or is this still something being worked on?

Thanks,

-- Steve

#5 lore raw
Quoted 22 lines · Steven Rostedt
Quoted 20 lines · Li Zefan
Quoted 19 lines · Johannes Berg
Quoted 8 lines · Li Zefan

Right, the length of a dynamic array is not recorded, and this causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a patch today or tomorrow.

Well except for the corner case I pointed out, you can determine the length of dynamic arrays by either
- the next dynamic array's offset or
- the length of the item.

So, afaict, the simplest solution would be to not embed the length of the item in type_len if it's not divisible by four and contains dynamic members, though the latter condition might be hard to check.

Quoted 7 lines
Quoted 3 lines

Actually I'm going to encode the size of a dynamic array in it's @offset, so the lower 16bits is offset and the higher 16bits is size.

Was there a patch sent out to do this yet, or is this still something being worked on?

Haven't you pulled it as you said. ;)

http://lkml.org/lkml/2009/7/20/155

#6 lore raw
Quoted 8 lines · Li Zefan
Quoted 4 lines

Was there a patch sent out to do this yet, or is this still something being worked on?

Haven't you pulled it as you said. ;)

http://lkml.org/lkml/2009/7/20/155

Ah, in deed, I have them queued.

So many patches, so little time ;-)

Thanks!

-- Steve