buffer: separate the BufferFragement release and drain tracker#28770
buffer: separate the BufferFragement release and drain tracker#28770ggreenway merged 9 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
/wait I want to give a test with IoUring first. |
|
@KBaichoo @yanavlasov This should be ready for the review. I also tested this with #28824, it didn't see any fail related to using the BufferFragment. |
KBaichoo
left a comment
There was a problem hiding this comment.
/wait
would be awesome if we could have a reproduction in an integration test similar to what @roelfdutoit reported in #28760
cc @pianiststickman since this seems like a regression related to your change in #27499
source/common/buffer/buffer_impl.h
Outdated
| void transferDrainTrackersTo(Slice& destination) { | ||
| destination.drain_trackers_.splice(destination.drain_trackers_.end(), drain_trackers_); | ||
| ASSERT(drain_trackers_.empty()); | ||
| destination.releasor_.swap(releasor_); |
There was a problem hiding this comment.
what happens with the original releasor that the destination has? Is it fine to toss it as we're doing? ISTM that we don't need to do this especially as the only place transferDrainTrackersTo is called is when we copy the current slice into destination in coalesceOrAddSlice.
There was a problem hiding this comment.
yes, you are right, I shouldn't change releasor here.
I will look at how can I reproduce that in an integration test Thanks for the review! |
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
@KBaichoo I added the tests for UserSpace::IoHandle, would you like take a look this again? thanks in advance! |
|
/retest |
KBaichoo
left a comment
There was a problem hiding this comment.
Thanks for working on this
/wait
| ASSERT(drain_trackers_.empty()); | ||
| // The releasor needn't to be transferred, and actually if there is releasor, this | ||
| // slice can't coalesce. Then there won't be a chance to calling this method. | ||
| ASSERT(releasor_ == nullptr); |
There was a problem hiding this comment.
I might be missing something on my end but how can we guarantee no slice that we're transferring (copying) has no releasor?
There was a problem hiding this comment.
There is condition control that
envoy/source/common/buffer/buffer_impl.cc
Lines 298 to 303 in 782bb0c
The other_slice.canCoalesce() is false for the Slice created from BufferFragement.
envoy/source/common/buffer/buffer_impl.h
Lines 89 to 90 in 782bb0c
KBaichoo
left a comment
There was a problem hiding this comment.
/assign @ggreenway
For additional buffer expertise
| ASSERT(drain_trackers_.empty()); | ||
| // The releasor needn't to be transferred, and actually if there is releasor, this | ||
| // slice can't coalesce. Then there won't be a chance to calling this method. | ||
| ASSERT(releasor_ == nullptr); |
|
@ggreenway gentle ping :) |
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
/retest |
ggreenway
left a comment
There was a problem hiding this comment.
Sorry for the delay on this. It was marked waiting so it didn't show up my list.
/wait
source/common/buffer/buffer_impl.h
Outdated
| reservable_ = rhs.reservable_; | ||
| drain_trackers_ = std::move(rhs.drain_trackers_); | ||
| account_ = std::move(rhs.account_); | ||
| releasor_.swap(rhs.releasor_); |
There was a problem hiding this comment.
I don't think swap is correct in this case. Putting the old releasor into rhs is incorrect, isn't it?
There was a problem hiding this comment.
You are right, let me fix that
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
/retest |
no worries! I didn't pay attention on this recently also |
|
It seems stuck at DCO test. |
|
/retest |
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
/retest |
|
@ggreenway ci is passed, would you think it is ok to merge? |
…proxy#28770) Fixes envoyproxy#28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
…proxy#28770) Fixes envoyproxy#28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
…proxy#28770) Fixes envoyproxy#28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
…proxy#28770) Fixes envoyproxy#28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Fixes #28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Fixes #28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Fixes #28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Fixes #28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com>
…proxy#28770) Fixes envoyproxy#28760 Signed-off-by: He Jie Xu <hejie.xu@intel.com> Signed-off-by: Sean Killeen <SeanKilleen@gmail.com>
Commit Message: buffer: separate the BufferFragement release and drain tracker
Additional Description:
There is a requirement for the user space io handle and iouring io handle to move the write buffer to its own buffer and invoke the drain trackers. But becomes an issue for the BufferFragment, the BufferFragement's releasor is invoked by the drain tracker also. After moving with invoke drain trackers, the memory in the BufferFragment will be released too, which leads to the Buffer reference some memory already released.
Risk Level: high
Testing: unittest
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a
Fixes #28760
Related to issue: #28395