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/9808dd94155cd1b3a38fd0ca6b4bd59a to your computer and use it in GitHub Desktop.
Save kerneltoast/9808dd94155cd1b3a38fd0ca6b4bd59a to your computer and use it in GitHub Desktop.
From 3193be09a99a1fa48eb1c0f290c48eba53d1bb11 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <sultan@openresty.com>
Date: Wed, 20 Jan 2021 12:55:40 -0800
Subject: [PATCH] stp_utrace: remove unneeded RCU-freed field from struct
utrace
We're only using RCU on struct utrace in order to allow non-blocking
iteration through the hashlists. RCU is not used to manage the lifetime
of utrace structs; once a utrace struct is ready to be freed, nothing
will try to grab it anymore, so we can remove the unneeded utrace->freed
check.
---
runtime/stp_utrace.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index a0d2ae34f..9cc910222 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -111,7 +111,6 @@ struct utrace {
unsigned int death:1; /* in utrace_report_death() now */
unsigned int reap:1; /* release_task() has run */
unsigned int pending_attach:1; /* need splice_attaching() */
- unsigned int freed:1; /* pending RCU free */
/* We need the '*_work_added' variables to be atomic so they
* can be modified without locking the utrace struct. This is
@@ -481,7 +480,6 @@ static int utrace_exit(void)
rcu_read_lock();
stap_hlist_for_each_entry_rcu(utrace, node, &bucket->head, hlist) {
- utrace->freed = true;
stp_spin_lock_irqsave(&bucket->lock, flags);
hlist_del_rcu(&utrace->hlist);
stp_spin_unlock_irqrestore(&bucket->lock, flags);
@@ -673,7 +671,7 @@ static struct utrace *task_utrace_struct(struct utrace_bucket *bucket,
rcu_read_lock();
stap_hlist_for_each_entry_rcu(utrace, node, &bucket->head, hlist) {
- if (utrace->task == task && !utrace->freed) {
+ if (utrace->task == task) {
found = utrace;
break;
}
@@ -747,7 +745,6 @@ static void utrace_free(struct utrace_bucket *bucket, struct utrace *utrace)
/* Remove this utrace from the mapping list of tasks to
* struct utrace. */
- utrace->freed = true;
stp_spin_lock_irqsave(&bucket->lock, flags);
hlist_del_rcu(&utrace->hlist);
stp_spin_unlock_irqrestore(&bucket->lock, flags);
--
2.30.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment