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

Fix broken kernel tracing in presence of offline CPUs #1849

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

shoffmeister
Copy link
Contributor

@shoffmeister shoffmeister commented Nov 24, 2023

Offline CPUs may be encountered in a number of scenarios, for instance in the presence of virtualization through VMware Workstation, where the product advertises 128 CPUs as present, but then only makes a (configurable) subset of these available and online for use.

Fixes #1846

@shoffmeister shoffmeister force-pushed the bugfix/1846_offline-cpu branch from 0772e53 to f27da39 Compare November 24, 2023 21:17
@shoffmeister
Copy link
Contributor Author

With the PR merged,

sudo ./uftrace record -P --logfile=uftrace.log --auto-args --nest-libcall --kernel --libname --libmcount-path=/usr/lib/uftrace ls

will produce kernel trace output (note the hard-coded path to libmcount, I am running this from the build environment)

utils/kernel.c Outdated Show resolved Hide resolved
@shoffmeister shoffmeister force-pushed the bugfix/1846_offline-cpu branch from f27da39 to 8d88be5 Compare November 28, 2023 19:02
Copy link
Owner

@namhyung namhyung left a comment

Choose a reason for hiding this comment

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

LGTM

utils/kernel.c Outdated
@@ -615,10 +615,10 @@ int record_kernel_trace_pipe(struct uftrace_kernel_writer *kernel, int cpu, int
if (n < 0) {
if (errno == EINTR)
goto retry;
if (errno == EAGAIN)
if ((errno == EAGAIN) || (errno == ENODEV))
Copy link
Contributor

@bernhardkaindl bernhardkaindl Dec 5, 2023

Choose a reason for hiding this comment

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

@shoffmeister @honggyukim
There is no need (and it's not usual) to add the extra braces around == because it precedence and order of evaluation comes before the logical or ||:

Suggested change
if ((errno == EAGAIN) || (errno == ENODEV))
if (errno == EAGAIN || errno == ENODEV)

A detailed reference: https://learn.microsoft.com/en-us/cpp/c-language/precedence-and-order-of-evaluation?view=msvc-170

Otherwise, LGTM.

If @shoffmeister did not deny maintainer write access, uftrace maintainers should be able to apply my suggestion by clicking the button "commit suggestion".

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, cool. I didn't notice this feature. Yes I prefer no parenthesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the redundant brackets and force pushed for a simple commit history.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks the brackets are still there. Please check again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, sorry + fixed!

@shoffmeister shoffmeister force-pushed the bugfix/1846_offline-cpu branch from 8d88be5 to e303d86 Compare December 6, 2023 06:52
Offline CPUs may be encountered in a number of scenarios, for instance
in the presence of virtualization through VMware Workstation, where the
product advertises 128 CPUs as present, but then only makes a
(configurable) subset of these available and online for use.

Signed-off-by: Stefan Hoffmeister <stefan.hoffmeister@econos.de>
@shoffmeister shoffmeister force-pushed the bugfix/1846_offline-cpu branch from e303d86 to 8f68eb3 Compare December 7, 2023 05:42
@namhyung namhyung merged commit 4213eb7 into namhyung:master Dec 7, 2023
3 checks passed
@shoffmeister shoffmeister deleted the bugfix/1846_offline-cpu branch December 7, 2023 09:23
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.

"WARN: record kernel data (cpu 16) failed: No such device"
4 participants