Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1343310 > unrolled thread

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

Started byPeter Zijlstra <peterz@infradead.org>
First post2016-02-25 17:50 +0100
Last post2016-02-25 18:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH net-next 1/3] perf: generalize perf_callchain Peter Zijlstra <peterz@infradead.org> - 2016-02-25 17:50 +0100
    Re: [PATCH net-next 1/3] perf: generalize perf_callchain Alexei Starovoitov <ast@fb.com> - 2016-02-25 18:30 +0100

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

FromPeter Zijlstra <peterz@infradead.org>
Date2016-02-25 17:50 +0100
SubjectRe: [PATCH net-next 1/3] perf: generalize perf_callchain
Message-ID<r67h0-6Ay-11@gated-at.bofh.it>
On Wed, Feb 17, 2016 at 07:58:57PM -0800, Alexei Starovoitov wrote:
> +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;
}

[toc] | [next] | [standalone]


#1343344

FromAlexei Starovoitov <ast@fb.com>
Date2016-02-25 18:30 +0100
Message-ID<r67TJ-74I-33@gated-at.bofh.it>
In reply to#1343310
On 2/25/16 8:47 AM, Peter Zijlstra wrote:
> On Wed, Feb 17, 2016 at 07:58:57PM -0800, Alexei Starovoitov wrote:
>> +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 ?

because that's the interface you had for callbacks in
'struct stacktrace_ops' including a comment there:
/* On negative return stop dumping */

> 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;
> }

I would prefer something like this as well, but it would look
inconsistent with what is already there. To make it bool
one would need to change struct stacktrace_ops for all archs
and touch a lot of files all over the tree.
Way more than 51 insertions(+), 29 deletions(-) as this patch did
for no real gain.
It's better to be consistent with existing code.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web