softirqs.c 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <linux/init.h>
  2. #include <linux/kernel_stat.h>
  3. #include <linux/proc_fs.h>
  4. #include <linux/seq_file.h>
  5. /*
  6. * /proc/softirqs ... display the number of softirqs
  7. */
  8. static int show_softirqs(struct seq_file *p, void *v)
  9. {
  10. int i, j;
  11. seq_puts(p, " ");
  12. for_each_possible_cpu(i)
  13. seq_printf(p, "CPU%-8d", i);
  14. seq_putc(p, '\n');
  15. for (i = 0; i < NR_SOFTIRQS; i++) {
  16. seq_printf(p, "%12s:", softirq_to_name[i]);
  17. for_each_possible_cpu(j)
  18. seq_printf(p, " %10u", kstat_softirqs_cpu(i, j));
  19. seq_putc(p, '\n');
  20. }
  21. return 0;
  22. }
  23. static int softirqs_open(struct inode *inode, struct file *file)
  24. {
  25. return single_open(file, show_softirqs, NULL);
  26. }
  27. static const struct file_operations proc_softirqs_operations = {
  28. .open = softirqs_open,
  29. .read = seq_read,
  30. .llseek = seq_lseek,
  31. .release = single_release,
  32. };
  33. static int __init proc_softirqs_init(void)
  34. {
  35. proc_create("softirqs", 0, NULL, &proc_softirqs_operations);
  36. return 0;
  37. }
  38. fs_initcall(proc_softirqs_init);