Skip to content

Commit

Permalink
Test for debugfs when specifying tracepoint dependent options,
Browse files Browse the repository at this point in the history
print [CPUS 0-0] as [CPU 0]
  • Loading branch information
cvonelm committed Jan 24, 2025
1 parent 7aa7beb commit 073cdc8
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ static inline void print_availability(std::ostream& os, const std::string& descr
else if (ev.availability() == perf::Availability::SYSTEM_MODE)
{
availability = " #";
}
if (ev.supported_cpus() != Topology::instance().cpus())
{
const auto& cpus = ev.supported_cpus();
cpu =
fmt::format(" [ CPUs {}-{} ]", std::min_element(cpus.begin(), cpus.end())->as_int(),
std::max_element(cpus.begin(), cpus.end())->as_int());
if (ev.supported_cpus() != Topology::instance().cpus())
{
const auto& cpus = ev.supported_cpus();
if (cpus.size() == 1)
{
cpu = fmt::format(" [ CPU {} ]", cpus.begin()->as_int());
}
else
{
cpu = fmt::format(" [ CPUs {}-{} ]",
std::min_element(cpus.begin(), cpus.end())->as_int(),
std::max_element(cpus.begin(), cpus.end())->as_int());
}
}
}

event_names.push_back(ev.name() + availability + cpu);
Expand Down Expand Up @@ -425,6 +432,26 @@ void parse_program_options(int argc, const char** argv)
std::exit(EXIT_SUCCESS);
}

if (!arguments.get_all("tracepoint").empty() || arguments.given("block-io") ||
!arguments.get_all("syscall").empty())
{
try
{
if (!std::filesystem::exists("/sys/kernel/debug/tracing"))
{
Log::error() << "syscall, block-io and tracepoint recording require access to "
"/sys/kernel/debug/tracing, make sure it exists and is accessible";
std::exit(EXIT_FAILURE);
}
}
catch (std::filesystem::filesystem_error&)
{
Log::error() << "syscall, block-io and tracepoint recording require access to "
"/sys/kernel/debug/tracing, make sure it exists and is accessible";
std::exit(EXIT_FAILURE);
}
}

if (arguments.given("quiet") && arguments.given("verbose"))
{
lo2s::Log::warn() << "Cannot be quiet and verbose at the same time. Refusing to be quiet.";
Expand Down

0 comments on commit 073cdc8

Please sign in to comment.