hardirqs: fix issue if irq is triggered while idle task (tid=0)
authorIsm Hong <ism.hong@gmail.com>
Wed, 8 Dec 2021 02:17:20 +0000 (10:17 +0800)
committeryonghong-song <ys114321@gmail.com>
Thu, 9 Dec 2021 06:45:57 +0000 (22:45 -0800)
commit99bfe8ac0b3f5d0422e47e09abc073425dc22968
tree2a5487b2bd4827f2b4acc59607b15182e2c25512
parent814c264d8088fc566dd9a5650691158281792cb4
hardirqs: fix issue if irq is triggered while idle task (tid=0)

Currently, hardirqs use tid as key to store information while tracepoint
irq_handler_entry. It works fine if irq is triggered while normal task
running, but there is a chance causing overwrite issue while irq is
triggered while idle task (a.k.a swapper/x, tid=0) running on multi-core
system.

Let's say there are two irq event trigger simultaneously on both CPU
core, irq A @ core #0, irq B @ core #1, and system load is pretty light,
so BPF program will get tid=0 since current task is swapper/x for both cpu
core. In this case, the information of first irq event stored in map could
be overwritten by incoming second irq event.

Use tid and cpu_id together to make sure the key is unique for each
event in this corner case.

Please check more detail at merge request #2804, #3733.
tools/hardirqs.py