mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Kernel+lsirq: Track per-CPU IRQ handler call counts
Each GenericInterruptHandler now tracks the number of calls that each CPU has serviced. This takes care of a FIXME in the /sys/kernel/interrupts generator. Also, the lsirq command line tool now displays per-CPU call counts.
This commit is contained in:
parent
94b514b981
commit
fb00d3ed25
Notes:
sideshowbarker
2024-07-17 07:14:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fb00d3ed25 Pull-request: https://github.com/SerenityOS/serenity/pull/16113 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/supercomputer7 ✅
4 changed files with 33 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -34,9 +35,12 @@ ErrorOr<void> SysFSInterrupts::try_generate(KBufferBuilder& builder)
|
|||
TRY(obj.add("purpose"sv, handler.purpose()));
|
||||
TRY(obj.add("interrupt_line"sv, handler.interrupt_number()));
|
||||
TRY(obj.add("controller"sv, handler.controller()));
|
||||
TRY(obj.add("cpu_handler"sv, 0)); // FIXME: Determine the responsible CPU for each interrupt handler.
|
||||
TRY(obj.add("device_sharing"sv, (unsigned)handler.sharing_devices_count()));
|
||||
TRY(obj.add("call_count"sv, handler.call_count()));
|
||||
auto per_cpu_call_counts = TRY(obj.add_array("per_cpu_call_counts"sv));
|
||||
for (auto call_count : handler.per_cpu_call_counts()) {
|
||||
TRY(per_cpu_call_counts.add(call_count));
|
||||
}
|
||||
TRY(per_cpu_call_counts.finish());
|
||||
TRY(obj.finish());
|
||||
return {};
|
||||
})();
|
||||
|
|
|
@ -67,9 +67,14 @@ void GenericInterruptHandler::change_interrupt_number(u8 number)
|
|||
register_generic_interrupt_handler(InterruptManagement::acquire_mapped_interrupt_number(interrupt_number()), *this);
|
||||
}
|
||||
|
||||
Span<u32 const> GenericInterruptHandler::per_cpu_call_counts() const
|
||||
{
|
||||
return m_per_cpu_call_counts.span().slice(0, Processor::count());
|
||||
}
|
||||
|
||||
void GenericInterruptHandler::increment_call_count()
|
||||
{
|
||||
++m_call_count;
|
||||
++m_per_cpu_call_counts[Processor::current_id()];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
u8 interrupt_number() const { return m_interrupt_number; }
|
||||
|
||||
u32 call_count() const { return m_call_count; }
|
||||
Span<u32 const> per_cpu_call_counts() const;
|
||||
|
||||
virtual size_t sharing_devices_count() const = 0;
|
||||
virtual bool is_shared_handler() const = 0;
|
||||
|
@ -57,7 +57,8 @@ protected:
|
|||
void disable_remap() { m_disable_remap = true; }
|
||||
|
||||
private:
|
||||
Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_call_count { 0 };
|
||||
Array<u32, MAX_CPU_COUNT> m_per_cpu_call_counts {};
|
||||
|
||||
u8 m_interrupt_number { 0 };
|
||||
bool m_disable_remap { false };
|
||||
bool m_registered { false };
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -20,17 +21,30 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
outln(" CPU0");
|
||||
auto file_contents = proc_interrupts->read_all();
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
json.as_array().for_each([](auto& value) {
|
||||
|
||||
auto cpu_count = json.as_array().at(0).as_object().get("per_cpu_call_counts"sv).as_array().size();
|
||||
|
||||
out(" "sv);
|
||||
for (size_t i = 0; i < cpu_count; ++i) {
|
||||
out("{:>10}", String::formatted("CPU{}", i));
|
||||
}
|
||||
outln("");
|
||||
|
||||
json.as_array().for_each([cpu_count](JsonValue const& value) {
|
||||
auto& handler = value.as_object();
|
||||
auto purpose = handler.get("purpose"sv).to_string();
|
||||
auto interrupt = handler.get("interrupt_line"sv).to_string();
|
||||
auto controller = handler.get("controller"sv).to_string();
|
||||
auto call_count = handler.get("call_count"sv).to_string();
|
||||
auto call_counts = handler.get("per_cpu_call_counts"sv).as_array();
|
||||
|
||||
outln("{:>4}: {:10} {:10} {:30}", interrupt, call_count, controller, purpose);
|
||||
out("{:>4}: ", interrupt);
|
||||
|
||||
for (size_t i = 0; i < cpu_count; ++i)
|
||||
out("{:>10}", call_counts[i].to_string());
|
||||
|
||||
outln(" {:10} {:30}", controller, purpose);
|
||||
});
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue