From 54e783959b5d3622556bbf34a3a7ad8e481d9e25 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 26 Aug 2021 18:53:29 -0400 Subject: Use procfs instead of dmesg to print runlist `cat /proc/runlist` to print the current runlist. Also break nvdebug.c into nvdebug_entry.c, runlist.c, and runlist_procfs.c. --- nvdebug_entry.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 nvdebug_entry.c (limited to 'nvdebug_entry.c') diff --git a/nvdebug_entry.c b/nvdebug_entry.c new file mode 100644 index 0000000..148bd3f --- /dev/null +++ b/nvdebug_entry.c @@ -0,0 +1,40 @@ +/* Copyright 2021 Joshua Bakita + * SPDX-License-Identifier: MIT + */ + +/* TODO + * - Add sysfs trigger for a preemption + */ + +#include +#include +#include // So we can set up entries in /proc + +#include "nvdebug.h" + +// LIAR. But without this we can't use GPL-only exported symbols like +// platform_bus_type or bus_find_device_by_name... +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Joshua Bakita"); +MODULE_DESCRIPTION("A scheduling debugging module for NVIDIA GPUs"); +MODULE_SOFTDEP("pre: nvgpu"); // We only support the Jetson boards for now + +extern const struct file_operations runlist_file_ops; + +int __init nvdebug_init(void) { + struct proc_dir_entry *entry = proc_create("runlist", 0444, NULL, &runlist_file_ops); + if (!entry) { + remove_proc_entry("runlist", NULL); + printk(KERN_ERR "[nvdebug] Unable to initialize procfs entries!\n"); + return -ENOMEM; + } + return 0; +} + +static void __exit nvdebug_exit(void) { + remove_proc_entry("runlist", NULL); + printk(KERN_INFO "[nvdebug] Exiting...\n"); +} + +module_init(nvdebug_init); +module_exit(nvdebug_exit); -- cgit v1.2.2