bugfix:fix potential dead loop when parsing interrupts

when parsing /proc/interrupts and if a chip name start with numbers,
current procedure would consider those  numbers as interrupt count thus
lead to miscount. Failed parsing would trigger new parsing and cause
dead loop which can't be stopped by SIGINT and SIGTERM. So fix this
by adding signal checks in loop.

Signed-off-by: qinyu <qinyu32@huawei.com>
This commit is contained in:
qinyu 2022-07-12 16:20:27 +08:00
parent a3736222a9
commit b82a6c9b59
3 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From 028082a6a1ff650d5cdf796ac55ac26a3874372a Mon Sep 17 00:00:00 2001
From: Liu Chao <liuchao173@huawei.com>
Date: Sat, 25 Jun 2022 14:13:10 +0800
Subject: [PATCH] add keep_going check to prevent irqbalance from failing to
exit after SIGTERM
Signed-off-by: Liu Chao <liuchao173@huawei.com>
---
irqbalance.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/irqbalance.c b/irqbalance.c
index c520c11..5eae5b6 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -290,7 +290,7 @@ gboolean scan(gpointer data __attribute__((unused)))
/* cope with cpu hotplug -- detected during /proc/interrupts parsing */
- while (need_rescan || need_rebuild) {
+ while (keep_going && (need_rescan || need_rebuild)) {
int try_times = 0;
need_rescan = 0;
--
2.23.0

View File

@ -0,0 +1,25 @@
From 0a82dddbaf5702caded0d0d83a6eafaca743254d Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Mon, 27 Jun 2022 13:43:04 +0200
Subject: [PATCH] parse_proc_interrupts: fix parsing interrupt counts
The name of an interrupt chip can start with a number, stop before it.
---
procinterrupts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index 57c8801..d90bf6d 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -331,7 +331,7 @@ void parse_proc_interrupts(void)
while (1) {
uint64_t C;
C = strtoull(c, &c2, 10);
- if (c==c2) /* end of numbers */
+ if (c==c2 || !strchr(" \t", *c2)) /* end of numbers */
break;
count += C;
c=c2;
--
2.23.0

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.8.0
Release: 7
Release: 8
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
@ -22,6 +22,8 @@ Requires: numactl-libs
%define _hardened_build 1
Patch6000: bugfix-fix-unsigned-integer-subtraction-sign-overflow.patch
Patch6001: bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch
Patch6002: bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch
%description
Irqbalance is a daemon to help balance the cpu load generated by
@ -79,6 +81,12 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Tue Jul 12 2022 qinyu <qinyu32@huawei.com> - 3:1.8.0-8
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:fix potential dead loop when parsing interrupts
* Mon Feb 21 2022 Liu Chao <liuchao173@huawei.com> - 3:1.8.0-7
- Type:bugfix
- ID:NA