Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3540595ybz; Mon, 20 Apr 2020 04:59:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLyTAv/rqSZ8F2TSqJedpvcE3PzC5Um6VXiYcJnUMGBsU3zOxCyuyZxlDEzP/B4g03g/Njz X-Received: by 2002:a05:6402:1008:: with SMTP id c8mr13361633edu.242.1587383955188; Mon, 20 Apr 2020 04:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383955; cv=none; d=google.com; s=arc-20160816; b=hVyaiCtcEwBfE65OYU+eaz2s4YtosMlcPgfWQ1fJzx20gYZjhSSQlBkr2ubLMJfUFz ASv97Wlaez3+pqn+rTE/tDs5BfycsD6L9sRz/8U/n4l21QKDekMBzNKM8rCNE6laHTps lW+zj2dCsZ6reo1yb2iUNOwf6mObhjs+aRxy5agb7OPhuRMG95Uxji+j2XVsFfXucLWQ eCMgOq4k54ybzJ3gNRoYqIfHdhM7MKwb8N6JFJ5HOHPs2eyqdLN/hBenSWITPr176ZB0 3Dwu9skv5krwLaWyRVub/ozWrfRPBVBRNp8IGjb9kAIeM9Y3ICid0zNlUxTcWcZgrVIe AE3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZUMaQkFLtNQgJOS5+AwEwNA6p5Lthxp8bB1ofhieeKo=; b=i2TrIoeqWzQu+mKRa7dy0i43yk1Ua6873kKL1tYun8U8cyMqk4e5jUCUzHQuh4U+TQ N6BxGLK89v8Hz60hJdqph4Mekf+GW9TsYPEXaXwmWw+UEi8IQnKBz2DSM5btjRVIlnWp 6eB/AzvyUdMRe7LvbGQLbF6Lgn8E3bWGo0kmnddcvgyqIaxEFdONBiWHfKj+DXPwx9Ba MlSeerQOisdzeP3Re8JOo3yUB4903UOJdHTyUQswK2UPViuzNfz+yQDN2/yyMBZDfBzx KwOlZqak7sMPAKQd2XGkvbVP7uhtMoY+UcNXsS4UzjvCMRCCIOKf4R9+aLShk2OuqDn5 cBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p//tgucm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si413051ejr.440.2020.04.20.04.58.52; Mon, 20 Apr 2020 04:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p//tgucm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgDTL5B (ORCPT + 99 others); Mon, 20 Apr 2020 07:57:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726402AbgDTL47 (ORCPT ); Mon, 20 Apr 2020 07:56:59 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B1C522209; Mon, 20 Apr 2020 11:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383818; bh=mrQGR8mQ7da433xvPuuVThJWpyapRQcoo0qjohvjqXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p//tgucmcDLL+TdwU8Ho+Nmm7wcNEahMH6EliIkLRmrGfttWQ1vwhUdt2tiRwBdRw k3h4mXcmzR124m+OleqtcSz/ZMLO3FdbwuGVTSUMp6M9qATbmcrowNSOJg82BogQh4 omjxsoBOTCF+vDG6bi+2aA+DinK2CRwr8DcrfSSE= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Kan Liang , Andi Kleen , Jiri Olsa , Adrian Hunter , Alexey Budankov , Mathieu Poirier , Michael Ellerman , Pavel Gerasimov , Peter Zijlstra , Ravi Bangoria , Stephane Eranian , Vitaly Slobodskoy , Arnaldo Carvalho de Melo Subject: [PATCH 48/60] perf machine: Remove the indent in resolve_lbr_callchain_sample Date: Mon, 20 Apr 2020 08:53:04 -0300 Message-Id: <20200420115316.18781-49-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200420115316.18781-1-acme@kernel.org> References: <20200420115316.18781-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang The indent is unnecessary in resolve_lbr_callchain_sample. Removing it will make the following patch simpler. Current code path for resolve_lbr_callchain_sample() /* LBR only affects the user callchain */ if (i != chain_nr) { body of the function .... return 1; } return 0; With the patch, /* LBR only affects the user callchain */ if (i == chain_nr) return 0; body of the function ... return 1; No functional changes. Signed-off-by: Kan Liang Reviewed-by: Andi Kleen Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexey Budankov Cc: Mathieu Poirier Cc: Michael Ellerman Cc: Namhyung Kim Cc: Pavel Gerasimov Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Stephane Eranian Cc: Vitaly Slobodskoy Link: http://lore.kernel.org/lkml/20200319202517.23423-6-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 123 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 09845eae9c03..be1bd9277471 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2208,6 +2208,12 @@ static int resolve_lbr_callchain_sample(struct thread *thread, int chain_nr = min(max_stack, (int)chain->nr), i; u8 cpumode = PERF_RECORD_MISC_USER; u64 ip, branch_from = 0; + struct branch_stack *lbr_stack; + struct branch_entry *entries; + int lbr_nr, j, k; + bool branch; + struct branch_flags *flags; + int mix_chain_nr; for (i = 0; i < chain_nr; i++) { if (chain->ips[i] == PERF_CONTEXT_USER) @@ -2215,71 +2221,68 @@ static int resolve_lbr_callchain_sample(struct thread *thread, } /* LBR only affects the user callchain */ - if (i != chain_nr) { - struct branch_stack *lbr_stack = sample->branch_stack; - struct branch_entry *entries = perf_sample__branch_entries(sample); - int lbr_nr = lbr_stack->nr, j, k; - bool branch; - struct branch_flags *flags; - /* - * LBR callstack can only get user call chain. - * The mix_chain_nr is kernel call chain - * number plus LBR user call chain number. - * i is kernel call chain number, - * 1 is PERF_CONTEXT_USER, - * lbr_nr + 1 is the user call chain number. - * For details, please refer to the comments - * in callchain__printf - */ - int mix_chain_nr = i + 1 + lbr_nr + 1; - - for (j = 0; j < mix_chain_nr; j++) { - int err; - branch = false; - flags = NULL; + if (i == chain_nr) + return 0; - if (callchain_param.order == ORDER_CALLEE) { - if (j < i + 1) - ip = chain->ips[j]; - else if (j > i + 1) { - k = j - i - 2; - ip = entries[k].from; - branch = true; - flags = &entries[k].flags; - } else { - ip = entries[0].to; - branch = true; - flags = &entries[0].flags; - branch_from = entries[0].from; - } + lbr_stack = sample->branch_stack; + entries = perf_sample__branch_entries(sample); + lbr_nr = lbr_stack->nr; + /* + * LBR callstack can only get user call chain. + * The mix_chain_nr is kernel call chain + * number plus LBR user call chain number. + * i is kernel call chain number, + * 1 is PERF_CONTEXT_USER, + * lbr_nr + 1 is the user call chain number. + * For details, please refer to the comments + * in callchain__printf + */ + mix_chain_nr = i + 1 + lbr_nr + 1; + + for (j = 0; j < mix_chain_nr; j++) { + int err; + + branch = false; + flags = NULL; + + if (callchain_param.order == ORDER_CALLEE) { + if (j < i + 1) + ip = chain->ips[j]; + else if (j > i + 1) { + k = j - i - 2; + ip = entries[k].from; + branch = true; + flags = &entries[k].flags; } else { - if (j < lbr_nr) { - k = lbr_nr - j - 1; - ip = entries[k].from; - branch = true; - flags = &entries[k].flags; - } - else if (j > lbr_nr) - ip = chain->ips[i + 1 - (j - lbr_nr)]; - else { - ip = entries[0].to; - branch = true; - flags = &entries[0].flags; - branch_from = entries[0].from; - } + ip = entries[0].to; + branch = true; + flags = &entries[0].flags; + branch_from = entries[0].from; + } + } else { + if (j < lbr_nr) { + k = lbr_nr - j - 1; + ip = entries[k].from; + branch = true; + flags = &entries[k].flags; + } else if (j > lbr_nr) + ip = chain->ips[i + 1 - (j - lbr_nr)]; + else { + ip = entries[0].to; + branch = true; + flags = &entries[0].flags; + branch_from = entries[0].from; } - - err = add_callchain_ip(thread, cursor, parent, - root_al, &cpumode, ip, - branch, flags, NULL, - branch_from); - if (err) - return (err < 0) ? err : 0; } - return 1; - } - return 0; + err = add_callchain_ip(thread, cursor, parent, + root_al, &cpumode, ip, + branch, flags, NULL, + branch_from); + if (err) + return (err < 0) ? err : 0; + } + return 1; } static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, -- 2.21.1