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

Avoid using runtime.NumCPU to get the number of CPUs on the system #680

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

RonFed
Copy link
Contributor

@RonFed RonFed commented Feb 19, 2024

runtime.NumCPU doc states:

NumCPU returns the number of logical CPUs usable by the current process

This is problematic when the probed process is configured to run on a subset of the available CPUs.
In addition, we perform the above call for the agent process, so even if the probed process has some configuration for this, we won't see it.
This PR replaces this call with querying the relevant files to get the number of CPUs available in the system.
Adding a boundary check in write_target_data to ensure that we are not writing to an un-mapped address if something goes wrong.

@RonFed RonFed added bug Something isn't working eBPF labels Feb 19, 2024
@RonFed RonFed marked this pull request as ready for review February 19, 2024 08:19
@RonFed RonFed requested a review from a team February 19, 2024 08:19
Copy link
Contributor

@edeNFed edeNFed left a comment

Choose a reason for hiding this comment

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

lgtm
great catch!

@edeNFed edeNFed merged commit 4d3bc06 into open-telemetry:main Feb 20, 2024
17 checks passed
@damemi damemi mentioned this pull request Mar 26, 2024
@MrAlias MrAlias added this to the v0.11.0-alpha milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working eBPF
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants