Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetragon: remove unnecessary GetProcessCopy() #1254

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

jrfastab
Copy link
Contributor

GetProcessCopy is required when we need to modify the Process info. This is done primarily to update the Tid to reflect the caller of a system call or kprobe.

Most other cases shouldn't need to get a fully copy of the process object. The reason a copy is needed in the modification case is to avoid having a writer updating the object while the GRPC stream handler or JSON writer are marshalling the data which can corrupt the streaming logic. This results in either broken messages in JSON export file or the GRPC stream failing.

GetProcessCopy is required when we need to modify the Process info.
This is done primarily to update the Tid to reflect the caller of
a system call or kprobe.

Most other cases shouldn't need to get a fully copy of the process
object. The reason a copy is needed in the modification case is
to avoid having a writer updating the object while the GRPC
stream handler or JSON writer are marshalling the data which can
corrupt the streaming logic. This results in either broken messages
in JSON export file or the GRPC stream failing.

Signed-off-by: John Fastabend <[email protected]>
@jrfastab jrfastab requested a review from a team as a code owner July 19, 2023 22:59
@jrfastab jrfastab requested a review from tixxdz July 19, 2023 22:59
@netlify
Copy link

netlify bot commented Jul 19, 2023

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 536e66d
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/64b86ac3b139f90008280ddc
😎 Deploy Preview https://deploy-preview-1254--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

if !msg.RefCntDone[ProcessRefCnt] {
internal.RefDec()
msg.RefCntDone[ProcessRefCnt] = true
}
proc := internal.GetProcessCopy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep the copy in here? there's tid update on the next line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update this part so we just use the tid of the exec time or pid as tid, without doing this extra copy , and this code will just make it an assertion of what we get from bpf side...

For keeping the copy or do not evict from cache before we return the event, I have to check the code , no idea now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this patch I'll put that Copy() back so its correct. We can remove them with future solution.

Copy link
Member

@tixxdz tixxdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with that comment from @olsajiri fixed! fix is also here: 3fb668c

@jrfastab jrfastab force-pushed the pr/jrfastab/deepCopyRemove branch from 536e66d to 71fee44 Compare July 27, 2023 20:37
@jrfastab jrfastab merged commit d6cc2c3 into main Jul 27, 2023
@jrfastab jrfastab deleted the pr/jrfastab/deepCopyRemove branch July 27, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants