Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kmod): remove AGN_DEBUG #348

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions kmod/agnocast.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

MODULE_LICENSE("Dual BSD/GPL");

// Temporary debug messages to solve a specific problem
#define AGN_DEBUG(fmt, ...) \
printk(KERN_DEBUG "agnocast_debug[%s:%d]: " fmt, __func__, __LINE__, ##__VA_ARGS__)

static int major;
static struct class * agnocast_class;
static struct device * agnocast_device;
Expand Down Expand Up @@ -1531,27 +1527,17 @@ static void process_exit_cleanup(const pid_t pid)

static int exit_worker_thread(void * data)
{
AGN_DEBUG("exit_worker_thread() start: current->pid=%d", current->pid);

while (!kthread_should_stop()) {
pid_t pid;
unsigned long flags;
bool got_pid = false;

AGN_DEBUG("before wait_event_interruptible() called: current->pid=%d", current->pid);

wait_event_interruptible(worker_wait, atomic_read(&has_new_pid) || kthread_should_stop());

AGN_DEBUG("after wait_event_interruptible() called: current->pid=%d", current->pid);

if (kthread_should_stop()) break;

AGN_DEBUG("before spin_lock_irqsave() called: current->pid=%d", current->pid);

spin_lock_irqsave(&pid_queue_lock, flags);

AGN_DEBUG("after spin_lock_irqsave() called: current->pid=%d", current->pid);

if (queue_head != queue_tail) {
pid = exit_pid_queue[queue_head];
queue_head = (queue_head + 1) & (EXIT_QUEUE_SIZE - 1);
Expand All @@ -1561,23 +1547,12 @@ static int exit_worker_thread(void * data)
// queue is empty
if (queue_head == queue_tail) atomic_set(&has_new_pid, 0);

AGN_DEBUG("before spin_unlock_irqrestore() called: current->pid=%d", current->pid);

spin_unlock_irqrestore(&pid_queue_lock, flags);

AGN_DEBUG("after spin_unlock_irqrestore() called: current->pid=%d", current->pid);

if (got_pid) {
AGN_DEBUG(
"before mutex_lock(global_mutex) called: pid=%d current->pid=%d", pid, current->pid);
mutex_lock(&global_mutex);
AGN_DEBUG("after mutex_lock(global_mutex) called: pid=%d current->pid=%d", pid, current->pid);
process_exit_cleanup(pid);
AGN_DEBUG(
"before mutex_unlock(global_mutex) called: pid=%d current->pid=%d", pid, current->pid);
mutex_unlock(&global_mutex);
AGN_DEBUG(
"after mutex_unlock(global_mutex) called: pid=%d current->pid=%d", pid, current->pid);
}
}

Expand All @@ -1589,12 +1564,8 @@ static int pre_handler_do_exit(struct kprobe * p, struct pt_regs * regs)
unsigned long flags;
uint32_t next;

AGN_DEBUG("before spin_lock_irqsave() called: current->pid=%d", current->pid);

spin_lock_irqsave(&pid_queue_lock, flags);

AGN_DEBUG("after spin_lock_irqsave() called: current->pid=%d", current->pid);

// Assumes EXIT_QUEUE_SIZE is 2^N
next = (queue_tail + 1) & (EXIT_QUEUE_SIZE - 1);

Expand All @@ -1603,22 +1574,14 @@ static int pre_handler_do_exit(struct kprobe * p, struct pt_regs * regs)
queue_tail = next;
atomic_set(&has_new_pid, 1);

AGN_DEBUG("before wake_up_interruptible() called: current->pid=%d", current->pid);

wake_up_interruptible(&worker_wait);

AGN_DEBUG("after wake_up_interruptible() called: current->pid=%d", current->pid);
} else {
// do nothing and put error message
dev_warn(agnocast_device, "exit_pid_queue is full! consider expanding the queue size\n");
}

AGN_DEBUG("before spin_unlock_irqrestore() called: current->pid=%d", current->pid);

spin_unlock_irqrestore(&pid_queue_lock, flags);

AGN_DEBUG("after spin_unlock_irqrestore() called: current->pid=%d", current->pid);

return 0;
}

Expand Down