Skip to contentSkip to conversation

There is a big risk in function bufferlist::claim_prepend()

DISCUSSION kefu chai 2 participants 2 messages Sep 18, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

kefu chai

author
#1 lore raw
Quoted 9 lines · 关云飞

hello kefu chai,

These two days I carefully considered the pr https://github.com/ceph/ceph/pull/17661 and looked the code about bufferlist and I still think the steps of 1-3 is needed. Although the ptr::_off can guarantee bufferlist to be copied/read/decode/write_file rightly, this will lead a bufferlist not clean and will waste memory like picture below.

Of course, it's also possible that i am not thinking about it, do you have any suggestions?

i think it's the user of the bufferlist's choice to defrag the element(s) in it or not. and it's not a pure win: it hurts the performance in some cases. in the case of PR#17661, we are trying to realloc a smaller mem chunk to replace the first memory ptr with it, if it has "bubbles". what about the second element, or the third one in the buffer::list, shall we also take care of them as well?

Signature · 2 lines
Regards
Kefu Chai
#2 lore raw

I agree with that point that would hurts the performance and i removed the step of 1-3, please help to review.
But the kind of situation you said should not appear.
If we realloc a mem chunk to replace the first memory ptr with it when do claim_prepend every time the ptr of bufferslit will not exist bubbles except for the first ptr.

2017-09-18 16:57 GMT+08:00 kefu chai <[email protected]>:

Quoted 25 lines · 关云飞
Quoted 9 lines

hello kefu chai,

These two days I carefully considered the pr https://github.com/ceph/ceph/pull/17661 and looked the code about bufferlist and I still think the steps of 1-3 is needed. Although the ptr::_off can guarantee bufferlist to be copied/read/decode/write_file rightly, this will lead a bufferlist not clean and will waste memory like picture below.

Of course, it's also possible that i am not thinking about it, do you have any suggestions?

i think it's the user of the bufferlist's choice to defrag the element(s) in it or not. and it's not a pure win: it hurts the performance in some cases. in the case of PR#17661, we are trying to realloc a smaller mem chunk to replace the first memory ptr with it, if it has "bubbles". what about the second element, or the third one in the buffer::list, shall we also take care of them as well?

--
Regards
Kefu Chai
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html