From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760980AbcBYR2m (ORCPT ); Thu, 25 Feb 2016 12:28:42 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:58132 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758976AbcBYR2k (ORCPT ); Thu, 25 Feb 2016 12:28:40 -0500 Subject: Re: [PATCH net-next 1/3] perf: generalize perf_callchain To: Peter Zijlstra References: <1455767939-2700534-1-git-send-email-ast@fb.com> <1455767939-2700534-2-git-send-email-ast@fb.com> <20160225164729.GS6356@twins.programming.kicks-ass.net> CC: "David S. Miller" , Ingo Molnar , Steven Rostedt , Wang Nan , Daniel Borkmann , Brendan Gregg , , From: Alexei Starovoitov Message-ID: <56CF398A.8020905@fb.com> Date: Thu, 25 Feb 2016 09:27:38 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160225164729.GS6356@twins.programming.kicks-ass.net> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-02-25_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.