IRQ hogging CPU czyli świński numer

Posted on Sun 07 June 2020 in Linux, Macbook

W jakimś, zupełnie nieuświadomionym, momencie czasowym mój Macbook zaczął dyszeć. To nie było rzężenie padającego dysku ale ewidetne obciążenie układu płuco-serce. Wiatraki szalały, prąd znikał, a obudowa wskazywała na stan wysokiej gorączki.

Uruchomienie top-a wykazało, że proces o proletariackiej nazwie kworker dosłownie pożera 60% czasu procesora. W nazwie procesu był jeszcze przyrostek: kacpid, co wskazywało na podsystem ACPI czyli zarządzanie energią. Nic mi to nie mówiło.

Internet podpowiedział mi, że chodzi o przerwania oraz fakt, że kworker zbyt często obsługuje któreś z nich i że należy podpowiedzieć ACPI, żeby sobie dał z tym spokój.

I rzeczywiście, w moim przypadku, czyli Macbooku 11,3 chodziło o przerwanie numer 6. Co je generuje? Jeszcze nie wiem ale pewnie się dowiem bo pojawienie się tzw. sztormu GPE (GPE storm) to znak, że coś złego dzieje się ze sprzętem. Pisałem, że klapa (lid) przestała się domykać?

Nie będę się rozwodził nad tematem bo obecnie interesuje mnie tylko likwidacja obciążenia procesora. A robi się to przez dodanie do systemowego crontaba (crontab -e) następującego wpisu:

@reboot echo "disable" > /sys/firmware/acpi/interrupts/gpe06

Przydatne linki:

https://unix.stackexchange.com/questions/242013/disable-gpe-acpi-interrupts-on-boot

https://www.kernel.org/doc/ols/2005/ols2005v1-pages-59-76.pdf

Opis w j. ang.:

ACPI is the Advanced Configuration and Power Interface, which allows Ubuntu (or any OS) to communicate with your hardware in a standard manner. It's main function is power management, along with hardware device configuration.

A GPE in ACPI is a General Purpose Event. Think of it as an interrupt - the hardware is informing the OS (via ACPI) that something happened. The "something" usually includes things like plugging/unplugging your AC adapter, closing/opening the lid of your laptop, etc.

EC is the embedded controller which provides ACPI functions on your motherboard.

A GPE storm occurs when the EC starts sending hundreds or thousands of "events" per second to the OS -- these are either spurious (bogus), or due to some fault in the underlying hardware. e.g. a failure in your battery's charging controller leads the ACPI EC to think that the battery is being removed and reinserted hundreds of times per second.

Transactions will use polling mode means that to handle the storm, the OS will stop using GPEs/interrupts to be informed of ACPI events and will instead -- on its own schedule -- "poll" or proactively ask the ACPI EC if any events it should know of have occurred. This way, the OS can still effectively perform ACPI functions while not being overwhelmed with a "GPE storm".