Re: [PATCH net-next 1/3] perf: generalize perf_callchain

From
Peter Zijlstra <peterz@infradead.org>
Date
2016-02-25 16:47:36
Also in
lkml
Reply to
Alexei Starovoitov, 2016-02-18
On Wed, Feb 17, 2016 at 07:58:57PM -0800, Alexei Starovoitov wrote:
quoted hunk ↗ jump to hunk
+static inline int perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
 {
+	if (entry->nr < PERF_MAX_STACK_DEPTH) {
 		entry->ip[entry->nr++] = ip;
+		return 0;
+	} else {
+		return -1; /* no more room, stop walking the stack */
+	}
 }
Why 0 and -1 ?

What's wrong with something like:

static inline bool perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
{
	if (entry->nr < PERF_MAX_STACK_DEPTH) {
		entry->ip[entry->nr++] = ip;
		return true;
	}
	return false;
}
Thread (16 messages) 16 messages, 3 authors, last reply 2016-02-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help