Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerneltoast/68db137e55f3fa1add03540b5673818d to your computer and use it in GitHub Desktop.
Save kerneltoast/68db137e55f3fa1add03540b5673818d to your computer and use it in GitHub Desktop.
From 5bc135475f0573d4651e96ee9786d29e685b3774 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <sultan@openresty.com>
Date: Tue, 1 Dec 2020 10:06:50 -0800
Subject: [PATCH] task_finder_vma: add kfree_rcu() compat for old unpatched
kernels
Newer RHEL 6 kernels have kfree_rcu(), but older ones do not. Using
kfree_rcu() is beneficial because it lets the RCU subsystem know that
the queued RCU callback is low-priority, and can be deferred, hence why
we don't replace kfree_rcu() with call_rcu() outright.
---
runtime/task_finder_vma.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/runtime/task_finder_vma.c b/runtime/task_finder_vma.c
index 7f0f6ed56..831ad6932 100644
--- a/runtime/task_finder_vma.c
+++ b/runtime/task_finder_vma.c
@@ -87,6 +87,15 @@ __stp_tf_vma_new_entry(void)
return entry;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+static void __stp_tf_vma_free_entry(struct rcu_head *rcu)
+{
+ struct __stp_tf_vma_entry *entry = container_of(rcu, typeof(*entry), rcu);
+
+ kfree(entry);
+}
+#endif
+
// __stp_tf_vma_put_entry(): Put a specified number of references on the entry.
static void
__stp_tf_vma_put_entry(struct __stp_tf_vma_bucket *bucket,
@@ -106,7 +115,11 @@ __stp_tf_vma_put_entry(struct __stp_tf_vma_bucket *bucket,
hlist_del_rcu(&entry->hlist);
stp_spin_unlock_irqrestore(&bucket->lock, flags);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+ call_rcu(&entry->rcu, __stp_tf_vma_free_entry);
+#else
kfree_rcu(entry, rcu);
+#endif
}
// stap_initialize_vma_map(): Initialize the free list. Grabs the
--
2.29.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment