diff options
Diffstat (limited to 'rebalance_interrupts')
-rw-r--r-- | rebalance_interrupts/rebalance_interrupts.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/rebalance_interrupts/rebalance_interrupts.cpp b/rebalance_interrupts/rebalance_interrupts.cpp index b0d2f69e..77a0bfb0 100644 --- a/rebalance_interrupts/rebalance_interrupts.cpp +++ b/rebalance_interrupts/rebalance_interrupts.cpp @@ -224,6 +224,33 @@ bool RebalanceIrqs(const list<pair<string, list<string>>>& action_to_irqs) { return true; } +void ChownIrqAffinity() { + std::unique_ptr<DIR, decltype(&closedir)> irq_dir(opendir(PROC_IRQDIR), closedir); + if (!irq_dir) { + PLOG(ERROR) << "opening dir " PROC_IRQDIR; + return; + } + + struct dirent *entry; + while ((entry = readdir(irq_dir.get()))) { + // If the directory entry isn't a parsable number, skip it. + // . and .. get skipped here. + unsigned throwaway; + if (!ParseUint(entry->d_name, &throwaway)) + continue; + + string affinity_path(PROC_IRQDIR "/"); + affinity_path += entry->d_name; + affinity_path += "/smp_affinity"; + chown(affinity_path.c_str(), 1000, 1000); + + string affinity_list_path(PROC_IRQDIR "/"); + affinity_list_path += entry->d_name; + affinity_list_path += "/smp_affinity_list"; + chown(affinity_list_path.c_str(), 1000, 1000); + } +} + int main(int /* argc */, char* /* argv */[]) { map<string, list<string>> irq_mapping; list<pair<string, list<string>>> action_to_irqs; @@ -238,6 +265,10 @@ int main(int /* argc */, char* /* argv */[]) { return 1; } + // Change ownership of smp_affinity and smp_affinity_list handles + // from root to system. + ChownIrqAffinity(); + // Some IRQs are already assigned to a subset of cores, usually for // good reason (like some drivers have an IRQ per core, for per-core // queues.) Find the set of IRQs that haven't been mapped to specific |