forked from scylladb/seastar
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add scheduler group to cpu profiler #169
Merged
travisdowns
merged 3 commits into
redpanda-data:v25.1.x
from
travisdowns:td-sg-in-cpu-profile
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,13 @@ | |
* Copyright (C) 2023 ScyllaDB | ||
*/ | ||
|
||
#include <chrono> | ||
#include <optional> | ||
#include <random> | ||
#include <chrono> | ||
#include <optional> | ||
#include <random> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like wrong formatting to me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. silly clang format, it's trying to match the alignment of the comment above or somthing, will fix |
||
|
||
#include <seastar/core/internal/cpu_profiler.hh> | ||
#include <seastar/util/log.hh> | ||
#include <seastar/core/internal/cpu_profiler.hh> | ||
#include <seastar/core/scheduling.hh> | ||
#include <seastar/util/log.hh> | ||
|
||
namespace seastar { | ||
seastar::logger cpu_profiler_logger("cpu_profiler"); | ||
|
@@ -38,7 +39,7 @@ signal_mutex::guard::~guard() { | |
return; | ||
} | ||
// Ensure the subsequent store isn't hoisted by the the | ||
// compiler into the critical section it's intended to | ||
// compiler into the critical section it's intended to | ||
// protect. | ||
std::atomic_signal_fence(std::memory_order_release); | ||
_mutex->_mutex.store(false, std::memory_order_relaxed); | ||
|
@@ -52,7 +53,7 @@ std::optional<signal_mutex::guard> signal_mutex::try_lock() { | |
// by the compiler. | ||
std::atomic_signal_fence(std::memory_order_acq_rel); | ||
return {guard(this)}; | ||
} | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
|
@@ -100,7 +101,7 @@ void cpu_profiler::update_config(cpu_profiler_config cfg) { | |
auto is_stopped = _is_stopped; | ||
stop(); | ||
_cfg = cfg; | ||
// Don't start the profiler if it's been explicitly | ||
// Don't start the profiler if it's been explicitly | ||
// stopped elsewhere. | ||
if (!is_stopped) { | ||
start(); | ||
|
@@ -133,7 +134,7 @@ void cpu_profiler::on_signal() { | |
|
||
// During exception handling in libgcc there is a critical section | ||
// where the stack is being modified so execution can be returned to | ||
// a handler for the exception. This modification isn't capture by | ||
// a handler for the exception. This modification isn't capture by | ||
// the eh_frames for the program though. So when libgcc's backtrace | ||
// enters the partially modified stack it will follow invalid addresses | ||
// and cause a segfault. To avoid this we check if any exception | ||
|
@@ -160,6 +161,7 @@ void cpu_profiler::on_signal() { | |
} | ||
_traces.emplace_back(); | ||
_traces.back().user_backtrace = current_backtrace_tasklocal(); | ||
_traces.back().sg = current_scheduling_group(); | ||
|
||
auto kernel_bt = try_get_kernel_backtrace(); | ||
if (kernel_bt) { | ||
|
@@ -178,7 +180,7 @@ void cpu_profiler::on_signal() { | |
auto next = get_next_timeout(); | ||
arm_timer(next); | ||
} | ||
|
||
size_t cpu_profiler::results(std::vector<cpu_profiler_trace>& results_buffer) { | ||
// Since is this not called in the interrupt it should always succeed | ||
// in acquiring the lock. | ||
|
@@ -209,7 +211,7 @@ bool cpu_profiler_linux_perf_event::is_spurious_signal() { | |
return _perf_event.is_spurious_signal(); | ||
} | ||
|
||
std::optional<linux_perf_event::kernel_backtrace> | ||
std::optional<linux_perf_event::kernel_backtrace> | ||
cpu_profiler_linux_perf_event::try_get_kernel_backtrace() { | ||
return _perf_event.try_get_kernel_backtrace(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentence incomplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks will fix