You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

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