Thread (6 messages) flat view 6 messages, 3 authors, 2021-02-04

Re: [for-next][PATCH 14/15] tracepoint: Do not fail unregistering a probe due to memory failure

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-02-03 17:10:51
Also in: bpf, lkml

On Wed, Feb 03, 2021 at 11:05:31AM -0500, Steven Rostedt wrote:
+		if (new) {
+			for (i = 0; old[i].func; i++)
+				if ((old[i].func != tp_func->func
+				     || old[i].data != tp_func->data)
+				    && old[i].func != tp_stub_func)
logical operators go at the end..
+					new[j++] = old[i];
+			new[nr_probes - nr_del].func = NULL;
+			*funcs = new;
+		} else {
+			/*
+			 * Failed to allocate, replace the old function
+			 * with calls to tp_stub_func.
+			 */
+			for (i = 0; old[i].func; i++)
							{
+				if (old[i].func == tp_func->func &&
+				    old[i].data == tp_func->data) {
like here.
+					old[i].func = tp_stub_func;
+					/* Set the prio to the next event. */
+					if (old[i + 1].func)
+						old[i].prio =
+							old[i + 1].prio;
multi line demands { }, but in this case just don't line-break.
+					else
+						old[i].prio = -1;
+				}
			}
quoted hunk ↗ jump to hunk
+			*funcs = old;
+		}
 	}
 	debug_print_probes(*funcs);
 	return old;
@@ -295,10 +341,12 @@ static int tracepoint_remove_func(struct tracepoint *tp,
 	tp_funcs = rcu_dereference_protected(tp->funcs,
 			lockdep_is_held(&tracepoints_mutex));
 	old = func_remove(&tp_funcs, func);
-	if (IS_ERR(old)) {
-		WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
+	if (WARN_ON_ONCE(IS_ERR(old)))
 		return PTR_ERR(old);
-	}
+
+	if (tp_funcs == old)
+		/* Failed allocating new tp_funcs, replaced func with stub */
+		return 0;
{ }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help