5c6cb4ec64c6e4d81275ad65b9d4cc843771fc74
[feed/packages.git] / utils / irqbalance / patches / 0001-post-190-fix-get-irq-module.patch
1 From ff48ac9c84f0b318dfce665605d72e86dfcfe008 Mon Sep 17 00:00:00 2001
2 From: Chao Liu <liuchao173@huawei.com>
3 Date: Tue, 7 Jun 2022 15:15:15 +0800
4 Subject: [PATCH] get irq->module relationship from /sys/bus/pci/*/driver
5
6 Signed-off-by: Chao Liu <liuchao173@huawei.com>
7 ---
8 classify.c | 19 +++++++++++++++++--
9 1 file changed, 17 insertions(+), 2 deletions(-)
10
11 --- a/classify.c
12 +++ b/classify.c
13 @@ -7,6 +7,7 @@
14 #include <dirent.h>
15 #include <assert.h>
16 #include <errno.h>
17 +#include <libgen.h>
18
19 #include "irqbalance.h"
20 #include "types.h"
21 @@ -578,7 +579,7 @@ static int check_for_module_ban(char *na
22 return 0;
23 }
24
25 -static int check_for_irq_ban(int irq, GList *proc_interrupts)
26 +static int check_for_irq_ban(int irq, char *mod, GList *proc_interrupts)
27 {
28 struct irq_info find, *res;
29 GList *entry;
30 @@ -594,6 +595,9 @@ static int check_for_irq_ban(int irq, GL
31 /*
32 * Check to see if we banned module which the irq belongs to.
33 */
34 + if (mod != NULL && strlen(mod) > 0 && check_for_module_ban(mod))
35 + return 1;
36 +
37 entry = g_list_find_custom(proc_interrupts, &find, compare_ints);
38 if (entry) {
39 res = entry->data;
40 @@ -609,14 +613,25 @@ static void add_new_irq(char *path, stru
41 struct irq_info *new;
42 struct user_irq_policy pol;
43 int irq = hint->irq;
44 + char buf[PATH_MAX], drvpath[PATH_MAX];
45 + char *mod = NULL;
46 + int ret;
47
48 new = get_irq_info(irq);
49 if (new)
50 return;
51
52 + if (path) {
53 + sprintf(buf, "%s/driver", path);
54 + ret = readlink(buf, drvpath, PATH_MAX);
55 + if (ret > 0 && ret < PATH_MAX) {
56 + drvpath[ret] = '\0';
57 + mod = basename(drvpath);
58 + }
59 + }
60 /* Set NULL devpath for the irq has no sysfs entries */
61 get_irq_user_policy(path, irq, &pol);
62 - if ((pol.ban == 1) || check_for_irq_ban(irq, proc_interrupts)) { /*FIXME*/
63 + if ((pol.ban == 1) || check_for_irq_ban(irq, mod, proc_interrupts)) { /*FIXME*/
64 __add_banned_irq(irq, &banned_irqs);
65 new = get_irq_info(irq);
66 } else