trace-printk.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <linux/module.h>
  2. #include <linux/kthread.h>
  3. #include <linux/irq_work.h>
  4. /* Must not be static to force gcc to consider these non constant */
  5. char *trace_printk_test_global_str =
  6. "This is a dynamic string that will use trace_puts\n";
  7. char *trace_printk_test_global_str_irq =
  8. "(irq) This is a dynamic string that will use trace_puts\n";
  9. char *trace_printk_test_global_str_fmt =
  10. "%sThis is a %s that will use trace_printk\n";
  11. static struct irq_work irqwork;
  12. static void trace_printk_irq_work(struct irq_work *work)
  13. {
  14. trace_printk("(irq) This is a static string that will use trace_bputs\n");
  15. trace_printk(trace_printk_test_global_str_irq);
  16. trace_printk("(irq) This is a %s that will use trace_bprintk()\n",
  17. "static string");
  18. trace_printk(trace_printk_test_global_str_fmt,
  19. "(irq) ", "dynamic string");
  20. }
  21. static int __init trace_printk_init(void)
  22. {
  23. init_irq_work(&irqwork, trace_printk_irq_work);
  24. trace_printk("This is a static string that will use trace_bputs\n");
  25. trace_printk(trace_printk_test_global_str);
  26. /* Kick off printing in irq context */
  27. irq_work_queue(&irqwork);
  28. trace_printk("This is a %s that will use trace_bprintk()\n",
  29. "static string");
  30. trace_printk(trace_printk_test_global_str_fmt, "", "dynamic string");
  31. return 0;
  32. }
  33. static void __exit trace_printk_exit(void)
  34. {
  35. }
  36. module_init(trace_printk_init);
  37. module_exit(trace_printk_exit);
  38. MODULE_AUTHOR("Steven Rostedt");
  39. MODULE_DESCRIPTION("trace-printk");
  40. MODULE_LICENSE("GPL");